Oleg,
I had a look at the method you have suggested.
My understanding:
1. Use HttpState
- setProxyCredentials(AuthScope authscope, Credentials
credentials) - For Setting Proxy Creds
- setCredentials(AuthScope authscope, Credentials credentials) -
For Setting Server Basic Creds
2. HostConfiguration is to "Set the default host/protocol for the
methods to connect to. This value will only be used if the methods are
not given an absolute URI"
So this can be instantiated as "new HostConfiguration ()"
(default constructor) and passed to
executeMethod(HostConfiguration,HttpMethod,HttpState)
Importantly, the credentials have to be set only in the HttpState object
& HostConfiguration has nothing to do with it.
Please could you validate this & let me know if this is correct.
Thanks a lot!
Regards,
Jaya.
-----Original Message-----
From: Jaya Christina B
Sent: Thursday, December 15, 2005 5:58 PM
To: 'HttpClient User Discussion'
Subject: RE: Proxy authentication on per Method/Connection basis
Thanks Oleg for this.
Could you also say how this can be applied for Basic Auth?
Currently this is what we are doing:
if (isBasicAuthRequired) {
httpClient.getState().setAuthenticationPreemptive(true);
Credentials creds = new
UsernamePasswordCredentials(basicCreds.getUserName(),
basicCreds.getPassword());
httpClient.getState().setCredentials(null, basicCreds.getHost(),
creds); }
Will this take care of correct authentication?
Thanks!
Regards,
Jaya.
-----Original Message-----
From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 15, 2005 5:46 PM
To: [email protected]
Subject: Re: Proxy authentication on per Method/Connection basis
On Thu, Dec 15, 2005 at 05:32:35PM +0530, Jaya Christina B wrote:
>
> Hello,
>
> We are facing problems with proxy authentication (HttpClient V3).
>
> We create one HttpClient for the entire application (singleton object)
> & are setting the Proxy Authentication for the HttpClient as follows.
> We use MultiThreadedHttpConnectionManager for handling the
connections.
>
> if (isProxyAuthRequired) {
> httpClient.getHostConfiguration().setProxy(proxyCreds.getHost(),
> proxyCreds.getPort());
> Credentials creds = new
> UsernamePasswordCredentials(proxyCreds.getUserName(),
> proxyCreds.getPassword());
> httpClient.getState().setProxyCredentials(null,
> proxyCreds.getHost(), creds);
> }
>
>
> Depending on "isProxyAuthRequired", we want to execute proxy
> authentication for a connection/method or not.
> What is happening is, once a set of proxy authentication is set for
> one Method/URL, the same is getting used for the next call also, even
> when "isProxyAuthRequired" is set to false, that is, even if we dont
> call this implicitly.
>
> Is it possible to set Proxy & Basic authentication on Method basis. I
> read that this is possible by creating a connection for every method.
> But as we use MultiThreadedHttpConnectionManager , this would not be
> possible.
>
> Please could you help.
> TIA.
>
> Regards,
> Jaya.
>
Jaya,
Use HttpClient#executeMethod(HostConfiguration, HttpMethod, HttpState)
to pass an individual host config / http state for a given method
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/
httpclient/HttpClient.html#executeMethod(org.apache.commons.httpclient.H
ostConfiguration,%20org.apache.commons.httpclient.HttpMethod,%20org.apac
he.commons.httpclient.HttpState)
Hope this helps
Oleg
> *********************************************************
> Disclaimer:
>
> The contents of this E-mail (including the contents of the
enclosure(s) or attachment(s) if any) are privileged and confidential
material of MBT and should not be disclosed to, used by or copied in any
manner by anyone other than the intended addressee(s). In case you are
not the desired addressee, you should delete this message and/or
re-direct it to the sender. The views expressed in this E-mail message
(including the enclosure(s) or attachment(s) if any) are those of the
individual sender, except where the sender expressly, and with
authority, states them to be the views of MBT.
>
> This e-mail message including attachment/(s), if any, is believed to
> be free of any virus. However, it is the responsibility of the
> recipient to ensure that it is virus free and MBT is not responsible
> for any loss or damage arising in any way from its use
>
> *********************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
*********************************************************
Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or
attachment(s) if any) are privileged and confidential material of MBT and
should not be disclosed to, used by or copied in any manner by anyone other
than the intended addressee(s). In case you are not the desired addressee,
you should delete this message and/or re-direct it to the sender. The views
expressed in this E-mail message (including the enclosure(s) or attachment(s)
if any) are those of the individual sender, except where the sender expressly,
and with authority, states them to be the views of MBT.
This e-mail message including attachment/(s), if any, is believed to be free of
any virus. However, it is the responsibility of the recipient to ensure that
it is virus free and MBT is not responsible for any loss or damage arising in
any way from its use
*********************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]