hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srihari na <namasrih...@gmail.com>
Subject HTTP Authentication - set Credentials/State at execute method
Date Wed, 11 Dec 2013 12:50:23 GMT
Hello Folks,

I have scenario for authentication where I need to pass credentials at
execute method level. Details are below:

Using http client 3.1
We set the authentication credentials to the HTTP execute call by passing
the state as an argument which can be set for every invocation,
Here is the sample code we used in 3.1
httpCode = HttpClient.executeMethod(_hostConfig,_method,_httpState);

however the same option to pass the state is not available in http client
API 4.2.5.

Once we migrated to HTTP client API v4.2.5, we do setting of authentication
credentials  at client level
Here is the sample code
_httpState = ((DefaultHttpClient)_client).getCredentialsProvider();
_httpState.setCredentials(authScope,credentials);

It is working fine when we use the the single client, single connection
manager connecting to various endpoints with different authentication
credentials As we have only one client, when two reqests with two different
authentication credentials were run,
-first request, registers with authentication credentials1  and is working
fine till the second request started
-second request, registers(overwrites the previous) with authentication
credentials2 and is working fine now
however due to new authentication credentials registration the first
request execution now fails (as it needs authentication credentials1 but
getting authentication credentials2)
------------
1. Is there a way we can set authentication credentials for every execute
call(passing the state object as param) with 4.2.5 client API instead of
directly setting the state of the http client.
2. Is there a way we can set authentication credentials at method or
context level so that we can pass it for every request?


-- 
Regards,
Srihari NA

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message