John Watson wrote:
I'm a new user of Http Client 4.0 (beta 2) and I'm struggling with BASIC
authentication.  I'm attempting to follow the authentication sample
using (simply):

        httpclient.getCredentialsProvider().setCredentials(

                new AuthScope(realm, port),

                new UsernamePasswordCredentials(userName, password));

Firstly, I can't seem to set pre-emptive authentication using as a guide
the sample from http://hc.apache.org/httpclient-3.x/authentication.html
- I can't seem to find the method
client.getParams().setAuthenticationPreemptive(...);

Preemptive authentication in HttpClient 4.0 works completely differently compared to 3.x.

Here's a sample application showing how HttpClient can be customized to authenticate preemptively using BASIC scheme

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java

Secondly, from inspecting the logs issued by the client, it appears that
the authorization request header that I'd expect to see is not there.

Most likely the auth scope is wrong

---
new AuthScope(realm, port)
---

The fist argument is hostname, not realm

Hope this helps

Oleg


I'm obviously missing something obvious, but for the life of me, can't
find what it is.  Any help gratefully accepted.
John Watson

**********************************************************************
Satellite Information Services Limited. Registered Office: 17 Corsham Street, 
London, N1 6DR. Company No. 4243307
The information in this email (which includes any files transmitted with it) is 
confidential and is intended for the addressee only. Unauthorized recipients 
are required to maintain confidentiality. If you have received this email in 
error please notify the sender immediately, destroy any copies and delete it 
from your computer system.
**********************************************************************




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to