Index: Authenticator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v retrieving revision 1.30 diff -u -r1.30 Authenticator.java --- Authenticator.java 30 Sep 2002 19:42:13 -0000 1.30 +++ Authenticator.java 2 Oct 2002 07:23:50 -0000 @@ -332,13 +332,28 @@ boolean proxy = PROXY_AUTH_RESP.equals(respHeader); NTCredentials cred = null; - try { - cred = (NTCredentials) (proxy - ? state.getProxyCredentials(null) - : state.getCredentials(null)); - } catch (ClassCastException e) { - throw new HttpException("NTCredentials required " - + "for NTLM authentication."); + if (method.getRequestHeader("Host") != null) { + String host = method.getRequestHeader("Host").getValue(); + try { + cred = (NTCredentials)(proxy ? state.getProxyCredentials(host) + : state.getCredentials(host)); + } catch (ClassCastException e) { + throw new HttpException("NTCredentials required " + + "for NTLM authentication."); + } + } + + if (cred == null) { + log.info("No credentials for specific host, " + + "attempting to use default credentials."); + try { + cred = (NTCredentials) (proxy + ? state.getProxyCredentials(null) + : state.getCredentials(null)); + } catch (ClassCastException e) { + throw new HttpException("NTCredentials required " + + "for NTLM authentication."); + } } try {