diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2022-06-28 15:11:53 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2022-06-28 15:11:53 +0300 |
commit | 716019cdfee87b9aa6ccd31b469450ced755edd7 (patch) | |
tree | 31d6c390592eadb641615da0a59096af7bc3b413 | |
parent | 46d10b24e8816245e4105457faf4418a3b6b0e97 (diff) | |
download | pysaml2-716019cdfee87b9aa6ccd31b469450ced755edd7.tar.gz |
Add registration_info_typ to get the registration information from EntityDescriptor services
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r-- | src/saml2/mdstore.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/saml2/mdstore.py b/src/saml2/mdstore.py index ce4c8789..8fadadbd 100644 --- a/src/saml2/mdstore.py +++ b/src/saml2/mdstore.py @@ -1190,8 +1190,7 @@ class MetadataStore(MetaData): def service(self, entity_id, typ, service, binding=None): known_entity = False - logger.debug("service(%s, %s, %s, %s)", entity_id, typ, service, - binding) + logger.debug("service(%s, %s, %s, %s)", entity_id, typ, service, binding) for key, _md in self.metadata.items(): srvs = _md.service(entity_id, typ, service, binding) if srvs: @@ -1522,6 +1521,29 @@ class MetadataStore(MetaData): } return res + def registration_info_typ(self, entity_id, typ): + try: + md = self.__getitem__(entity_id) + except KeyError: + md = {} + + services_of_type = md.get(typ) or [] + typ_reg_info = ( + { + "registration_authority": elem.get("registration_authority"), + "registration_instant": elem.get("registration_instant"), + "registration_policy": { + policy["lang"]: policy["text"] + for policy in elem.get("registration_policy", []) + if policy.get("__class__") == classnames["mdrpi_registration_policy"] + }, + } + for srv in services_of_type + for elem in srv.get("extensions", {}).get("extension_elements", []) + if elem.get("__class__") == classnames["mdrpi_registration_info"] + ) + return typ_reg_info + def _lookup_elements_by_cls(self, root, cls): elements = ( element |