Entries tagged [httpclient]

You're viewing entries tagged [httpclient] in the weblog safari.

NTLM-Authentication using HTTPClient, JCIFSEngine and NTLMSchemeFactory

Apache's HttpClient 4.0 does not provide support for the NTLM authentication scheme out of the box and probably never will. The reasons for that are legal rather than technical. (Source: http://hc.apache.org/httpcomponents-client/ntlm.html)

But Apache proposes an implementation blue print using the classes JCIFSEngine and NTLMSchemeFactory.

The last step is to glue it together. This example authenticates against IIS6 and Windows2003 domain.

 httpclient = new DefaultHttpClient();
 httpclient.getParams().setParameter("http.useragent", "Mozilla/5.0 (X11; U; Linux i686; en; rv:1.7.3)");
 httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
 httpclient.getCredentialsProvider().setCredentials(new AuthScope(HOSTNAME, -1),
                new NTCredentials(USERNAME, PASSWORD, LOCAL, DOMAIN));