Subhash Chandran wrote:
Hi,

I recently moved RESTClient ( http://code.google.com/p/rest-client/ ) from
Commons HTTP to HTTP client.

Previously I was using BASIC and DIGEST authentication using the Commons
API. Now the example provided:

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

Does not speak on how to specify if it is DIGEST or BASIC authentication.

Can anyone of you let me know the API for specifying this?

Subhash,

The general approach has not changed. It is not entirely up to HttpClient to choose an authentication scheme as the origin server is meant to challenge the client first. Depending on what kind of authentication schemes are supported by the server the client is free to pick up the one it considers the most secure. One can override the way Httpclient selects an authentication scheme by setting 'http.auth.scheme-pref' parameter to a List<String> containing names of supported auth schemes in the order of preference.

Alternatively one can provide a custom authentication in order to have a complete control over the authentication process:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java

Hope this helps

Oleg

PS: Please consider upgrading to the latest SVN snapshot. The code in SVN trunk is very likely to be released as 4.0-BETA1 pretty soon.

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

Reply via email to