I am using Apache HTTPClient for file uploading.(Apache File Upload at the server side)
Code looks like this
if(proxyStatus)
{
client.getHostConfiguration().setProxy(proxyHost,port);
if(userName!=null)
{
HttpState httpState = new HttpState();
httpState.setProxyCredentials(new AuthScope(proxyHost,port),new NTCredentials(userName,password));
filePost.setDoAuthentication(true);
client.setState(httpState);
}
else
{
filePost.setDoAuthentication(false);
}
}
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>@172.16.200.3:8080
Thanks