We help IT Professionals succeed at work.
Get Started

Problem With NTLM authentication while using Apache HTTPClient APIs

sangameshrh asked
Last Modified: 2013-11-24
I am using Apache HTTPClient for file uploading.(Apache File Upload at the server side)
Code looks like this
            HttpState httpState = new HttpState();
            httpState.setProxyCredentials(new AuthScope(proxyHost,port),new NTCredentials(userName,password));

Its working file if the proxy is without authentication or with Authentication.

But at one place I have encountered an error like this

Oct 24, 2007 1:36:28 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: ntlm authentication scheme selected
Oct 24, 2007 1:36:28 PM org.apache.commons.httpclient.HttpMethodDirector authenticate
SEVERE: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
      at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.java:332)
      at org.apache.commons.httpclient.HttpMethodDirector.authenticateProxy(HttpMethodDirector.java:320)
      at org.apache.commons.httpclient.HttpMethodDirector.authenticate(HttpMethodDirector.java:232)
      at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
      at Test.submitMessage(UserValidation.java:276)
      at SendMessage.run(SendMessage.java:305)
      at java.lang.Thread.run(Unknown Source)
Oct 24, 2007 1:36:28 PM org.apache.commons.httpclient.HttpMethodDirector processProxyAuthChallenge
INFO: Failure authenticating with NTLM <any realm>@

Watch Question
Java Developer
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE