J'ai parcouru toutes les discussions ici sur StackOverflow concernant NTLM et Java, et je n'arrive pas à trouver la réponse. Je vais essayer d'être beaucoup plus précis.Apache Axis2 1.5.1 et l'authentification NTLM
est ici un code qui renvoie un stub client qui (je l'espère) est configuré pour l'authentification 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;
}
Ce retourne un objet SerivceStub valide. Lorsque je tente d'invoquer un appel sur le talon, je vois ce qui suit dans mon journal:
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
Quelqu'un at-il une solution à ce problème?
je pense avoir la réponse. N'utilisez pas Axis. Axis dit qu'il prend en charge NTLM, mais il a besoin d'informations d'identification. Ceci est inutile dans un environnement SSO où nous voulons les informations d'identification ambiantes. Cela devrait être une solution facile pour Axis dans Java 6 parce que Java 6 est livré avec NTLM natif, mais je suppose qu'ils s'en foutent. Je vais essayer CXF - ça devrait marcher ... ou du moins j'espère que c'est le cas. – andyczerwonka
CXF fonctionne très bien - déposez Axis si vous avez besoin de NTLM. – andyczerwonka
Il n'y a pas de code dans CXF pour gérer NTLM. Cela dépend du support NTLM fourni par JDK. Lors du travail NTLM avec CXF, nous devions définir httpClientPolicy.setAllowChunking (false) ;. Cela n'a pas fonctionné sans cet ensemble de propriétés. –