Thursday, April 12, 2007

NTLM authentication using Commons HttpClient

Recently I wanted to access a site outside the firewall thru Apache commons HttpClient. The proxy server was using NTLM authentication.

Thankfully, HttpClient had support for NTLM authentication. Here's the code snippet for the same:
HostConfiguration hConf= httpClient.getHostConfiguration();
hConf.setProxy("", 8080);

new AuthScope("", 8080, "domainName"),

new NTCredentials("username", "password","my_localhost","domainName")


No comments:

Post a Comment