本文整理汇总了Python中saml2.config.Config.load方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load方法的具体用法?Python Config.load怎么用?Python Config.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saml2.config.Config
的用法示例。
在下文中一共展示了Config.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_metadata
# 需要导入模块: from saml2.config import Config [as 别名]
# 或者: from saml2.config.Config import load [as 别名]
def _make_metadata(config_dict, option):
"""
Creates metadata from the given idp config
:type config_dict: dict[str, Any]
:type option: vopaas.metadata_creation.make_vopaas_metadata.MetadataOption
:rtype: str
:param config_dict: config
:param option: metadata creation settings
:return: A xml string
"""
eds = []
cnf = Config()
cnf.load(copy.deepcopy(config_dict), metadata_construction=True)
if option.valid:
cnf.valid_for = option.valid
eds.append(entity_descriptor(cnf))
conf = Config()
conf.key_file = option.keyfile
conf.cert_file = option.cert
conf.debug = 1
conf.xmlsec_binary = option.xmlsec
secc = security_context(conf)
if option.id:
desc, xmldoc = entities_descriptor(eds, option.valid, option.name, option.id, option.sign, secc)
valid_instance(desc)
print(desc.to_string(NSPAIR))
else:
for eid in eds:
if option.sign:
assert conf.key_file
assert conf.cert_file
eid, xmldoc = sign_entity_descriptor(eid, option.id, secc)
else:
xmldoc = None
valid_instance(eid)
xmldoc = metadata_tostring_fix(eid, NSPAIR, xmldoc).decode()
return xmldoc
示例2: _saml2_config
# 需要导入模块: from saml2.config import Config [as 别名]
# 或者: from saml2.config.Config import load [as 别名]
def _saml2_config(self):
if hasattr(self, '_v_cached_config') and self._v_cached_config:
return self._v_cached_config
config = Config()
conf=sp_config.copy()
metadata_file = self.config['metadata_file']
if not metadata_file:
path = os.path.dirname(__file__)
metadata_file = os.path.join(path, 'metadata.xml')
conf['metadata']['local'] = [metadata_file]
config.load(conf)
config['entityid'] = self.config['portal_url']
config['service']['sp']['name'] = self.config['portal_name']
config['service']['sp']['url'] = self.config['portal_url']
required_attributes = []
for attribute in self.config['required_attributes'].split('\r\n'):
name = attributes.get(attribute, None)
if name:
required_attributes.append(name)
elif attribute in attributes.values():
required_attributes.append(attribute)
optional_attributes = []
for attribute in self.config['optional_attributes'].split('\r\n'):
name = attributes.get(attribute, None)
if name:
optional_attributes.append(name)
elif attribute in attributes.values():
optional_attributes.append(attribute)
config['service']['sp']['required_attributes'] = required_attributes
config['service']['sp']['optional_attributes'] = optional_attributes
config['service']['sp']['privacy_notice'] = self.config['privacy_notice']
config['key_file'] = self.config['key_file']
config['cert_file'] = self.config['cert_file']
config['xmlsec_binary'] = self.config['xmlsec_binary']
# Get Idps from the metadata
config['service']['sp']['idp'] = {}
for location in config['metadata'].locations():
name = config['metadata'].name(location)
config['service']['sp']['idp'][name] = location
self._v_cached_config = config
return self._v_cached_config
示例3: test_load_local
# 需要导入模块: from saml2.config import Config [as 别名]
# 或者: from saml2.config.Config import load [as 别名]
def test_load_local():
# string representation of XML idp definition
idp_metadata = open(full_path("metadata.xml")).read()
saml_config = Config()
config_dict = {
"metadata": {"inline": [idp_metadata]}
}
cfg = saml_config.load(config_dict)
assert cfg