Skip to content

Commit 4879dab

Browse files
author
Hans Hörberg
committed
Merge remote-tracking branch 'upstream/master'
2 parents 51c06ee + 48c2121 commit 4879dab

File tree

7 files changed

+109
-42
lines changed

7 files changed

+109
-42
lines changed

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
'pytz',
1818
'pyOpenSSL',
1919
'python-dateutil',
20-
'six',
21-
'future'
20+
'six'
2221
]
2322

2423
version = ''

src/saml2/algsupport.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
from subprocess import Popen, PIPE
2+
from saml2.sigver import get_xmlsec_binary
3+
from saml2.extension.algsupport import SigningMethod
4+
from saml2.extension.algsupport import DigestMethod
5+
6+
__author__ = 'roland'
7+
8+
DIGEST_METHODS = {
9+
"hmac-md5": 'http://www.w3.org/2001/04/xmldsig-more#md5', # test framework only!
10+
"hmac-sha1": 'http://www.w3.org/2000/09/xmldsig#sha1',
11+
"hmac-sha224": 'http://www.w3.org/2001/04/xmldsig-more#sha224',
12+
"hmac-sha256": 'http://www.w3.org/2001/04/xmlenc#sha256',
13+
"hmac-sha384": 'http://www.w3.org/2001/04/xmldsig-more#sha384',
14+
"hmac-sha512": 'http://www.w3.org/2001/04/xmlenc#sha512',
15+
"hmac-ripemd160": 'http://www.w3.org/2001/04/xmlenc#ripemd160'
16+
}
17+
18+
SIGNING_METHODS = {
19+
"rsa-md5": 'http://www.w3.org/2001/04/xmldsig-more#rsa-md5',
20+
"rsa-ripemd160": 'http://www.w3.org/2001/04/xmldsig-more#rsa-ripemd160',
21+
"rsa-sha1": 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
22+
"rsa-sha224": 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha224',
23+
"rsa-sha256": 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
24+
"rsa-sha384": 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384',
25+
"rsa-sha512": 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512',
26+
"dsa-sha1": 'http,//www.w3.org/2000/09/xmldsig#dsa-sha1',
27+
'dsa-sha256': 'http://www.w3.org/2009/xmldsig11#dsa-sha256',
28+
'ecdsa_sha1': 'http://www.w3.org/2001/04/xmldsig-more#ECDSA_sha1',
29+
'ecdsa_sha224': 'http://www.w3.org/2001/04/xmldsig-more#ECDSA_sha224',
30+
'ecdsa_sha256': 'http://www.w3.org/2001/04/xmldsig-more#ECDSA_sha256',
31+
'ecdsa_sha384': 'http://www.w3.org/2001/04/xmldsig-more#ECDSA_sha384',
32+
'ecdsa_sha512': 'http://www.w3.org/2001/04/xmldsig-more#ECDSA_sha512',
33+
}
34+
35+
36+
def get_algorithm_support(xmlsec):
37+
com_list = [xmlsec, '--list-transforms']
38+
pof = Popen(com_list, stderr=PIPE, stdout=PIPE)
39+
40+
p_out = pof.stdout.read().decode('utf-8')
41+
p_err = pof.stderr.read().decode('utf-8')
42+
43+
if not p_err:
44+
p = p_out.split('\n')
45+
algs = [x.strip('"') for x in p[1].split(',')]
46+
digest = []
47+
signing = []
48+
for alg in algs:
49+
if alg in DIGEST_METHODS:
50+
digest.append(alg)
51+
elif alg in SIGNING_METHODS:
52+
signing.append(alg)
53+
54+
return {"digest": digest, "signing": signing}
55+
56+
raise SystemError(p_err)
57+
58+
59+
def algorithm_support_in_metadata(xmlsec):
60+
if xmlsec is None:
61+
return []
62+
63+
support = get_algorithm_support(xmlsec)
64+
element_list = []
65+
for alg in support["digest"]:
66+
element_list.append(DigestMethod(algorithm=DIGEST_METHODS[alg]))
67+
for alg in support["signing"]:
68+
element_list.append(SigningMethod(algorithm=SIGNING_METHODS[alg]))
69+
return element_list
70+
71+
if __name__ == '__main__':
72+
xmlsec = get_xmlsec_binary()
73+
res = get_algorithm_support(xmlsec)
74+
print(res)
75+
for a in algorithm_support_in_metadata(xmlsec):
76+
print(a)

tests/server2_conf.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
from pathutils import full_path
22

