summaryrefslogtreecommitdiff
path: root/src/saml2/mdstore.py
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2019-11-21 01:39:00 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2019-11-21 01:39:00 +0200
commite23f11a8c3f0334c3b6820f826c02e0a0770243c (patch)
tree84d4b810359889f5ace263499a9e2a7b83716b0c /src/saml2/mdstore.py
parent247e2f642b37de90a61c4f5ca49d8403840b6ea2 (diff)
downloadpysaml2-e23f11a8c3f0334c3b6820f826c02e0a0770243c.tar.gz
Add mdstore method to extract contact_person data
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/mdstore.py')
-rw-r--r--src/saml2/mdstore.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/saml2/mdstore.py b/src/saml2/mdstore.py
index 8ced1463..3a49d4a4 100644
--- a/src/saml2/mdstore.py
+++ b/src/saml2/mdstore.py
@@ -1379,6 +1379,30 @@ class MetadataStore(MetaData):
)
return values
+ def contact_person_data(self, entity_id, contact_type=None):
+ try:
+ data = self[entity_id]
+ except KeyError:
+ data = {}
+
+ contacts = (
+ {
+ "contact_type": _contact_type,
+ "given_name": contact.get("given_name", {}).get("text", ""),
+ "email_address": [
+ address
+ for email in contact.get("email_address", {})
+ for address in [email.get("text")]
+ if address
+ ],
+ }
+ for contact in data.get("contact_person", [])
+ for _contact_type in [contact.get("contact_type", "")]
+ if contact_type is None or contact_type == _contact_type
+ )
+
+ return contacts
+
def bindings(self, entity_id, typ, service):
for _md in self.metadata.values():
if entity_id in _md.items():