"Fossies" - the Fresh Open Source Software Archive

Member "LinOTP-release-2.10.5.2/linotpd/src/linotp/provider/create_provider_ini.py" (13 May 2019, 2121 Bytes) of package /linux/misc/LinOTP-release-2.10.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "create_provider_ini.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #    LinOTP - the open source solution for two factor authentication
    4 #    Copyright (C) 2010 - 2019 KeyIdentity GmbH
    5 #
    6 #    This file is part of LinOTP server.
    7 #
    8 #    This program is free software: you can redistribute it and/or
    9 #    modify it under the terms of the GNU Affero General Public
   10 #    License, version 3, as published by the Free Software Foundation.
   11 #
   12 #    This program is distributed in the hope that it will be useful,
   13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 #    GNU Affero General Public License for more details.
   16 #
   17 #    You should have received a copy of the
   18 #               GNU Affero General Public License
   19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   20 #
   21 #
   22 #    E-mail: linotp@keyidentity.com
   23 #    Contact: www.linotp.org
   24 #    Support: www.keyidentity.com
   25 #
   26 
   27 import cStringIO
   28 from linotp.lib.utils.UConfigParser import UConfigParser
   29 
   30 
   31 def create_provider_config():
   32     """
   33     not used but implemented to generate templates of provider configs
   34     'contents' contains the ini file
   35     """
   36     from linotp.provider import Provider_types
   37     from linotp.provider import get_all_new_providers
   38 
   39     provider_config = {}
   40     for provider_type in Provider_types.keys():
   41 
   42         providers = get_all_new_providers(provider_type,
   43                                           show_managed_config=True)
   44 
   45         provider_config[provider_type] = providers
   46 
   47     ini = UConfigParser()
   48 
   49     for provider_type, providers in provider_config.items():
   50         for provider in providers.keys():
   51             section = '%s:%s' % (provider_type, provider)
   52             ini.add_section(section)
   53 
   54             provider_config = providers.get(provider)
   55             for key, value in provider_config.items():
   56                 if isinstance(value, unicode):
   57                     value = value.encode('utf-8')
   58 
   59                 ini.set(section, key, value)
   60 
   61     output = cStringIO.StringIO()
   62     ini.write(output)
   63     contents = output.getvalue()
   64     output.close()
   65     return contents