-
Notifications
You must be signed in to change notification settings - Fork 17
/
README.pySAML2-dev.txt
77 lines (56 loc) · 2.39 KB
/
README.pySAML2-dev.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
a = """<?xml version="1.0"?>
<spid:Extensions xmlns:spid="https://www.spid.gov.it/saml-extensions">
<spid:ContactPerson contactType="other">
<spid:Extensions xmlns:spid="https://www.spid.gov.it/saml-extensions">
<spid:VATNumber>IT12345678901</spid:VATNumber>
<spid:FiscalCode>XYZABCAAMGGJ000W</spid:FiscalCode>
<spid:Private/>
</spid:Extensions>
<spid:EmailAddress>spid@organizzazione.com</spid:EmailAddress>
<spid:TelephoneNumber>+390123456789</spid:TelephoneNumber>
</spid:ContactPerson>
"""
from saml2.md import *
SPID_PREFIXES = dict(md = 'urn:oasis:names:tc:SAML:2.0:metadata',
spid = "https://www.spid.gov.it/saml-extensions")
SamlBase.register_prefix(SPID_PREFIXES)
d = """<?xml version='1.0' encoding='UTF-8'?>
<md:EntityDescriptor entityID="https://entityID.unico/dell/SP"
ID="_uniqueID"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:spid="https://spid.gov.it/saml-extensions">
<md:Extensions xmlns:spid="https://www.spid.gov.it/saml-extensions">
<spid:VATNumber>IT12345678901</spid:VATNumber>
<spid:FiscalCode>XYZABCAAMGGJ000W</spid:FiscalCode>
<spid:Private/>
</md:Extensions>
</md:EntityDescriptor>"""
spid_ext = saml2.extension_element_from_string(d)
print(spid_ext.to_string().decode())
# AVVISO 29 v3
e = """<?xml version='1.0' encoding='UTF-8'?>
<md:ContactPerson contactType="other">
<md:EmailAddress>spid@organizzazione.com</md:EmailAddress>
<md:TelephoneNumber>+390123456789</md:TelephoneNumber>
</md:ContactPerson>"""
spid_ext = saml2.extension_element_from_string(e)
spid_ext.to_string()
####################
SPID_PREFIXES = dict(spid = "https://www.spid.gov.it/saml-extensions")
SamlBase.register_prefix(SPID_PREFIXES)
spid_extensions = Extensions()
spid_extensions.c_namespace = "https://spid.gov.it/saml-extensions"
spid_extensions = saml2.ExtensionElement('Extensions',
namespace="https://www.spid.gov.it/saml-extensions")
spid_extensions.to_string()
SPID_CONTACT_PERSON_DICT = {
'VATNumber': 'IT12345678901',
'FiscalCode': 'XYZABCAAMGGJ000W',
'Private': ''
}
for k,v in SPID_CONTACT_PERSON_DICT.items():
ext = saml2.ExtensionElement(k,
namespace="https://www.spid.gov.it/saml-extensions",
text=v)
spid_extensions.children.append(ext)
spid_extensions.to_string()