|
56 | 56 | from saml2.extension.mdui import InformationURL
|
57 | 57 | from saml2.extension.mdui import PrivacyStatementURL
|
58 | 58 | from saml2.extension.mdui import Logo
|
| 59 | +from saml2.extension.mdrpi import NAMESPACE as NS_MDRPI |
| 60 | +from saml2.extension.mdrpi import RegistrationInfo |
| 61 | +from saml2.extension.mdrpi import RegistrationPolicy |
59 | 62 |
|
60 | 63 |
|
61 | 64 | logger = logging.getLogger(__name__)
|
|
79 | 82 | "service_artifact_resolution": "{ns}&{tag}".format(ns=NS_MD, tag=ArtifactResolutionService.c_tag),
|
80 | 83 | "service_single_sign_on": "{ns}&{tag}".format(ns=NS_MD, tag=SingleSignOnService.c_tag),
|
81 | 84 | "service_nameid_mapping": "{ns}&{tag}".format(ns=NS_MD, tag=NameIDMappingService.c_tag),
|
| 85 | + "mdrpi_registration_info": "{ns}&{tag}".format(ns=NS_MDRPI, tag=RegistrationInfo.c_tag), |
| 86 | + "mdrpi_registration_policy": "{ns}&{tag}".format(ns=NS_MDRPI, tag=RegistrationPolicy.c_tag), |
82 | 87 | }
|
83 | 88 |
|
84 | 89 | ENTITY_CATEGORY = "http://macedir.org/entity-category"
|
@@ -1406,6 +1411,45 @@ def supported_algorithms(self, entity_id):
|
1406 | 1411 | res['signing_methods'].append(elem['algorithm'])
|
1407 | 1412 | return res
|
1408 | 1413 |
|
| 1414 | + def registration_info(self, entity_id): |
| 1415 | + """ |
| 1416 | + Get all registration info for an entry in the metadata. |
| 1417 | +
|
| 1418 | + Example return data: |
| 1419 | +
|
| 1420 | + res = { |
| 1421 | + 'registration_authority': 'http://www.example.com', |
| 1422 | + 'registration_instant': '2013-06-15T18:15:03Z', |
| 1423 | + 'registration_policy': { |
| 1424 | + 'en': 'http://www.example.com/policy.html', |
| 1425 | + 'sv': 'http://www.example.com/sv/policy.html', |
| 1426 | + } |
| 1427 | + } |
| 1428 | +
|
| 1429 | + :param entity_id: Entity id |
| 1430 | + :return: dict with keys and value-lists from metadata |
| 1431 | +
|
| 1432 | + :type entity_id: string |
| 1433 | + :rtype: dict |
| 1434 | + """ |
| 1435 | + res = { |
| 1436 | + 'registration_authority': None, |
| 1437 | + 'registration_instant': None, |
| 1438 | + 'registration_policy': {} |
| 1439 | + } |
| 1440 | + try: |
| 1441 | + ext = self.__getitem__(entity_id)["extensions"] |
| 1442 | + except KeyError: |
| 1443 | + return res |
| 1444 | + for elem in ext["extension_elements"]: |
| 1445 | + if elem["__class__"] == classnames["mdrpi_registration_info"]: |
| 1446 | + res["registration_authority"] = elem["registration_authority"] |
| 1447 | + res["registration_instant"] = elem.get("registration_instant") |
| 1448 | + for policy in elem.get('registration_policy'): |
| 1449 | + if policy["__class__"] == classnames["mdrpi_registration_policy"]: |
| 1450 | + res['registration_policy'][policy["lang"]] = policy["text"] |
| 1451 | + return res |
| 1452 | + |
1409 | 1453 | def _lookup_elements_by_cls(self, root, cls):
|
1410 | 1454 | elements = (
|
1411 | 1455 | element
|
|
0 commit comments