本文整理汇总了Python中saml2.md.entities_descriptor_from_string函数的典型用法代码示例。如果您正苦于以下问题:Python entities_descriptor_from_string函数的具体用法?Python entities_descriptor_from_string怎么用?Python entities_descriptor_from_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了entities_descriptor_from_string函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
def parse(self, xmlstr):
self.entities_descr = md.entities_descriptor_from_string(xmlstr)
if not self.entities_descr:
self.entity_descr = md.entity_descriptor_from_string(xmlstr)
if self.entity_descr:
self.do_entity_descriptor(self.entity_descr)
else:
try:
valid_instance(self.entities_descr)
except NotValid, exc:
logger.error(exc.args[0])
return
if self.check_validity:
try:
if not valid(self.entities_descr.valid_until):
raise ToOld(
"Metadata not valid anymore, it's after %s" % (
self.entities_descr.valid_until,))
except AttributeError:
pass
for entity_descr in self.entities_descr.entity_descriptor:
self.do_entity_descriptor(entity_descr)
示例2: entities_descriptor
def entities_descriptor(eds, valid_for, name, ident, sign, secc):
entities = md.EntitiesDescriptor(entity_descriptor=eds)
if valid_for:
entities.valid_until = in_a_while(hours=valid_for)
if name:
entities.name = name
if ident:
entities.id = ident
if sign:
if not ident:
ident = sid()
if not secc.key_file:
raise SAMLError("If you want to do signing you should define " +
"a key to sign with")
if not secc.my_cert:
raise SAMLError("If you want to do signing you should define " +
"where your public key are")
entities.signature = pre_signature_part(ident, secc.my_cert, 1)
entities.id = ident
xmldoc = secc.sign_statement("%s" % entities, class_name(entities))
entities = md.entities_descriptor_from_string(xmldoc)
else:
xmldoc = None
return entities, xmldoc
示例3: import_metadata
def import_metadata(self, xml_str, source):
""" Import information; organization distinguish name, location and
certificates from a metadata file.
:param xml_str: The metadata as a XML string.
:param source: A name by which this source should be known, has to be
unique within this session.
"""
# now = time.gmtime()
#print >> sys.stderr, "Loading %s" % (source,)
entities_descr = md.entities_descriptor_from_string(xml_str)
if not entities_descr:
entity_descr = md.entity_descriptor_from_string(xml_str)
if entity_descr:
self.do_entity_descriptor(entity_descr, source)
else:
try:
valid_instance(entities_descr)
except NotValid, exc:
print >> sys.stderr, exc.args[0]
return
try:
valid(entities_descr.valid_until)
except AttributeError:
pass
for entity_descr in entities_descr.entity_descriptor:
self.do_entity_descriptor(entity_descr, source,
entities_descr.valid_until)
示例4: parse
def parse(self, xmlstr):
self.entities_descr = md.entities_descriptor_from_string(xmlstr)
if not self.entities_descr:
self.entity_descr = md.entity_descriptor_from_string(xmlstr)
if self.entity_descr:
self.do_entity_descriptor(self.entity_descr)
else:
try:
valid_instance(self.entities_descr)
except NotValid, exc:
logger.error(exc.args[0])
return
try:
valid(self.entities_descr.valid_until)
except AttributeError:
pass
for entity_descr in self.entities_descr.entity_descriptor:
self.do_entity_descriptor(entity_descr)
示例5: open
#!/usr/bin/env python
from saml2 import md
import sys
from saml2.md import EntitiesDescriptor
__author__ = 'rolandh'
xml_str = open(sys.argv[1]).read()
entities_descr = md.entities_descriptor_from_string(xml_str)
keep = sys.argv[2:]
eds = []
for entity_descr in entities_descr.entity_descriptor:
if entity_descr.entity_id in keep:
eds.append(entity_descr)
print EntitiesDescriptor(name=entities_descr.name, entity_descriptor=eds,
valid_until = entities_descr.valid_until,
cache_duration=entities_descr.cache_duration)