From 42b916f382d46b3fda512df81c00875978eaeb1d Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Mon, 6 May 2013 14:10:40 +0200 Subject: [PATCH] Avoid hard xmlsec_binary requirement for ECP client. By providing an already initialized Config() instance, an ECP client using another CryptoBackend than xmlsec1 can be instantiated. --- src/saml2/ecp_client.py | 27 ++++++++++++++++----------- tests/test_63_ecp.py | 3 +-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/saml2/ecp_client.py b/src/saml2/ecp_client.py index 7a6253c..b092f89 100644 --- a/src/saml2/ecp_client.py +++ b/src/saml2/ecp_client.py @@ -48,28 +48,33 @@ class Client(Entity): def __init__(self, user, passwd, sp="", idp=None, metadata_file=None, xmlsec_binary=None, verbose=0, ca_certs="", disable_ssl_certificate_validation=True, key_file=None, - cert_file=None): + cert_file=None, config=None): """ :param user: user name :param passwd: user password :param sp: The SP URL :param idp: The IdP PAOS endpoint :param metadata_file: Where the metadata file is if used - :param xmlsec_binary: Where the xmlsec1 binary can be found + :param xmlsec_binary: Where the xmlsec1 binary can be found (*) :param verbose: Chatty or not :param ca_certs: is the path of a file containing root CA certificates - for SSL server certificate validation. + for SSL server certificate validation (*) :param disable_ssl_certificate_validation: If disable_ssl_certificate_validation is true, SSL cert validation - will not be performed. + will not be performed (*) + :param key_file: Private key filename (*) + :param cert_file: Certificate filename (*) + :param config: Config() instance, overrides all the parameters marked + with an asterisk (*) above """ - config = Config() - config.disable_ssl_certificate_validation = \ - disable_ssl_certificate_validation - config.key_file = key_file - config.cert_file = cert_file - config.ca_certs = ca_certs - config.xmlsec_binary = xmlsec_binary + if not config: + config = Config() + config.disable_ssl_certificate_validation = \ + disable_ssl_certificate_validation + config.key_file = key_file + config.cert_file = cert_file + config.ca_certs = ca_certs + config.xmlsec_binary = xmlsec_binary Entity.__init__(self, "sp", config) self._idp = idp diff --git a/tests/test_63_ecp.py b/tests/test_63_ecp.py index b423e52..5f1dac5 100644 --- a/tests/test_63_ecp.py +++ b/tests/test_63_ecp.py @@ -38,8 +38,7 @@ class DummyResponse(object): def test_complete_flow(): client = ecp_client.Client("user", "password", - metadata_file=full_path("idp_all.xml"), - xmlsec_binary=xmlsec_path) + metadata_file=full_path("idp_all.xml")) sp = Saml2Client(config_file=dotname("servera_conf")) idp = Server(config_file=dotname("idp_all_conf"))