You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Xiaobo Yang <xi...@gmail.com> on 2010/03/31 16:54:53 UTC
NTLM issue with HttpClient 3.1
Hi,
I've got a problem of NTLM authentication with HttpClient 3.1. My code
is as below. What I get is "Credentials provider not available" and a
401 error. But I've successfully using HttpClient 4.1 and JCIFS to
access the same URL.
What's wrong with my code?
Many thanks,
Xiaobo Yang
[java] 11:12:32,462 DEBUG HttpMethodDirector:843 - Authorization required
[java] 11:12:32,463 DEBUG AuthChallengeProcessor:155 - Using
authentication scheme: ntlm
[java] 11:12:32,463 DEBUG AuthChallengeProcessor:163 -
Authorization challenge processed
[java] 11:12:32,464 DEBUG HttpMethodDirector:714 - Authentication
scope: NTLM <any realm>@owa.bham.ac.uk:443
[java] 11:12:32,464 DEBUG HttpMethodDirector:861 - Credentials required
[java] 11:12:32,465 DEBUG HttpMethodDirector:879 - Credentials
provider not available
[java] 11:12:32,465 INFO HttpMethodDirector:722 - Failure
authenticating with NTLM <any realm>@owa.bham.ac.uk:443
[java] 11:12:32,471 INFO HTTPSender:202 - Unable to sendViaPost
to url[https://owa.bham.ac.uk/EWS/Exchange.asmx]
[java] org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(
new AuthScope(host, port, AuthScope.ANY_REALM),
new NTCredentials(username, password, host, domain));
GetMethod getMethod = new GetMethod(url);
try {
int statusCode = httpClient.executeMethod(getMethod);
System.out.println(statusCode + "\n"
+ getMethod.getResponseBodyAsString());
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
getMethod.releaseConnection();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org