Interesting. Up to now I have been explicitly setting
the authorization header, because I couldn't get HTTP
Client to do what I wanted. In my case I just needed to
download a single resource from a URL given of the form:

  http://user:[EMAIL PROTECTED]/

I didn't want to have to resend the reequest a second
time in response to a challenge.

Andre
 

-----Original Message-----
From: Kalnichevski, Oleg [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 9:16 AM
To: Commons HttpClient Project
Subject: RE: Posting XML over authenticated connection using SSL


Lee Francis,

Now it hit me. 


When credentials are explicitly set to be used with a given host and/or realm only, 
there'll never be used for preemptive authentication for security reasons. The 
credentials will be used to respond to a direct authorization challenge originating 
from the specified host/realm.

client.getState().setCredentials(realm, host, upc);

You have got to provide default credentials in order for HttpClient to be able to send 
credentials preemptively

client.getState().setCredentials(null, null, upc);

This should do the trick

Oleg

-----Original Message-----
From: Lee Francis Wilhelmsen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 18, 2004 15:03
To: Commons HttpClient Project
Subject: RE: Posting XML over authenticated connection using SSL


> Since you appear to be passing a custom HttpState object to the 
> HttpClient#executeMethod these lines of code have no effect of what so ever on the 
> method's execution
>

> client.getState().setAuthenticationPreemptive(true);
> client.getState().setCredentials(realm, host, upc);
 >
> Try this instead
>

> httpState.setAuthenticationPreemptive(true);
> httpState.setCredentials(realm, host, upc);
> status = client.executeMethod(hostConfiguration, method, httpState);
>

> HTH
>

> Oleg

Sorry, it seems I 've made a mistake when showing you my example code in

  my prevous mail. I'm calling
        client.executeMethod(method);
and not
        client.executeMethod(hostConfiguration, method, httpState);
in my code.

Don't understand why the Authorization header isn't being sent in the

first request as expected when setting setAuthenticationPreemptive(true)

Any ideas?

Regards
Lee Francis

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access 
to this email by anyone other than the intended addressee is unauthorized.  If you are 
not the intended recipient of this message, any review, disclosure, copying, 
distribution, retention, or any action taken or omitted to be taken in reliance on it 
is prohibited and may be unlawful.  If you are not the intended recipient, please 
reply to or forward a copy of this message to the sender and delete the message, any 
attachments, and any copies thereof from your system.
***************************************************************************************************

---------------------------------------------------------------------
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]

Reply via email to