Skip to content

Commit

Permalink
Add registration_info_typ to get the registration information from En…
Browse files Browse the repository at this point in the history
…tityDescriptor services

Signed-off-by: Ivan Kanakarakis <[email protected]>
  • Loading branch information
c00kiemon5ter committed Jun 28, 2022
1 parent 46d10b2 commit 716019c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/saml2/mdstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,7 @@ def imp(self, spec):

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:
Expand Down Expand Up @@ -1522,6 +1521,29 @@ def registration_info(self, entity_id):
}
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
Expand Down

0 comments on commit 716019c

Please sign in to comment.