Index: java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.170 diff -u -r1.170 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 19 Jul 2003 09:41:37 -0000 1.170 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 22 Jul 2003 09:29:36 -0000 @@ -73,6 +73,7 @@ import org.apache.commons.httpclient.auth.AuthScheme; import org.apache.commons.httpclient.auth.AuthenticationException; +import org.apache.commons.httpclient.auth.CredentialsNotAvailableException; import org.apache.commons.httpclient.auth.HttpAuthenticator; import org.apache.commons.httpclient.auth.MalformedChallengeException; import org.apache.commons.httpclient.cookie.CookiePolicy; @@ -2438,8 +2439,15 @@ this.proxyRealm = authscheme.getRealm(); break; } + } catch (CredentialsNotAvailableException e) { + if (LOG.isWarnEnabled()) { + LOG.warn(e.getMessage()); + } + return true; // finished request } catch (AuthenticationException e) { - LOG.warn(e.getMessage()); + if (LOG.isErrorEnabled()) { + LOG.error(e.getMessage(), e); + } return true; // finished request } if (!authenticated) { Index: java/org/apache/commons/httpclient/auth/BasicScheme.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/BasicScheme.java,v retrieving revision 1.4 diff -u -r1.4 BasicScheme.java --- java/org/apache/commons/httpclient/auth/BasicScheme.java 26 May 2003 22:07:22 -0000 1.4 +++ java/org/apache/commons/httpclient/auth/BasicScheme.java 22 Jul 2003 09:29:36 -0000 @@ -133,7 +133,7 @@ try { usernamepassword = (UsernamePasswordCredentials) credentials; } catch (ClassCastException e) { - throw new AuthenticationException( + throw new InvalidCredentialsException( "Credentials cannot be used for basic authentication: " + credentials.toString()); } Index: java/org/apache/commons/httpclient/auth/CredentialsNotAvailableException.java =================================================================== RCS file: java/org/apache/commons/httpclient/auth/CredentialsNotAvailableException.java diff -N java/org/apache/commons/httpclient/auth/CredentialsNotAvailableException.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ java/org/apache/commons/httpclient/auth/CredentialsNotAvailableException.java 22 Jul 2003 09:29:36 -0000 @@ -0,0 +1,101 @@ +/* + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * [Additional notices, if required by prior licensing conditions] + * + */ + +package org.apache.commons.httpclient.auth; + +/** + * Authentication credentials required to respond to a authentication + * challenge are not available + * + * @author Oleg Kalnichevski + * + * @since 2.1 + */ +public class CredentialsNotAvailableException extends AuthenticationException { + /** + * Creates a new CredentialsNotAvailableException with a null detail message. + */ + public CredentialsNotAvailableException() { + super(); + } + + /** + * Creates a new CredentialsNotAvailableException with the specified message. + * + * @param message the exception detail message + */ + public CredentialsNotAvailableException(String message) { + super(message); + } + + /** + * Creates a new CredentialsNotAvailableException with the specified detail message and cause. + * + * @param message the exception detail message + * @param cause the Throwable that caused this exception, or null + * if the cause is unavailable, unknown, or not a Throwable + */ + public CredentialsNotAvailableException(String message, Throwable cause) { + super(message, cause); + } +} Index: java/org/apache/commons/httpclient/auth/DigestScheme.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/DigestScheme.java,v retrieving revision 1.4 diff -u -r1.4 DigestScheme.java --- java/org/apache/commons/httpclient/auth/DigestScheme.java 26 May 2003 22:07:22 -0000 1.4 +++ java/org/apache/commons/httpclient/auth/DigestScheme.java 22 Jul 2003 09:29:36 -0000 @@ -152,7 +152,7 @@ try { usernamepassword = (UsernamePasswordCredentials) credentials; } catch (ClassCastException e) { - throw new AuthenticationException( + throw new InvalidCredentialsException( "Credentials cannot be used for basic authentication: " + credentials.toString()); } Index: java/org/apache/commons/httpclient/auth/HttpAuthenticator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java,v retrieving revision 1.9 diff -u -r1.9 HttpAuthenticator.java --- java/org/apache/commons/httpclient/auth/HttpAuthenticator.java 15 Jul 2003 23:35:06 -0000 1.9 +++ java/org/apache/commons/httpclient/auth/HttpAuthenticator.java 22 Jul 2003 09:29:37 -0000 @@ -312,7 +312,7 @@ ? state.getProxyCredentials(realm, host) : state.getCredentials(realm, host); if (credentials == null) { - throw new AuthenticationException( + throw new CredentialsNotAvailableException( "No credentials available for the " + authscheme.getSchemeName() + " authentication realm '" + realm + "'"); } Index: java/org/apache/commons/httpclient/auth/InvalidCredentialsException.java =================================================================== RCS file: java/org/apache/commons/httpclient/auth/InvalidCredentialsException.java diff -N java/org/apache/commons/httpclient/auth/InvalidCredentialsException.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ java/org/apache/commons/httpclient/auth/InvalidCredentialsException.java 22 Jul 2003 09:29:37 -0000 @@ -0,0 +1,101 @@ +/* + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * [Additional notices, if required by prior licensing conditions] + * + */ + +package org.apache.commons.httpclient.auth; + +/** + * Authentication credentials required to respond to a authentication + * challenge are invalid + * + * @author Oleg Kalnichevski + * + * @since 2.1 + */ +public class InvalidCredentialsException extends AuthenticationException { + /** + * Creates a new InvalidCredentialsException with a null detail message. + */ + public InvalidCredentialsException() { + super(); + } + + /** + * Creates a new InvalidCredentialsException with the specified message. + * + * @param message the exception detail message + */ + public InvalidCredentialsException(String message) { + super(message); + } + + /** + * Creates a new InvalidCredentialsException with the specified detail message and cause. + * + * @param message the exception detail message + * @param cause the Throwable that caused this exception, or null + * if the cause is unavailable, unknown, or not a Throwable + */ + public InvalidCredentialsException(String message, Throwable cause) { + super(message, cause); + } +} Index: java/org/apache/commons/httpclient/auth/NTLM.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/NTLM.java,v retrieving revision 1.2 diff -u -r1.2 NTLM.java --- java/org/apache/commons/httpclient/auth/NTLM.java 15 Jul 2003 02:19:58 -0000 1.2 +++ java/org/apache/commons/httpclient/auth/NTLM.java 22 Jul 2003 09:29:37 -0000 @@ -75,7 +75,6 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.httpclient.HttpConstants; -import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.util.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -148,7 +147,7 @@ */ public final String getResponseFor(String message, String username, String password, String host, String domain) - throws HttpException { + throws AuthenticationException { final String response; if (message == null || message.trim().equals("")) { @@ -164,9 +163,9 @@ * Return the cipher for the specified key. * @param key The key. * @return Cipher The cipher. - * @throws HttpException If the cipher cannot be retrieved. + * @throws AuthenticationException If the cipher cannot be retrieved. */ - private Cipher getCipher(byte[] key) throws HttpException { + private Cipher getCipher(byte[] key) throws AuthenticationException { try { final Cipher ecipher = Cipher.getInstance("DES/ECB/NoPadding"); key = setupKey(key); @@ -218,7 +217,7 @@ * @throws HttpException If {@link Cipher.doFinal(byte[])} fails */ private byte[] encrypt(byte[] key, byte[] bytes) - throws HttpException { + throws AuthenticationException { Cipher ecipher = getCipher(key); try { byte[] enc = ecipher.doFinal(bytes); @@ -378,11 +377,11 @@ * @param domain The domain. * @param nonce the 8 byte array the server sent. * @return The type 3 message. - * @throws HttpException If {@encrypt(byte[],byte[])} fails. + * @throws AuthenticationException If {@encrypt(byte[],byte[])} fails. */ private String getType3Message(String user, String password, String host, String domain, byte[] nonce) - throws HttpException { + throws AuthenticationException { int ntRespLen = 0; int lmRespLen = 24; @@ -480,7 +479,7 @@ * @throws HttpException If {@link #encrypt(byte[],byte[])} fails. */ private byte[] hashPassword(String password, byte[] nonce) - throws HttpException { + throws AuthenticationException { byte[] passw = getBytes(password.toUpperCase()); byte[] lmPw1 = new byte[7]; byte[] lmPw2 = new byte[7]; @@ -546,10 +545,10 @@ * @param keys The keys. * @param plaintext The plain text to encrypt. * @param results Where the results are stored. - * @throws HttpException If {@link #encrypt(byte[],byte[])} fails. + * @throws AuthenticationException If {@link #encrypt(byte[],byte[])} fails. */ private void calcResp(byte[] keys, byte[] plaintext, byte[] results) - throws HttpException { + throws AuthenticationException { byte[] keys1 = new byte[7]; byte[] keys2 = new byte[7]; byte[] keys3 = new byte[7]; Index: java/org/apache/commons/httpclient/auth/NTLMScheme.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/NTLMScheme.java,v retrieving revision 1.8 diff -u -r1.8 NTLMScheme.java --- java/org/apache/commons/httpclient/auth/NTLMScheme.java 15 Jul 2003 02:19:58 -0000 1.8 +++ java/org/apache/commons/httpclient/auth/NTLMScheme.java 22 Jul 2003 09:29:37 -0000 @@ -63,7 +63,6 @@ package org.apache.commons.httpclient.auth; -import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.NTCredentials; import org.apache.commons.logging.Log; @@ -189,14 +188,9 @@ } NTLM ntlm = new NTLM(); - String s = null; - try { - s = ntlm.getResponseFor(challenge, - credentials.getUserName(), credentials.getPassword(), - credentials.getHost(), credentials.getDomain()); - } catch (HttpException e) { - throw new AuthenticationException(e.getMessage(), e); - } + String s = ntlm.getResponseFor(challenge, + credentials.getUserName(), credentials.getPassword(), + credentials.getHost(), credentials.getDomain()); return "NTLM " + s; }