El problema aquí es consumir un recurso web que tiene autenticación NTLM mientras se utiliza Apache HttpClient en el lado del cliente. El problema que estoy teniendo es forzar al cliente a usar la autenticación NTLM. aquí hay un código sapmle.Apache HttpClient 4.1.1 Autenticación NTLM no SPNEGO
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
NTCredentials creds = new NTCredentials("_myUSer_","_myPass_","_myWorkstation_","_myDomain_");
httpclient.getCredentialsProvider().setCredentials(new AuthScope("serverName",80), creds);
List<String> authpref = new ArrayList<String>();
authpref.add(AuthPolicy.NTLM);
httpclient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
HttpHost target = new HttpHost("serverName", 80, "http");
HttpGet httpget = new HttpGet("webResource");
HttpContext localContext = new BasicHttpContext();
HttpResponse response = httpclient.execute(target, httpget, localContext);
Aquí está el error de Java:
org.apache.http.client.protocol.RequestTargetAuthentication process
SEVERE: Authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
La respuesta del servidor Web es un 401
.
¿Alguna idea sobre por qué la política de autenticación no está configurada correctamente? ¿Me falta algo en el código?
he encontrado un problema con mi código y es que el AuthScope debe apuntar a su proxy y no su objetivo, que se deshizo de los errores en los que estaba tratando de usar Kerberos en lugar de NTLM , pero todavía recibo un 401 del servidor, ¿alguna idea sobre la combinación correcta de nombre de usuario/contraseña/dominio? – Kelly
HttpClient necesita ser actualizado verifique mi publicación [http://stackoverflow.com/questions/5917356/httpclient-4-1-1-returns-401-when-authenticating-with-ntlm-browsers-work-fine/20047880# 20047880] [1] [1]: http://stackoverflow.com/questions/5917356/httpclient-4-1-1-returns-401-when-authenticating-with-ntlm-browsers-work -fine/20047880 # 20047880 –