hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Pasero <benjamin.pas...@web.de>
Subject Help: Problems with preemptive authentication and redirects
Date Sun, 22 Jan 2006 12:09:48 GMT

I am using HttpClient 3.0 and have a problem with preemptive 
authentication and redirects.

The scenario is as follows:

1. I create a GetMethod with a certain URI, lets say www.foo.com which 
redirects to bar.foo.com
   that requires authentication.

2. I lookup a registry with stored credentials for this URI and find 
Username + Password

3. I call HttpClient.getParams().setAuthenticationPreemptive(true);

4. I create AuthScope and Credentials, asking the GetMethod for Host, 
Port and Realm. For Host
   I am getting "www.foo.com".

5. I call HttpClient.getState().setCredentials(authScope, userPwCreds);

6. I call getMethod.setDoAuthentication(true);

Now, I execute the GetMethod and it gets redirected to "bar.foo.com". 
Thereby the AuthScope
I created preemptively with "www.foo.com" is no longer valid. I get an 
401 error, although
the credentials are correct, just the host is not.

Is there a workaround for avoiding this problem? I tried to supply 
ANY_HOST as value for
the AuthScope but get the exception that NULL is not allowed (though the 
API tells me
that I can supply ANY_HOST if I want to).

Thanks for helping,

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message