本文整理汇总了Python中saml2.mdstore.MetadataStore.metadata[entityId]方法的典型用法代码示例。如果您正苦于以下问题:Python MetadataStore.metadata[entityId]方法的具体用法?Python MetadataStore.metadata[entityId]怎么用?Python MetadataStore.metadata[entityId]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saml2.mdstore.MetadataStore
的用法示例。
在下文中一共展示了MetadataStore.metadata[entityId]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleMetadataVerifyJson
# 需要导入模块: from saml2.mdstore import MetadataStore [as 别名]
# 或者: from saml2.mdstore.MetadataStore import metadata[entityId] [as 别名]
def handleMetadataVerifyJson(self, environ, start_response, qs):
"""
Handles JSON metadata verifications.
The post body must contains a JSON message like { 'xml' : 'a metadata file'}
:param environ: wsgi enviroment
:param start_response: wsgi start respons
:param qs: Query parameters in a dictionary.
:return: wsgi response contaning a JSON response. The JSON message will contain the parameter ok and services.
ok will contain true if the metadata file can be parsed, otherwise false.
services will contain a list of all the service names contained in the metadata file.
"""
ok = False
services = "[]"
try:
if MetadataGeneration.CONST_BODY in qs:
jsonMessage = json.loads(qs[MetadataGeneration.CONST_BODY])
if "xml" in jsonMessage:
xml = jsonMessage["xml"]
xml = xml.strip()
metadataOK = False
ci = None
try:
mds = MetadataStore(MetadataGeneration.CONST_ONTS.values(),
MetadataGeneration.CONST_ATTRCONV, self.xmlsec_path,
disable_ssl_certificate_validation=True)
md = MetaData(MetadataGeneration.CONST_ONTS.values(), MetadataGeneration.CONST_ATTRCONV, metadata=xml)
md.load()
entityId = md.entity.keys()[0]
mds.metadata[entityId] = md
args = {"metad": mds, "dkeys": {"rsa": [self.privateKey]}}
ci = utils.ConsumerInfo(['metadata'], **args)
metadataOK = True
except:
self.logger.info('Could not parse the metadata file in handleMetadataVerifyJSON.',
exc_info=True)
services = "["
first = True
if ci is not None:
for item in ci._info:
if item._ava is not None and entityId in item._ava:
for social in item._ava[entityId]:
if not first:
services += ","
else:
first = False
services += '"' + social + '"'
services += "]"
if metadataOK:
ok = True
except:
self.logger.fatal('Unknown error in handleMetadataVerifyJSON.',
exc_info=True)
resp = Response('{"ok":"' + str(ok) + '", "services":' + services + '}', headers=[('Content-Type', MetadataGeneration.CONST_TYPEJSON)])
return resp(environ, start_response)