def load(self, typ, *args, **kwargs): if typ == "local": key = args[0] md = MetaDataFile(self.onts, self.attrc, args[0]) elif typ == "inline": self.ii += 1 key = self.ii md = MetaData(self.onts, self.attrc, args[0], **kwargs) elif typ == "remote": key = kwargs["url"] md = MetaDataExtern(self.onts, self.attrc, kwargs["url"], self.security, kwargs["cert"], self.http, node_name=kwargs.get('node_name')) elif typ == "mdfile": key = args[0] md = MetaDataMD(self.onts, self.attrc, args[0]) elif typ == "loader": key = args[0] md = MetaDataLoader(self.onts, self.attrc, args[0]) else: raise SAMLError("Unknown metadata type '%s'" % typ) md.load() self.metadata[key] = md
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)
def verify_metadata(self): self.json_config = self.json_config_file() self.sp_configure() metadata = MetadataStore(SCHEMA, self.sp_config.attribute_converters, self.sp_config.xmlsec_binary) info = self.json_config["metadata"].encode("utf-8") md = MetaData(SCHEMA, self.sp_config.attribute_converters, info) md.load() metadata[0] = md env = {"metadata": metadata} chk = CheckSaml2IntMetaData() output = [] res = chk(env, output) print(res, file=sys.stdout)
def verify_metadata(self): self.json_config = self.json_config_file() self.sp_configure() metadata = MetadataStore(SCHEMA, self.sp_config.attribute_converters, self.sp_config.xmlsec_binary) info = self.json_config["metadata"].encode("utf-8") md = MetaData(SCHEMA, self.sp_config.attribute_converters, info) md.load() metadata[0] = md env = {"metadata": metadata} chk = CheckSaml2IntMetaData() output = [] res = chk(env, output) print >> sys.stdout, res
def load(self, type, *args, **kwargs): if type == "local": key = args[0] md = MetaDataFile(self.onts, self.attrc, args[0]) elif type == "inline": self.ii += 1 key = self.ii md = MetaData(self.onts, self.attrc) elif type == "remote": key = kwargs["url"] md = MetaDataExtern(self.onts, self.attrc, kwargs["url"], self.xmlsec_binary, kwargs["cert"], self.http) elif type == "mdfile": key = args[0] md = MetaDataMD(self.onts, self.attrc, args[0]) else: raise Exception("Unknown metadata type '%s'" % type) md.load() self.metadata[key] = md
def load(self, typ, *args, **kwargs): if typ == "local": key = args[0] md = MetaDataFile(self.onts, self.attrc, args[0]) elif typ == "inline": self.ii += 1 key = self.ii md = MetaData(self.onts, self.attrc) elif typ == "remote": key = kwargs["url"] md = MetaDataExtern(self.onts, self.attrc, kwargs["url"], self.security, kwargs["cert"], self.http) elif typ == "mdfile": key = args[0] md = MetaDataMD(self.onts, self.attrc, args[0]) else: raise Exception("Unknown metadata type '%s'" % typ) md.load() self.metadata[key] = md
def load(self, typ, *args, **kwargs): if typ == "local": key = args[0] md = MetaDataFile(self.onts, self.attrc, args[0]) elif typ == "inline": self.ii += 1 key = self.ii md = MetaData(self.onts, self.attrc, args[0]) elif typ == "remote": key = kwargs["url"] md = MetaDataExtern(self.onts, self.attrc, kwargs["url"], self.security, kwargs["cert"], self.http) elif typ == "mdfile": key = args[0] md = MetaDataMD(self.onts, self.attrc, args[0]) else: raise SAMLError("Unknown metadata type '%s'" % typ) md.load() self.metadata[key] = md
def setup(self): self.json_config = self.json_config_file() _jc = self.json_config try: self.interactions = _jc["interaction"] except KeyError: self.interactions = [] self.sp_configure() metadata = MetadataStore(SCHEMA, self.sp_config.attribute_converters, self.sp_config) info = _jc["metadata"].encode("utf-8") md = MetaData(SCHEMA, self.sp_config.attribute_converters, info) md.load() metadata[0] = md self.sp_config.metadata = metadata if self.args.testpackage: self.tests = import_module("idp_test.package.%s" % self.args.testpackage) try: self.entity_id = _jc["entity_id"] # Verify its the correct metadata assert self.entity_id in md.entity.keys( ), "metadata does not contain entityId %s" % self.entity_id except KeyError: if len(md.entity.keys()) == 1: self.entity_id = md.entity.keys()[0] else: raise Exception("Don't know which entity to talk to") if "constraints" in _jc: self.constraints = _jc["constraints"] if "name_format" not in self.constraints: self.constraints["name_format"] = NAME_FORMAT_UNSPECIFIED
def setup(self): self.json_config = self.json_config_file() _jc = self.json_config try: self.interactions = _jc["interaction"] except KeyError: self.interactions = [] self.sp_configure() metadata = MetadataStore(SCHEMA, self.sp_config.attribute_converters, self.sp_config) info = _jc["metadata"].encode("utf-8") md = MetaData(SCHEMA, self.sp_config.attribute_converters, info) md.load() metadata[0] = md self.sp_config.metadata = metadata if self.args.testpackage: self.tests = import_module("idp_test.package.%s" % self.args.testpackage) try: self.entity_id = _jc["entity_id"] # Verify its the correct metadata assert self.entity_id in md.entity.keys(), "metadata does not contain entityId %s" % self.entity_id except KeyError: if len(md.entity.keys()) == 1: self.entity_id = md.entity.keys()[0] else: raise Exception("Don't know which entity to talk to") if "constraints" in _jc: self.constraints = _jc["constraints"] if "name_format" not in self.constraints: self.constraints["name_format"] = NAME_FORMAT_UNSPECIFIED