Skip to content

Commit e23f11a

Browse files
committed
Add mdstore method to extract contact_person data
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 247e2f6 commit e23f11a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/saml2/mdstore.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,30 @@ def mdui_uiinfo_logo(self, entity_id, width=None, height=None):
13791379
)
13801380
return values
13811381

1382+
def contact_person_data(self, entity_id, contact_type=None):
1383+
try:
1384+
data = self[entity_id]
1385+
except KeyError:
1386+
data = {}
1387+
1388+
contacts = (
1389+
{
1390+
"contact_type": _contact_type,
1391+
"given_name": contact.get("given_name", {}).get("text", ""),
1392+
"email_address": [
1393+
address
1394+
for email in contact.get("email_address", {})
1395+
for address in [email.get("text")]
1396+
if address
1397+
],
1398+
}
1399+
for contact in data.get("contact_person", [])
1400+
for _contact_type in [contact.get("contact_type", "")]
1401+
if contact_type is None or contact_type == _contact_type
1402+
)
1403+
1404+
return contacts
1405+
13821406
def bindings(self, entity_id, typ, service):
13831407
for _md in self.metadata.values():
13841408
if entity_id in _md.items():

0 commit comments

Comments
 (0)