33
CONFIG = {
4-
"entityid" : "urn:mace:example.com:saml:roland:sp",
5-
"name" : "urn:mace:example.com:saml:roland:sp",
4+
"entityid": "urn:mace:example.com:saml:roland:sp",
5+
"name": "urn:mace:example.com:saml:roland:sp",
66
"description": "My own SP",
77
"service": {
88
"sp": {
9-
"endpoints":{
10-
"assertion_consumer_service": ["http://lingon.catalogix.se:8087/"],
9+
"endpoints": {
10+
"assertion_consumer_service": [
11+
"http://lingon.catalogix.se:8087/"],
1112
},
1213
"required_attributes": ["surName", "givenName", "mail"],
1314
"optional_attributes": ["title"],
14-
"idp":["urn:mace:example.com:saml:roland:idp"],
15+
"idp": ["urn:mace:example.com:saml:roland:idp"],
1516
"subject_data": "subject_data.db",
1617
}
1718
},
18-
"debug" : 1,
19-
"key_file" : full_path("test.key"),
20-
"cert_file" : full_path("test.pem"),
21-
"xmlsec_binary" : None,
19+
"debug": 1,
20+
"key_file": full_path("test.key"),
21+
"cert_file": full_path("test.pem"),
22+
"xmlsec_binary": None,
2223
"metadata": {
2324
"local": [full_path("idp_soap.xml"), full_path("vo_metadata.xml")],
2425
},
25-
"virtual_organization" : {
26-
"urn:mace:example.com:it:tek":{
27-
"nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
26+
"virtual_organization": {
27+
"urn:mace:example.com:it:tek": {
28+
"nameid_format": "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
2829
"common_identifier": "umuselin",
2930
}
3031
},
3132
"accepted_time_diff": 60,
32-
"attribute_map_dir" : full_path("attributemaps"),
33+
"attribute_map_dir": full_path("attributemaps"),
3334
"organization": {
3435
"name": ("AB Exempel", "se"),
3536
"display_name": ("AB Exempel", "se"),
3637
"url": "http://www.example.org",
3738
},
3839
"contact_person": [{
39-
"given_name": "Roland",
40-
"sur_name": "Hedberg",
41-
"telephone_number": "+46 70 100 0000",
42-
"email_address": ["[email protected]", "[email protected]"],
43-
"contact_type": "technical"
44-
},
40+
"given_name": "Roland",
41+
"sur_name": "Hedberg",
42+
"telephone_number": "+46 70 100 0000",
43+
"email_address": ["[email protected]", "[email protected]"],
44+
"contact_type": "technical"
45+
},
4546
]
4647
}

tests/sp_mdext_conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pathutils import full_path
1+
from pathutils import full_path, xmlsec_path
22

33
CONFIG = {
44
"entityid": "urn:mace:example.com:saml:roland:sp",
@@ -38,7 +38,7 @@
3838
"debug": 1,
3939
"key_file": full_path("test.key"),
4040
"cert_file": full_path("test.pem"),
41-
"xmlsec_binary": None,
41+
"xmlsec_binary": xmlsec_path,
4242
"metadata": {
4343
"local": [full_path("idp_2.xml")],
4444
},

tests/test_30_mdstore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# -*- coding: utf-8 -*-
33
import datetime
44
import re
5-
#from six.moves.urllib.parse import quote_plus
6-
from future.backports.urllib.parse import quote_plus
5+
from six.moves.urllib.parse import quote_plus
6+
#from future.backports.urllib.parse import quote_plus
77
from saml2.config import Config
88
from saml2.mdstore import MetadataStore
99
from saml2.mdstore import MetaDataMDX

tests/test_83_md_extensions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212

1313
assert ed.spsso_descriptor.extensions
1414
assert len(ed.spsso_descriptor.extensions.extension_elements) == 3
15+
16+
assert ed.extensions
17+
assert len(ed.extensions.extension_elements) > 1

tools/mdexport.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
#!/usr/bin/env python
2-
from saml2.sigver import _get_xmlsec_cryptobackend, SecurityContext
1+
#!/usr/bin/env python
2+
from saml2.sigver import _get_xmlsec_cryptobackend
3+
from saml2.sigver import SecurityContext
34
from saml2.httpbase import HTTPBase
45

56
from saml2 import saml
67
from saml2 import md
78
from saml2.attribute_converter import ac_factory
8-
from saml2.extension import dri
9-
from saml2.extension import idpdisc
10-
from saml2.extension import mdattr
11-
from saml2.extension import mdrpi
12-
from saml2.extension import mdui
13-
from saml2.extension import shibmd
14-
from saml2.extension import ui
159
from saml2 import xmldsig
1610
from saml2 import xmlenc
1711

1812
import argparse
1913

20-
from saml2.mdstore import MetaDataFile, MetaDataExtern
14+
from saml2.mdstore import MetaDataFile, MetaDataExtern, load_extensions
2115

2216
__author__ = 'rolandh'
2317

@@ -29,18 +23,12 @@
2923

3024
ONTS = {
3125
saml.NAMESPACE: saml,
32-
mdui.NAMESPACE: mdui,
33-
mdattr.NAMESPACE: mdattr,
34-
mdrpi.NAMESPACE: mdrpi,
35-
dri.NAMESPACE: dri,
36-
ui.NAMESPACE: ui,
37-
idpdisc.NAMESPACE: idpdisc,
3826
md.NAMESPACE: md,
3927
xmldsig.NAMESPACE: xmldsig,
4028
xmlenc.NAMESPACE: xmlenc,
41-
shibmd.NAMESPACE: shibmd
4229
}
4330

31+
ONTS.update(load_extensions())
4432

4533
parser = argparse.ArgumentParser()
4634
parser.add_argument('-t', dest='type')

0 commit comments

Comments
 (0)