def dumps(self, format="local"): """ Dumps the content in standard metadata format or the pysaml2 metadata format :param format: Which format to dump in :return: a string """ if format == "local": res = EntitiesDescriptor() for _md in self.metadata.values(): try: res.entity_descriptor.extend( _md.entities_descr.entity_descriptor) except AttributeError: res.entity_descriptor.append(_md.entity_descr) return "%s" % res elif format == "md": return json.dumps(self.items(), indent=2)
xmldsig.NAMESPACE: xmldsig, xmlenc.NAMESPACE: xmlenc, shibmd.NAMESPACE: shibmd } parser = argparse.ArgumentParser() parser.add_argument('-a', dest='attrsmap') parser.add_argument('-o', dest='output', default="local") parser.add_argument('-x', dest='xmlsec') parser.add_argument('-i', dest='ignore_valid', action='store_true') parser.add_argument(dest="conf") args = parser.parse_args() metad = None output = EntitiesDescriptor() # config file format # local <local file name> # external <url> <local file name for certificate use to verify signature> for line in open(args.conf).readlines(): line = line.strip() if line[0] == "#": continue spec = line.split(" ") if args.ignore_valid: kwargs = {"check_validity": False} else: kwargs = {}
#!/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)