|
49 | 49 |
|
50 | 50 | NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion' |
51 | 51 | # TEMPLATE = '{urn:oasis:names:tc:SAML:2.0:assertion}%s' |
52 | | -# XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' |
53 | | - |
54 | | -# spaceone's https://github.com/IdentityPython/pysaml2/pull/326 |
55 | 52 | SAMLP_NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:protocol' |
56 | 53 | XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' |
57 | 54 | XS_NAMESPACE = 'http://www.w3.org/2001/XMLSchema' |
58 | | -DS_NAMESPACE = 'http://www.w3.org/2000/09/xmldsig#' |
59 | 55 | MD_NAMESPACE = "urn:oasis:names:tc:SAML:2.0:metadata" |
60 | 56 | MDUI_NAMESPACE = "urn:oasis:names:tc:SAML:metadata:ui" |
61 | | -DEFAULT_NS_PREFIXES = {'saml': NAMESPACE, 'samlp': SAMLP_NAMESPACE, |
62 | | - 'ds': DS_NAMESPACE, 'xsi': XSI_NAMESPACE, |
63 | | - 'xs': XS_NAMESPACE, |
64 | | - 'mdui': MDUI_NAMESPACE, |
65 | | - 'md': MD_NAMESPACE, |
66 | | - # 'alg': TODO: algsupport.DIGEST_METHODS|SIGNING_METHODS shoulb be moved before mapping them here |
67 | | - # TODO: <ns1:EntityAttributes> |
68 | | - } |
69 | | - |
| 57 | +DS_NAMESPACE = 'http://www.w3.org/2000/09/xmldsig#' |
| 58 | +XENC_NAMESPACE = "http://www.w3.org/2001/04/xmlenc#" |
| 59 | +ALG_NAMESPACE = "urn:oasis:names:tc:SAML:metadata:algsupport" |
| 60 | +MDATTR_NAMESPACE = "urn:oasis:names:tc:SAML:metadata:attribute" |
| 61 | + |
| 62 | +OASIS_DEFAULT_NS_PREFIXES = {'saml': NAMESPACE, |
| 63 | + 'samlp': SAMLP_NAMESPACE, |
| 64 | + 'ds': DS_NAMESPACE, |
| 65 | + 'xsi': XSI_NAMESPACE, |
| 66 | + 'xs': XS_NAMESPACE, |
| 67 | + 'mdui': MDUI_NAMESPACE, |
| 68 | + 'md': MD_NAMESPACE, |
| 69 | + 'xenc': XENC_NAMESPACE, |
| 70 | + 'alg': ALG_NAMESPACE, |
| 71 | + 'mdattr': MDATTR_NAMESPACE} |
70 | 72 |
|
71 | 73 | NAMEID_FORMAT_EMAILADDRESS = ( |
72 | 74 | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress") |
@@ -570,7 +572,8 @@ def _to_element_tree(self): |
570 | 572 | self._add_members_to_element_tree(new_tree) |
571 | 573 | return new_tree |
572 | 574 |
|
573 | | - def register_prefix(self, nspair): |
| 575 | + @staticmethod |
| 576 | + def register_prefix(nspair): |
574 | 577 | """ |
575 | 578 | Register with ElementTree a set of namespaces |
576 | 579 |
|
@@ -698,14 +701,11 @@ def fixup(name): |
698 | 701 | del elem.attrib[key] |
699 | 702 |
|
700 | 703 | def to_string_force_namespace(self, nspair): |
701 | | - |
702 | 704 | elem = self._to_element_tree() |
703 | | - |
704 | 705 | self.set_prefixes(elem, nspair) |
705 | | - |
706 | 706 | return ElementTree.tostring(elem, encoding="UTF-8") |
707 | 707 |
|
708 | | - def to_string(self, nspair=DEFAULT_NS_PREFIXES): |
| 708 | + def to_string(self, nspair=None): |
709 | 709 | """Converts the Saml object to a string containing XML. |
710 | 710 |
|
711 | 711 | :param nspair: A dictionary of prefixes and uris to use when |
@@ -1056,3 +1056,6 @@ def is_required_attribute(cls, attr): |
1056 | 1056 | :return: True if required |
1057 | 1057 | """ |
1058 | 1058 | return cls.c_attributes[attr][REQUIRED] |
| 1059 | + |
| 1060 | +# this register preferred prefix namespaces |
| 1061 | +SamlBase.register_prefix(OASIS_DEFAULT_NS_PREFIXES) |
0 commit comments