NTLM と Java に関する StackOverflow のすべての議論を閲覧しましたが、答えが見つからないようです。もっと具体的にしようと思います。
NTLM 認証用に構成されている (希望する) クライアント スタブを返すコードを次に示します。
ServiceStub getService() {
try {
ServiceStub stub = new ServiceStub(
"http://myserver/some/path/to/webservices.asmx"); // this service is hosted on IIS
List<String> ntlmPreferences = new ArrayList<String>(1);
ntlmPreferences.add(HttpTransportProperties.Authenticator.NTLM);
HttpTransportProperties.Authenticator ntlmAuthenticator = new HttpTransportProperties.Authenticator();
ntlmAuthenticator.setAuthSchemes(ntlmPreferences);
ntlmAuthenticator.setUsername("me");
ntlmAuthenticator.setHost("localhost");
ntlmAuthenticator.setDomain("mydomain");
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.AUTHENTICATE, ntlmAuthenticator);
options.setProperty(HTTPConstants.CHUNKED, "false");
return stub;
} catch (AxisFault e) {
e.printStackTrace();
}
return null;
}
これにより、有効な SerivceStub オブジェクトが返されます。スタブで呼び出しを実行しようとすると、ログに次のように表示されます。
Jun 9, 2010 12:12:22 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: NTLM authentication scheme selected
Jun 9, 2010 12:12:22 PM org.apache.commons.httpclient.HttpMethodDirector authenticate
SEVERE: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials
誰でもこの問題の解決策を持っていますか?