Sebastiaan van Erk wrote:
Hi,

I have a question a preemptive authentication and auth types in alhpa5.

First of all, I'm doing some non-repeatable requests, but I always do 1 repeatable short request first.

I can use this first request to authenticate to the proxy (figuring out the out type etc), but the following requests should be preemptive if possible. I use all three possible auth types (basic, digest, and NTLM).

First question: is the above doable with httpclient 4.0-alpha5?


HttpClient 4.0 can be customized to support preemptive authentication using BASIC or DIGEST schemes. NTLM cannot be used preemptively in principle.

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

Second question: when I register credentials with httpclient, I can only set them once. So how can set the correct credentials if I don't yet know the auth type? Or should I use the first request to determine the auth type? Currently there are UsernamePasswordCredentials (for BASIC and DIGEST) and NTCredentials (for NTLM). Or is it possible to *always* just use NTCredentials for the other auth types as well?
Yes, it is. NTCredentials are perfectly valid for non-NTLM authentication schemes.


Third question: in alpha5 the following code no longer compiles:

    HttpClientParams.setAuthenticationPreemptive(true);

What is the correct way to use preemptive authentication now?

The use of preemptive authentication is discouraged (or at least not promoted). However, one can easily add preemptive authentication capabilities using custom protocol interceptors. See samples above.

Hope this helps

Oleg


Regards,
Sebastiaan



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

Reply via email to