Skip to content

Commit 716019c

Browse files
committed
Add registration_info_typ to get the registration information from EntityDescriptor services
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 46d10b2 commit 716019c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/saml2/mdstore.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,7 @@ def imp(self, spec):
11901190

11911191
def service(self, entity_id, typ, service, binding=None):
11921192
known_entity = False
1193-
logger.debug("service(%s, %s, %s, %s)", entity_id, typ, service,
1194-
binding)
1193+
logger.debug("service(%s, %s, %s, %s)", entity_id, typ, service, binding)
11951194
for key, _md in self.metadata.items():
11961195
srvs = _md.service(entity_id, typ, service, binding)
11971196
if srvs:
@@ -1522,6 +1521,29 @@ def registration_info(self, entity_id):
15221521
}
15231522
return res
15241523

1524+
def registration_info_typ(self, entity_id, typ):
1525+
try:
1526+
md = self.__getitem__(entity_id)
1527+
except KeyError:
1528+
md = {}
1529+
1530+
services_of_type = md.get(typ) or []
1531+
typ_reg_info = (
1532+
{
1533+
"registration_authority": elem.get("registration_authority"),
1534+
"registration_instant": elem.get("registration_instant"),
1535+
"registration_policy": {
1536+
policy["lang"]: policy["text"]
1537+
for policy in elem.get("registration_policy", [])
1538+
if policy.get("__class__") == classnames["mdrpi_registration_policy"]
1539+
},
1540+
}
1541+
for srv in services_of_type
1542+
for elem in srv.get("extensions", {}).get("extension_elements", [])
1543+
if elem.get("__class__") == classnames["mdrpi_registration_info"]
1544+
)
1545+
return typ_reg_info
1546+
15251547
def _lookup_elements_by_cls(self, root, cls):
15261548
elements = (
15271549
element

0 commit comments

Comments
 (0)