summaryrefslogtreecommitdiff
path: root/tools/mdexport.py
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2012-12-15 10:45:22 +0100
committerRoland Hedberg <roland.hedberg@adm.umu.se>2012-12-15 10:45:22 +0100
commit5962a5a1c49317123c967d2ce48b7de3dc79eba5 (patch)
tree545589759f62e0dc5ca89cd2c007763b6d1f91ee /tools/mdexport.py
parentd6a470f83db7b07e5f165f97281c8839e44277bf (diff)
downloadpysaml2-5962a5a1c49317123c967d2ce48b7de3dc79eba5.tar.gz
Basic tools that allows the metadata handling to be separated out from the IdP/SP/AA entity. Necessary when the size of the metadata files gets really big.
Diffstat (limited to 'tools/mdexport.py')
-rwxr-xr-xtools/mdexport.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/mdexport.py b/tools/mdexport.py
new file mode 100755
index 00000000..2fecf935
--- /dev/null
+++ b/tools/mdexport.py
@@ -0,0 +1,68 @@
+#!/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
+from saml2.extension import mdattr
+from saml2.extension import ui
+import xmldsig
+import xmlenc
+
+__author__ = 'rolandh'
+
+"""
+A script that imports and verifies metadata and dumps it in a basic
+dictionary format.
+"""
+
+MDIMPORT = {
+ "swamid": {
+ "url": "https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
+ "cert":"kalmar2.pem"
+ },
+ "incommon": {
+ "url": "file://InCommon-metadata.xml"
+ },
+ "test": {
+ "url": "file://mdtest.xml"
+ }
+}
+
+ATTRCONV = ac_factory("attributemaps")
+
+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
+}
+
+
+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"])
+
+_dict = to_dict(metad.entity, ONTS.values())
+
+import json
+print json.dumps(_dict, indent=2)
+