本文整理汇总了Python中saml2.sigver.get_xmlsec_binary函数的典型用法代码示例。如果您正苦于以下问题:Python get_xmlsec_binary函数的具体用法?Python get_xmlsec_binary怎么用?Python get_xmlsec_binary使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_xmlsec_binary函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, idp_conf, logger, conf, publicKey, privateKey, metadataList):
"""
Constructor.
Initiates the class.
:param logger: Logger to be used when something needs to be logged.
:param conf: idp_proxy_conf see IdpProxy/conig/idp_proxy_conf.example.py
:param key: A RSA key to be used for encryption.
:param metadataList: A list of metadata files.
[{"local": ["swamid-1.0.xml"]}, {"local": ["sp.xml"]}]
:raise:
"""
if (logger is None) or (conf is None) or (publicKey is None)or (privateKey is None):
raise ValueError(
"A new instance must include a value for logger, conf and key.")
#Public key to be used for encryption.
self.publicKey = publicKey
self.privateKey = privateKey
#Used for presentation of mako files.
self.lookup = TemplateLookup(
directories=[MetadataGeneration.CONST_STATIC_MAKO + 'templates',
MetadataGeneration.CONST_STATIC_MAKO + 'htdocs'],
module_directory='modules',
input_encoding='utf-8',
output_encoding='utf-8')
#The logger.
self.logger = logger
#A list of all social services used by this IdPproxy.
self.socialServiceKeyList = []
#A list of all service providers used by this sp.
self.spKeyList = []
for key in conf:
self.socialServiceKeyList.append(conf[key]["name"])
try:
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except:
try:
xmlsec_path = get_xmlsec_binary(["/usr/local/bin"])
except:
self.logger.info('Xmlsec must be installed! Tries /usr/bin/xmlsec1.')
xmlsec_path = '/usr/bin/xmlsec1'
self.xmlsec_path = xmlsec_path
config = Config()
config.disable_ssl_certificate_validation = True
config.key_file = idp_conf["key_file"]
config.cert_file = idp_conf["cert_file"]
config.xmlsec_binary = idp_conf["xmlsec_binary"]
config.debug = idp_conf["debug"]
for metadata in metadataList:
mds = MetadataStore(MetadataGeneration.CONST_ONTS.values(),
MetadataGeneration.CONST_ATTRCONV, config)
mds.imp(metadata)
for entityId in mds.keys():
self.spKeyList.append(entityId)
示例2: load
def load(self, cnf, metadata_construction=False):
""" The base load method, loads the configuration
:param cnf: The configuration as a dictionary
:param metadata_construction: Is this only to be able to construct
metadata. If so some things can be left out.
:return: The Configuration instance
"""
for arg in COMMON_ARGS:
try:
self._attr[""][arg] = cnf[arg]
except KeyError:
pass
if "service" in cnf:
for typ in ["aa", "idp", "sp", "pdp"]:
try:
self.load_special(cnf["service"][typ], typ,
metadata_construction=metadata_construction)
except KeyError:
pass
if not metadata_construction:
if "xmlsec_binary" not in self._attr[""]:
self._attr[""]["xmlsec_binary"] = get_xmlsec_binary()
# verify that xmlsec is where it's supposed to be
if not os.access(self._attr[""]["xmlsec_binary"], os.F_OK):
raise Exception("xmlsec binary not in '%s' !" % (
self._attr[""]["xmlsec_binary"]))
self.load_complex(cnf, metadata_construction=metadata_construction)
self.context = self.def_context
return self
示例3: test_metadata_file
def test_metadata_file():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
mds = MetadataStore(list(ONTS.values()), ATTRCONV, sec_config, disable_ssl_certificate_validation=True)
mds.imp(METADATACONF["8"])
print((len(list(mds.keys()))))
assert len(list(mds.keys())) == 560
示例4: test_load_local_dir
def test_load_local_dir():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
mds = MetadataStore(ONTS.values(), ATTRCONV, sec_config, disable_ssl_certificate_validation=True)
mds.imp(METADATACONF["9"])
print mds
assert len(mds) == 3 # Three sources
assert len(mds.keys()) == 4 # number of idps
示例5: xmlsec
def xmlsec():
"""
xmlsec path
"""
if get_xmlsec_binary:
return get_xmlsec_binary()
else:
return '/usr/local/bin/xmlsec1'
示例6: test_mdx_certs
def test_mdx_certs():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
http = HTTPBase(verify=False, ca_bundle=None)
mdx = MetaDataMDX(ONTS.values(), ATTRCONV, "http://pyff-test.nordu.net",
sec_config, None, http)
foo = mdx.certs("https://idp.umu.se/saml2/idp/metadata.php", "idpsso")
assert len(foo) == 1
示例7: test_load_extern_incommon
def test_load_extern_incommon():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
mds = MetadataStore(ONTS.values(), ATTRCONV, sec_config,
disable_ssl_certificate_validation=True)
mds.imp(METADATACONF["10"])
print(mds)
assert mds
assert len(mds.keys())
示例8: test_load_external
def test_load_external():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
mds = MetadataStore(ATTRCONV, sec_config,
disable_ssl_certificate_validation=True)
mds.imp(METADATACONF["10"])
print(mds)
assert len(mds) == 1 # One source
assert len(mds.keys()) > 1 # number of idps
示例9: test_mdx_service
def test_mdx_service():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
http = HTTPBase(verify=False, ca_bundle=None)
mdx = MetaDataMDX(ONTS.values(), ATTRCONV, "http://pyff-test.nordu.net",
sec_config, None, http)
foo = mdx.service("https://idp.umu.se/saml2/idp/metadata.php",
"idpsso_descriptor", "single_sign_on_service")
assert len(foo) == 1
assert foo.keys()[0] == BINDING_HTTP_REDIRECT
示例10: setup_class
def setup_class(self):
xmlexec = get_xmlsec_binary()
self.sec = sigver.SecurityContext(xmlexec, key_file=PRIV_KEY,
cert_file=PUB_KEY, debug=1)
self._assertion = factory( saml.Assertion,
version="2.0",
id="11111",
issue_instant="2009-10-30T13:20:28Z",
signature=sigver.pre_signature_part("11111", self.sec.my_cert, 1),
attribute_statement=do_attribute_statement({
("","","surName"): ("Foo",""),
("","","givenName") :("Bar",""),
})
)
示例11: test_decrypt
def test_decrypt(self):
attr_stat = saml.attribute_statement_from_string(
open("encrypted_attribute_statement.xml").read())
assert len(attr_stat.attribute) == 0
assert len(attr_stat.encrypted_attribute) == 4
xmlsec = get_xmlsec_binary()
sec = SecurityContext(xmlsec, key_file="private_key.pem")
resp = AuthnResponse(sec, None, "entity_id")
resp.decrypt_attributes(attr_stat)
assert len(attr_stat.attribute) == 4
assert len(attr_stat.encrypted_attribute) == 4
示例12: test_load_string
def test_load_string():
sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"])
mds = MetadataStore(ONTS.values(), ATTRCONV, sec_config,
disable_ssl_certificate_validation=True)
mds.imp(METADATACONF["11"])
# print(mds)
assert len(mds.keys()) == 1
idps = mds.with_descriptor("idpsso")
assert list(idps.keys()) == [
'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php']
certs = mds.certs(
'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php',
"idpsso", "signing")
assert len(certs) == 1
示例13: load
def load(self, cnf, metadata_construction=False):
""" The base load method, loads the configuration
:param cnf: The configuration as a dictionary
:param metadata_construction: Is this only to be able to construct
metadata. If so some things can be left out.
:return: The Configuration instance
"""
_uc = self.unicode_convert
for arg in COMMON_ARGS:
if arg == "virtual_organization":
if "virtual_organization" in cnf:
for key, val in cnf["virtual_organization"].items():
self.vorg[key] = VirtualOrg(None, key, val)
continue
try:
setattr(self, arg, _uc(cnf[arg]))
except KeyError:
pass
except TypeError: # Something that can't be a string
setattr(self, arg, cnf[arg])
if "service" in cnf:
for typ in ["aa", "idp", "sp", "pdp", "aq"]:
try:
self.load_special(
cnf["service"][typ], typ,
metadata_construction=metadata_construction)
self.serves.append(typ)
except KeyError:
pass
if not metadata_construction:
if not self.xmlsec_binary:
self.xmlsec_binary = get_xmlsec_binary()
# verify that xmlsec is where it's supposed to be
if not os.path.exists(self.xmlsec_binary):
#if not os.access(, os.F_OK):
raise Exception(
"xmlsec binary not in '%s' !" % self.xmlsec_binary)
self.load_complex(cnf, metadata_construction=metadata_construction)
self.context = self.def_context
return self
示例14: test_sign_assertion
def test_sign_assertion(self):
ass = self._assertion
print ass
sign_ass = self.sec.sign_assertion_using_xmlsec("%s" % ass,
nodeid=ass.id)
#print sign_ass
sass = saml.assertion_from_string(sign_ass)
#print sass
assert _eq(sass.keyswv(), ['attribute_statement', 'issue_instant',
'version', 'signature', 'id'])
assert sass.version == "2.0"
assert sass.id == "11111"
assert time_util.str_to_time(sass.issue_instant)
print xmlsec_version(get_xmlsec_binary())
item = self.sec.check_signature(sass, class_name(sass), sign_ass)
assert isinstance(item, saml.Assertion)
示例15: setup_class
def setup_class(self):
xmlexec = get_xmlsec_binary()
md = MetadataStore([saml, samlp], None, xmlexec)
md.load("local", full_path("metadata_cert.xml"))
crypto = get_xmlsec_cryptobackend()
self.sec = sigver.SecurityContext(crypto, key_file=PRIV_KEY,
cert_file=PUB_KEY, debug=1, metadata=md)
self._assertion = factory( saml.Assertion,
version="2.0",
id="11111",
issue_instant="2009-10-30T13:20:28Z",
signature=sigver.pre_signature_part("11111", self.sec.my_cert, 1),
attribute_statement=do_attribute_statement({
("","","surName"): ("Foo",""),
("","","givenName") :("Bar",""),
})
)