diff options
author | Roland Hedberg <roland.hedberg@adm.umu.se> | 2013-05-24 18:02:30 +0200 |
---|---|---|
committer | Roland Hedberg <roland.hedberg@adm.umu.se> | 2013-05-24 18:02:30 +0200 |
commit | e401cf25e2ace829f3438d06efb3e6749e84014b (patch) | |
tree | 183531718d373c5c8b0f50ee3614ccece39abed5 /tools | |
parent | 77e5a407a52a380cff191ffcf5d74c8cf095b27d (diff) | |
download | pysaml2-e401cf25e2ace829f3438d06efb3e6749e84014b.tar.gz |
In some case you want the url to be based on server_name/server_port and not http_host, now you can get what you want.develop
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/mdexport_test.py | 68 | ||||
-rwxr-xr-x | tools/mdimport.py | 24 |
2 files changed, 87 insertions, 5 deletions
diff --git a/tools/mdexport_test.py b/tools/mdexport_test.py new file mode 100755 index 00000000..abd9aefe --- /dev/null +++ b/tools/mdexport_test.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +import sys + +from saml2 import saml +from saml2 import md +from saml2.extension import mdui +from saml2.extension import idpdisc +from saml2.extension import dri +from saml2.extension import mdattr +from saml2.extension import ui +from saml2.extension import shibmd +import xmldsig +import xmlenc + +from saml2.mdstore import MetaDataFile, MetaDataExtern + +__author__ = 'rolandh' + +""" +A script that imports and verifies metadata and then dumps it in a basic +dictionary format. +""" + + +ONTS = { + saml.NAMESPACE: saml, + mdui.NAMESPACE: mdui, + mdattr.NAMESPACE: mdattr, + dri.NAMESPACE: dri, + ui.NAMESPACE: ui, + idpdisc.NAMESPACE: idpdisc, + md.NAMESPACE: md, + xmldsig.NAMESPACE: xmldsig, + xmlenc.NAMESPACE: xmlenc, + shibmd.NAMESPACE: shibmd +} + +MDIMPORT = { + "swamid": { + "url": "https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2", + "cert": "kalmar2.pem", + "type": "external" + }, + "incommon": { + "file": "InCommon-metadata.xml", + "type": "local" + }, + "test": { + "file": "mdtest.xml", + "type": "local" + } +} + + +item = MDIMPORT[sys.argv[1]] + +metad = None + +if item["type"] == "local": + metad = MetaDataFile(sys.argv[1], ONTS.values(), item["file"]) +elif item["type"] == "external": + metad = MetaDataExtern(sys.argv[1], ONTS.values(), + item["url"], "/opt/local/bin/xmlsec1", item["cert"]) + +if metad: + metad.load() + print metad.dumps() + diff --git a/tools/mdimport.py b/tools/mdimport.py index 10cf994b..6f83d958 100755 --- a/tools/mdimport.py +++ b/tools/mdimport.py @@ -1,10 +1,11 @@ #!/usr/bin/env python import sys +import time +from saml2.attribute_converter import ac_factory +from saml2.mdstore import MetaDataMD, MetaDataFile __author__ = 'rolandh' -from saml2.mdie import from_dict - import xmldsig import xmlenc from saml2 import md @@ -27,7 +28,20 @@ ONTS = { xmldsig.NAMESPACE: xmldsig, } -_dict = eval(open(sys.argv[1]).read()) -res = from_dict(_dict, ONTS) +start = time.time() +for i in range(1, 10): + mdmd = MetaDataMD(ONTS, ac_factory("../tests/attributemaps"), "swamid2.md") + mdmd.load() + + _ = mdmd.keys() + +print time.time() - start + +start = time.time() +for i in range(1, 10): + mdf = MetaDataFile(ONTS.values(), ac_factory("../tests/attributemaps"), + "../tests/swamid-2.0.xml") + mdf.load() + _ = mdf.keys() -print res
\ No newline at end of file +print time.time() - start |