1818
1919__author__ = 'Roland Hedberg'
2020
21+ from oidcrp .util import has_method
22+
2123logger = logging .getLogger (__name__ )
2224
2325Version = "2.0"
@@ -31,38 +33,35 @@ class ExpiredToken(Exception):
3133
3234
3335class Client (object ):
34- def __init__ (self , state_db , ca_certs = None , client_authn_factory = None ,
35- keyjar = None , verify_ssl = True , config = None , client_cert = None ,
36- httplib = None , services = None , jwks_uri = '' ):
36+ def __init__ (self , state_db , client_authn_factory = None ,
37+ keyjar = None , verify_ssl = True , config = None ,
38+ httplib = None , services = None , jwks_uri = '' , httpc_params = None ):
3739 """
3840
39- :param ca_certs: Certificates used to verify HTTPS certificates
4041 :param client_authn_factory: Factory that this client can use to
4142 initiate a client authentication class.
4243 :param keyjar: A py:class:`oidcmsg.key_jar.KeyJar` instance
43- :param verify_ssl: Whether the SSL certificate should be verified.
4444 :param config: Configuration information passed on to the
4545 :py:class:`oidcservice.service_context.ServiceContext`
4646 initialization
47- :param client_cert: Certificate used by the HTTP client
4847 :param httplib: A HTTP client to use
4948 :param services: A list of service definitions
5049 :param jwks_uri: A jwks_uri
50+ :param httpc_params: HTTP request arguments
5151 :return: Client instance
5252 """
5353
5454 self .session_interface = StateInterface (state_db )
55- self .http = httplib or HTTPLib (ca_certs = ca_certs ,
56- verify_ssl = verify_ssl ,
57- client_cert = client_cert )
55+ self .http = httplib or HTTPLib (httpc_params )
5856
5957 if not keyjar :
6058 keyjar = KeyJar ()
6159 keyjar .verify_ssl = verify_ssl
6260
6361 self .events = None
6462 self .service_context = ServiceContext (keyjar , config = config ,
65- jwks_uri = jwks_uri )
63+ jwks_uri = jwks_uri ,
64+ httpc_params = httpc_params )
6665 if self .service_context .client_id :
6766 self .client_id = self .service_context .client_id
6867
@@ -77,7 +76,6 @@ def __init__(self, state_db, ca_certs=None, client_authn_factory=None,
7776 do_add_ons (config ['add_ons' ], self .service )
7877
7978 self .service_context .service = self .service
80-
8179 self .verify_ssl = verify_ssl
8280
8381 def do_request (self , request_type , response_body_type = "" , request_args = None ,
@@ -149,7 +147,7 @@ def service_request(self, service, url, method="GET", body=None,
149147 :param body: A message body if any
150148 :param response_body_type: The expected format of the body of the
151149 return message
152- :param http_args : Arguments for the HTTP client
150+ :param httpc_params : Arguments for the HTTP client
153151 :return: A cls or ResponseMessage instance or the HTTP response
154152 instance if no response body was expected.
155153 """
@@ -159,8 +157,12 @@ def service_request(self, service, url, method="GET", body=None,
159157
160158 logger .debug (REQUEST_INFO .format (url , method , body , headers ))
161159
162- response = self .get_response (service , url , method , body , response_body_type , headers ,
163- ** kwargs )
160+ if has_method (service , "get_response" ):
161+ response = service .get_response (url , method , body , response_body_type , headers ,
162+ ** kwargs )
163+ else :
164+ response = self .get_response (service , url , method , body , response_body_type , headers ,
165+ ** kwargs )
164166
165167 if 'error' in response :
166168 pass
0 commit comments