summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2012-12-19 13:08:02 +0100
committerRoland Hedberg <roland.hedberg@adm.umu.se>2012-12-19 13:08:02 +0100
commit50459d616f4f5ec52f94d7a0181e4445ca867d1e (patch)
treeaf605edbfb88dfcbd017782f7032968bae6fa95f /tools
parentf265c3b421b87c951b27306284b1b1725c39c7ab (diff)
downloadpysaml2-50459d616f4f5ec52f94d7a0181e4445ca867d1e.tar.gz
Complete rewrite of the metadata handling package.
Switched from using httplib2 to requests.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mdexport.py44
1 files changed, 20 insertions, 24 deletions
diff --git a/tools/mdexport.py b/tools/mdexport.py
index 2fecf935..1231d381 100755
--- a/tools/mdexport.py
+++ b/tools/mdexport.py
@@ -1,12 +1,8 @@
#!/usr/bin/env python
import sys
-from saml2 import metadata
+
from saml2 import saml
from saml2 import md
-from saml2.attribute_converter import ac_factory
-
-from saml2.mdie import to_dict
-
from saml2.extension import mdui
from saml2.extension import idpdisc
from saml2.extension import dri
@@ -15,28 +11,31 @@ from saml2.extension import ui
import xmldsig
import xmlenc
+from saml2.mdstore import MetaDataFile, MetaDataExtern
+
__author__ = 'rolandh'
"""
-A script that imports and verifies metadata and dumps it in a basic
+A script that imports and verifies metadata and then dumps it in a basic
dictionary format.
"""
MDIMPORT = {
"swamid": {
"url": "https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
- "cert":"kalmar2.pem"
+ "cert":"kalmar2.pem",
+ "type": "external"
},
"incommon": {
- "url": "file://InCommon-metadata.xml"
+ "file": "InCommon-metadata.xml",
+ "type": "local"
},
"test": {
- "url": "file://mdtest.xml"
+ "file": "mdtest.xml",
+ "type": "local"
}
}
-ATTRCONV = ac_factory("attributemaps")
-
ONTS = {
saml.NAMESPACE: saml,
mdui.NAMESPACE: mdui,
@@ -49,20 +48,17 @@ ONTS = {
xmlenc.NAMESPACE: xmlenc
}
+item = MDIMPORT[sys.argv[1]]
-metad = metadata.MetaData(xmlsec_binary="/opt/local/bin/xmlsec1",
- attrconv=ATTRCONV)
-
-for src in sys.argv[1:]:
- spec = MDIMPORT[src]
- url = spec["url"]
- if url.startswith("file://"):
- metad.import_metadata(open(url[7:]).read(), src)
- else:
- metad.import_external_metadata(url, spec["cert"])
+metad = None
-_dict = to_dict(metad.entity, ONTS.values())
+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"])
-import json
-print json.dumps(_dict, indent=2)
+if metad:
+ metad.load()
+ print metad.dumps()