|
37 | 37 | from saml2.sigver import security_context
|
38 | 38 | from saml2.extension.mdattr import NAMESPACE as NS_MDATTR
|
39 | 39 | from saml2.extension.mdattr import EntityAttributes
|
| 40 | +from saml2.extension.algsupport import NAMESPACE as NS_ALGSUPPORT |
| 41 | +from saml2.extension.algsupport import SigningMethod, DigestMethod |
40 | 42 | from saml2.extension.mdui import NAMESPACE as NS_MDUI
|
41 | 43 | from saml2.extension.mdui import UIInfo
|
42 | 44 | from saml2.extension.mdui import DisplayName
|
|
52 | 54 | "mdattr_entityattributes": "{ns}&{tag}".format(
|
53 | 55 | ns=NS_MDATTR, tag=EntityAttributes.c_tag
|
54 | 56 | ),
|
| 57 | + "algsupport_signing_method": "{ns}&{tag}".format(ns=NS_ALGSUPPORT, tag=SigningMethod.c_tag), |
| 58 | + "algsupport_digest_method": "{ns}&{tag}".format(ns=NS_ALGSUPPORT, tag=DigestMethod.c_tag), |
55 | 59 | "mdui_uiinfo": "{ns}&{tag}".format(ns=NS_MDUI, tag=UIInfo.c_tag),
|
56 | 60 | "mdui_uiinfo_display_name": "{ns}&{tag}".format(ns=NS_MDUI, tag=DisplayName.c_tag),
|
57 | 61 | "mdui_uiinfo_description": "{ns}&{tag}".format(ns=NS_MDUI, tag=Description.c_tag),
|
@@ -1282,6 +1286,36 @@ def entity_attributes(self, entity_id):
|
1282 | 1286 | "attribute_value"]]
|
1283 | 1287 | return res
|
1284 | 1288 |
|
| 1289 | + def supported_algorithms(self, entity_id): |
| 1290 | + """ |
| 1291 | + Get all supported algorithms for an entry in the metadata. |
| 1292 | +
|
| 1293 | + Example return data: |
| 1294 | +
|
| 1295 | + {'digest_methods': ['http://www.w3.org/2001/04/xmldsig-more#sha224', 'http://www.w3.org/2001/04/xmlenc#sha256'], |
| 1296 | + 'signing_methods': ['http://www.w3.org/2001/04/xmldsig-more#rsa-sha256']} |
| 1297 | +
|
| 1298 | + :param entity_id: Entity id |
| 1299 | + :return: dict with keys and value-lists from metadata |
| 1300 | +
|
| 1301 | + :type entity_id: string |
| 1302 | + :rtype: dict |
| 1303 | + """ |
| 1304 | + res = { |
| 1305 | + 'digest_methods': [], |
| 1306 | + 'signing_methods': [] |
| 1307 | + } |
| 1308 | + try: |
| 1309 | + ext = self.__getitem__(entity_id)["extensions"] |
| 1310 | + except KeyError: |
| 1311 | + return res |
| 1312 | + for elem in ext["extension_elements"]: |
| 1313 | + if elem["__class__"] == classnames["algsupport_digest_method"]: |
| 1314 | + res['digest_methods'].append(elem['algorithm']) |
| 1315 | + elif elem["__class__"] == classnames["algsupport_signing_method"]: |
| 1316 | + res['signing_methods'].append(elem['algorithm']) |
| 1317 | + return res |
| 1318 | + |
1285 | 1319 | def _lookup_elements_by_cls(self, root, cls):
|
1286 | 1320 | elements = (
|
1287 | 1321 | element
|
|
0 commit comments