summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2015-12-01 12:53:35 +0100
committerRoland Hedberg <roland.hedberg@adm.umu.se>2015-12-01 12:53:35 +0100
commit883b89efb07acf6e28eb177f9f582aad1e33ba58 (patch)
tree733e979d4790241f1874b15f98f2bae33429a90e /tools
parentcff1391d73a4e81bf53ff11017b40bd016d82010 (diff)
downloadpysaml2-883b89efb07acf6e28eb177f9f582aad1e33ba58.tar.gz
Made MetaData instances pickleable.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mdexport.py15
-rwxr-xr-xtools/mdexport_test.py19
-rwxr-xr-xtools/mdimport.py27
-rwxr-xr-xtools/merge_metadata.py37
-rwxr-xr-xtools/verify_metadata.py25
5 files changed, 16 insertions, 107 deletions
diff --git a/tools/mdexport.py b/tools/mdexport.py
index d9ab521b..36becd2e 100755
--- a/tools/mdexport.py
+++ b/tools/mdexport.py
@@ -20,16 +20,6 @@ A script that imports and verifies metadata and then dumps it in a basic
dictionary format.
"""
-
-ONTS = {
- saml.NAMESPACE: saml,
- md.NAMESPACE: md,
- xmldsig.NAMESPACE: xmldsig,
- xmlenc.NAMESPACE: xmlenc,
-}
-
-ONTS.update(load_extensions())
-
parser = argparse.ArgumentParser()
parser.add_argument('-t', dest='type')
parser.add_argument('-u', dest='url')
@@ -44,14 +34,13 @@ args = parser.parse_args()
metad = None
if args.type == "local":
- metad = MetaDataFile(ONTS.values(), args.item, args.item)
+ metad = MetaDataFile(args.item, args.item)
elif args.type == "external":
ATTRCONV = ac_factory(args.attrsmap)
httpc = HTTPBase()
crypto = _get_xmlsec_cryptobackend(args.xmlsec)
sc = SecurityContext(crypto)
- metad = MetaDataExtern(ONTS.values(), ATTRCONV, args.url,
- sc, cert=args.cert, http=httpc)
+ metad = MetaDataExtern(ATTRCONV, args.url, sc, cert=args.cert, http=httpc)
if metad is not None:
metad.load()
diff --git a/tools/mdexport_test.py b/tools/mdexport_test.py
index 19ef443c..b5f4d88a 100755
--- a/tools/mdexport_test.py
+++ b/tools/mdexport_test.py
@@ -22,19 +22,6 @@ 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",
@@ -58,10 +45,10 @@ def main():
metad = None
if item["type"] == "local":
- metad = MetaDataFile(sys.argv[1], ONTS.values(), item["file"])
+ metad = MetaDataFile(sys.argv[1], item["file"])
elif item["type"] == "external":
- metad = MetaDataExtern(sys.argv[1], ONTS.values(),
- item["url"], "/opt/local/bin/xmlsec1", item["cert"])
+ metad = MetaDataExtern(sys.argv[1], item["url"],
+ "/opt/local/bin/xmlsec1", item["cert"])
if metad:
metad.load()
diff --git a/tools/mdimport.py b/tools/mdimport.py
index f9d62e35..4434b4ab 100755
--- a/tools/mdimport.py
+++ b/tools/mdimport.py
@@ -1,36 +1,13 @@
#!/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 import xmldsig
-from saml2 import xmlenc
-from saml2 import md
-from saml2 import saml
-from saml2.extension import dri
-from saml2.extension import idpdisc
-from saml2.extension import mdattr
-from saml2.extension import mdui
-from saml2.extension import ui
-
-ONTS = {
- dri.NAMESPACE: dri,
- idpdisc.NAMESPACE: idpdisc,
- md.NAMESPACE: md,
- mdattr.NAMESPACE: mdattr,
- mdui.NAMESPACE: mdui,
- saml.NAMESPACE: saml,
- ui.NAMESPACE: ui,
- xmlenc.NAMESPACE: xmlenc,
- xmldsig.NAMESPACE: xmldsig,
-}
-
start = time.time()
for i in range(1, 10):
- mdmd = MetaDataMD(ONTS, ac_factory("../tests/attributemaps"), "swamid2.md")
+ mdmd = MetaDataMD(ac_factory("../tests/attributemaps"), "swamid2.md")
mdmd.load()
_ = mdmd.keys()
@@ -39,7 +16,7 @@ print(time.time() - start)
start = time.time()
for i in range(1, 10):
- mdf = MetaDataFile(ONTS.values(), ac_factory("../tests/attributemaps"),
+ mdf = MetaDataFile(ac_factory("../tests/attributemaps"),
"../tests/swamid-2.0.xml")
mdf.load()
_ = mdf.keys()
diff --git a/tools/merge_metadata.py b/tools/merge_metadata.py
index 46d07c90..fc8430bf 100755
--- a/tools/merge_metadata.py
+++ b/tools/merge_metadata.py
@@ -1,20 +1,7 @@
#!/usr/bin/env python
from saml2.sigver import _get_xmlsec_cryptobackend, SecurityContext
from saml2.httpbase import HTTPBase
-
-from saml2 import saml
-from saml2 import md
from saml2.attribute_converter import ac_factory
-from saml2.extension import dri
-from saml2.extension import idpdisc
-from saml2.extension import mdattr
-from saml2.extension import mdrpi
-from saml2.extension import mdui
-from saml2.extension import shibmd
-from saml2.extension import ui
-from saml2 import xmldsig
-from saml2 import xmlenc
-
import argparse
from saml2.mdstore import MetaDataFile, MetaDataExtern, MetadataStore
@@ -25,22 +12,6 @@ __author__ = 'rolandh'
A script that imports and verifies metadata.
"""
-
-ONTS = {
- saml.NAMESPACE: saml,
- mdui.NAMESPACE: mdui,
- mdattr.NAMESPACE: mdattr,
- mdrpi.NAMESPACE: mdrpi,
- dri.NAMESPACE: dri,
- ui.NAMESPACE: ui,
- idpdisc.NAMESPACE: idpdisc,
- md.NAMESPACE: md,
- xmldsig.NAMESPACE: xmldsig,
- xmlenc.NAMESPACE: xmlenc,
- shibmd.NAMESPACE: shibmd
-}
-
-
parser = argparse.ArgumentParser()
parser.add_argument('-a', dest='attrsmap')
parser.add_argument('-o', dest='output', default="local")
@@ -65,7 +36,7 @@ metad = None
ATTRCONV = ac_factory(args.attrsmap)
-mds = MetadataStore(ONTS.values(), None, None)
+mds = MetadataStore(None, None)
for line in open(args.conf).readlines():
line = line.strip()
@@ -81,14 +52,14 @@ for line in open(args.conf).readlines():
kwargs = {}
if spec[0] == "local":
- metad = MetaDataFile(ONTS.values(), spec[1], spec[1], **kwargs)
+ metad = MetaDataFile(spec[1], spec[1], **kwargs)
elif spec[0] == "remote":
ATTRCONV = ac_factory(args.attrsmap)
httpc = HTTPBase()
crypto = _get_xmlsec_cryptobackend(args.xmlsec)
sc = SecurityContext(crypto, key_type="", cert_type="")
- metad = MetaDataExtern(ONTS.values(), ATTRCONV, spec[1],
- sc, cert=spec[2], http=httpc, **kwargs)
+ metad = MetaDataExtern(ATTRCONV, spec[1], sc, cert=spec[2], http=httpc,
+ **kwargs)
if metad is not None:
try:
diff --git a/tools/verify_metadata.py b/tools/verify_metadata.py
index da71334c..ac211b9a 100755
--- a/tools/verify_metadata.py
+++ b/tools/verify_metadata.py
@@ -30,21 +30,6 @@ A script that imports and verifies metadata.
"""
-ONTS = {
- saml.NAMESPACE: saml,
- mdui.NAMESPACE: mdui,
- mdattr.NAMESPACE: mdattr,
- mdrpi.NAMESPACE: mdrpi,
- dri.NAMESPACE: dri,
- ui.NAMESPACE: ui,
- idpdisc.NAMESPACE: idpdisc,
- md.NAMESPACE: md,
- xmldsig.NAMESPACE: xmldsig,
- xmlenc.NAMESPACE: xmlenc,
- shibmd.NAMESPACE: shibmd
-}
-
-
parser = argparse.ArgumentParser()
parser.add_argument('-t', dest='type')
parser.add_argument('-u', dest='url')
@@ -68,17 +53,17 @@ if args.type == "local":
if args.cert and args.xmlsec:
crypto = _get_xmlsec_cryptobackend(args.xmlsec)
sc = SecurityContext(crypto)
- metad = MetaDataFile(ONTS.values(), args.item, args.item,
- cert=args.cert, security=sc, **kwargs)
+ metad = MetaDataFile(args.item, args.item, cert=args.cert, security=sc,
+ **kwargs)
else:
- metad = MetaDataFile(ONTS.values(), args.item, args.item, **kwargs)
+ metad = MetaDataFile(args.item, args.item, **kwargs)
elif args.type == "external":
ATTRCONV = ac_factory(args.attrsmap)
httpc = HTTPBase()
crypto = _get_xmlsec_cryptobackend(args.xmlsec)
sc = SecurityContext(crypto)
- metad = MetaDataExtern(ONTS.values(), ATTRCONV, args.url,
- sc, cert=args.cert, http=httpc, **kwargs)
+ metad = MetaDataExtern(ATTRCONV, args.url, sc, cert=args.cert, http=httpc,
+ **kwargs)
if metad:
try: