Index: httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v retrieving revision 1.7 diff -u -r1.7 MultiThreadedHttpConnectionManager.java --- httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 28 Jan 2003 04:40:21 -0000 1.7 +++ httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 29 Jan 2003 22:21:18 -0000 @@ -79,6 +79,7 @@ * * @author Michael Becke * @author Eric Johnson + * @author Mike Bowler * * @since 2.0 */ @@ -86,24 +87,33 @@ // -------------------------------------------------------- Class Variables /** Log object for this class. */ - private static final Log log = LogFactory.getLog(MultiThreadedHttpConnectionManager.class); + private static final Log LOG = LogFactory.getLog(MultiThreadedHttpConnectionManager.class); // ----------------------------------------------------- Instance Variables - private Map mapHosts = new HashMap(); + /** + * Map where keys are {@link HostConfiguration}s and values are {@link + * HostConnectionPool}s + */ + private final Map mapHosts = new HashMap(); + + /** Maximum number of connections allowed */ private int maxConnections = 2; // Per RFC 2616 sec 8.1.4 - // mapping from reference to hostConfiguration - private Map referenceToHostConfig; - // the reference queue used to track when HttpConnections are lost to the - // garbage collector - private ReferenceQueue referenceQueue; + /** mapping from reference to hostConfiguration */ + private final Map referenceToHostConfig; + + /** + * the reference queue used to track when HttpConnections are lost to the + * garbage collector + */ + private final ReferenceQueue referenceQueue; /** * No-args constructor */ public MultiThreadedHttpConnectionManager() { - this.referenceToHostConfig = Collections.synchronizedMap( new HashMap() ); + this.referenceToHostConfig = Collections.synchronizedMap(new HashMap()); this.referenceQueue = new ReferenceQueue(); new ReferenceQueueThread().start(); @@ -137,11 +147,11 @@ */ public HttpConnection getConnection(HostConfiguration hostConfiguration) { - while( true ) { + while (true) { try { return getConnection(hostConfiguration, 0); - } catch ( HttpException e ) { - log.debug( + } catch (HttpException e) { + LOG.debug( "Unexpected exception while waiting for connection", e ); @@ -153,25 +163,25 @@ /** * @see HttpConnectionManager#getConnection(HostConfiguration, long) */ - public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) - throws HttpException { - log.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)"); + public HttpConnection getConnection(HostConfiguration hostConfiguration, + long timeout) throws HttpException { + + LOG.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)"); if (hostConfiguration == null) { throw new IllegalArgumentException("hostConfiguration is null"); } - if (log.isDebugEnabled()) { - log.debug("HttpConnectionManager.getConnection: config = " + if (LOG.isDebugEnabled()) { + LOG.debug("HttpConnectionManager.getConnection: config = " + hostConfiguration + ", timeout = " + timeout); } // we get the connection pool with a clone of the hostConfiguration // so that it cannot be changed once the connecton has been retrieved - HttpConnection conn = getConnection( - getConnectionPool( new HostConfiguration( hostConfiguration ) ), - hostConfiguration, - timeout + final HttpConnection conn + = getConnection(getConnectionPool(new HostConfiguration(hostConfiguration)), + hostConfiguration, timeout ); return conn; @@ -182,45 +192,41 @@ * available if one exists that is not being used or if fewer than * maxConnections have been created in the connectionPool. * - * @param connectionPool - * @param hostConfiguration + * @param connectionPool The connection pool to use. + * @param hostConfiguration The host configuration. * @param timeout the number of milliseconds to wait for a connection, 0 to * wait indefinitely * * @return HttpConnection an available connection * - * @throws HttpException if a connection does not available in 'timeout' - * milliseconds + * @throws HttpException if a connection does not become available in + * 'timeout' milliseconds */ - private HttpConnection getConnection( - HostConnectionPool connectionPool, - HostConfiguration hostConfiguration, - long timeout - ) throws HttpException { + private HttpConnection getConnection(HostConnectionPool connectionPool, + HostConfiguration hostConfiguration, long timeout) throws HttpException { HttpConnection connection = null; - synchronized( connectionPool ) { + synchronized (connectionPool) { // keep trying until a connection is available, should happen at // most twice - while ( connection == null ) { + while (connection == null) { if (connectionPool.freeConnections.size() > 0) { - connection = (HttpConnection)connectionPool.freeConnections.removeFirst(); + connection = (HttpConnection) connectionPool + .freeConnections.removeFirst(); } else { // get number of connections hostConfig if (connectionPool.numConnections < maxConnections) { // Create a new connection - connection = new HttpConnection( hostConfiguration ); - connection.setHttpConnectionManager( this ); + connection = new HttpConnection(hostConfiguration); + connection.setHttpConnectionManager(this); connectionPool.numConnections++; // add a weak reference to this connection - referenceToHostConfig.put( - new WeakReference( connection, referenceQueue ), - hostConfiguration - ); + referenceToHostConfig.put(new WeakReference(connection, referenceQueue), + hostConfiguration); } else { @@ -230,7 +236,7 @@ threadTimeout.start(); try { - log.debug( + LOG.debug( "HttpConnectionManager.getConnection: waiting for " + "connection from " + connectionPool ); @@ -258,7 +264,7 @@ * @return a pool (list) of connections available for the given config */ private HostConnectionPool getConnectionPool(HostConfiguration hostConfiguration) { - log.trace("enter HttpConnectionManager.getConnections(String)"); + LOG.trace("enter HttpConnectionManager.getConnections(String)"); // Look for a list of connections for the given config HostConnectionPool listConnections = null; @@ -280,10 +286,10 @@ * @return the number of connections in use */ public int getConnectionsInUse(HostConfiguration hostConfiguration) { - log.trace("enter HttpConnectionManager.getConnectionsInUse(String)"); + LOG.trace("enter HttpConnectionManager.getConnectionsInUse(String)"); HostConnectionPool connectionPool = getConnectionPool(hostConfiguration); - synchronized( connectionPool ) { + synchronized (connectionPool) { return connectionPool.numConnections; } @@ -297,42 +303,32 @@ * @param conn the HttpConnection to make available. */ public void releaseConnection(HttpConnection conn) { - log.trace("enter HttpConnectionManager.releaseConnection(HttpConnection)"); + LOG.trace("enter HttpConnectionManager.releaseConnection(HttpConnection)"); // make sure that the response has been read. SimpleHttpConnectionManager.finishLastResponse(conn); HostConfiguration connectionConfiguration = new HostConfiguration(); - connectionConfiguration.setHost( - conn.getHost(), - conn.getPort(), - conn.getProtocol() - ); - if ( conn.getProxyHost() != null ) { - connectionConfiguration.setProxy( - conn.getProxyHost(), - conn.getProxyPort() - ); - } - - if(log.isDebugEnabled()){ - log.debug( - "HttpConnectionManager.releaseConnection: Release connection for " - + connectionConfiguration - ); + connectionConfiguration.setHost(conn.getHost(), + conn.getPort(), conn.getProtocol()); + if (conn.getProxyHost() != null) { + connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort()); } - HostConnectionPool listConnections = getConnectionPool( - connectionConfiguration - ); - synchronized(listConnections){ + if (LOG.isDebugEnabled()) { + LOG.debug("HttpConnectionManager.releaseConnection: Release connection for " + + connectionConfiguration); + } + + final HostConnectionPool listConnections + = getConnectionPool(connectionConfiguration); + synchronized (listConnections) { // Put the connect back in the available list and notify a waiter listConnections.freeConnections.addFirst(conn); - if ( listConnections.numConnections == 0 ) { + if (listConnections.numConnections == 0) { // for some reason this connection pool didn't already exist - log.error( - "connection pool not found for: " + connectionConfiguration - ); + LOG.error("connection pool not found for: " + + connectionConfiguration); listConnections.numConnections = 1; } listConnections.notify(); @@ -344,10 +340,11 @@ * of created connections. */ private class HostConnectionPool { - - public LinkedList freeConnections = new LinkedList(); - public int numConnections = 0; - + /** The list of free connections */ + private LinkedList freeConnections = new LinkedList(); + + /** The number of created connections */ + private int numConnections = 0; } /** @@ -356,32 +353,35 @@ */ private class ReferenceQueueThread extends Thread { + /** + * Create an instance and make this a daemon thread. + */ public ReferenceQueueThread() { setDaemon(true); } /** - * @see java.lang.Runnable#run() + * Start execution. */ public void run() { - while(true) { + while (true) { try { Reference ref = referenceQueue.remove(); - if ( ref != null ) { + if (ref != null) { HostConfiguration config = (HostConfiguration) referenceToHostConfig.get(ref); referenceToHostConfig.remove(ref); HostConnectionPool connectionPool = getConnectionPool(config); - synchronized( connectionPool ) { + synchronized (connectionPool) { connectionPool.numConnections--; connectionPool.notify(); } } } catch (InterruptedException e) { - log.debug("ReferenceQueueThread interrupted", e); + LOG.debug("ReferenceQueueThread interrupted", e); } } @@ -391,52 +391,70 @@ } /** - * In getConnection, if the maximum number of connections has already - * been reached the call will block. This class is used to help provide - * a timeout facility for this wait. Because Java does not provide a way to - * determine if wait() returned due to a notify() or a timeout, we need - * an outside mechanism to interrupt the waiting thread after the specified + * In getConnection, if the maximum number of connections has already been + * reached the call will block. This class is used to help provide a + * timeout facility for this wait. Because Java does not provide a way to + * determine if wait() returned due to a notify() or a timeout, we need an + * outside mechanism to interrupt the waiting thread after the specified * timeout interval. */ private static class TimeoutThread extends Thread { + /** The timeout in milliseconds. */ private long timeout = 0; - private Thread thrdWakeup = null; - public void setTimeout(long timeout) - { + /** The thread that will be woken up after the specified timeout. */ + private Thread wakeupThread = null; + + /** + * Set the timeout + * @param timeout The timeout in milliseconds. + */ + public void setTimeout(long timeout) { this.timeout = timeout; } - public long getTimeout() - { + /** + * Return the timeout value in milliseconds. + * @return long The timeout. + */ + public long getTimeout() { return timeout; } - public void setWakeupThread(Thread thrdWakeup) - { - this.thrdWakeup = thrdWakeup; + /** + * Set the thread that will be woken up after the specified timeout. + * @param newWakeupThread The thread to be woken. + */ + public void setWakeupThread(Thread newWakeupThread) { + this.wakeupThread = newWakeupThread; } - public Thread getWakeupThread() - { - return thrdWakeup; + /** + * Return the thread that will be woken up after the specified timeout. + * @return Thread The thread to be woken. + */ + public Thread getWakeupThread() { + return wakeupThread; } + /** + * Start execution. + */ public void run() { - log.trace("TimeoutThread.run()"); - if(timeout == 0){ + LOG.trace("TimeoutThread.run()"); + if (timeout == 0) { return; } - if(thrdWakeup == null){ + if (wakeupThread == null) { return; } - try{ + try { sleep(timeout); - thrdWakeup.interrupt(); - }catch(InterruptedException e){ - log.debug("InterruptedException caught as expected"); + wakeupThread.interrupt(); + } catch (InterruptedException e) { + LOG.debug("InterruptedException caught as expected"); // This is expected } } Index: httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java,v retrieving revision 1.5 diff -u -r1.5 NTCredentials.java --- httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java 28 Jan 2003 04:40:21 -0000 1.5 +++ httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java 29 Jan 2003 22:21:19 -0000 @@ -67,6 +67,7 @@ *

Username and password {@link Credentials}.

* * @author Adrian Sutton + * @author Mike Bowler * * @version $Revision: 1.5 $ $Date: 2003/01/28 04:40:21 $ * @@ -94,6 +95,10 @@ /** * Constructor. + * @param userName The user name. + * @param password The password. + * @param host The host. + * @param domain The domain. */ public NTCredentials(String userName, String password, String host, String domain) { @@ -146,8 +151,12 @@ return this.host; } + /** + * Return a string representation of this object. + * @return A string represenation of this object. + */ public String toString() { - StringBuffer sbResult = new StringBuffer(super.toString()); + final StringBuffer sbResult = new StringBuffer(super.toString()); sbResult.append(":"); sbResult.append(this.host == null ? "null" : this.host); Index: httpclient/src/java/org/apache/commons/httpclient/NTLM.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NTLM.java,v retrieving revision 1.10 diff -u -r1.10 NTLM.java --- httpclient/src/java/org/apache/commons/httpclient/NTLM.java 28 Jan 2003 04:40:21 -0000 1.10 +++ httpclient/src/java/org/apache/commons/httpclient/NTLM.java 29 Jan 2003 22:21:19 -0000 @@ -89,42 +89,47 @@ * * @author Adrian Sutton * @author Jeff Dever + * @author Mike Bowler * * @version $Revision: 1.10 $ $Date: 2003/01/28 04:40:21 $ * @since 2.0 */ public final class NTLM { - private byte[] currResponse; - private int pos = 0; + /** The current response */ + private byte[] currentResponse; + + /** The current position */ + private int currentPosition = 0; /** Log object for this class. */ - private static final Log log = LogFactory.getLog(NTLM.class); - /** Character encoding */ - public static final String DEFAULT_CHARSET = "ASCII"; + private static final Log LOG = LogFactory.getLog(NTLM.class); + + /** Character encoding */ + public static final String DEFAULT_CHARSET = "ASCII"; //Initialize the security provider static { //TODO: do not use System properties - String secProviderName = System.getProperty( - "httpclient.security.provider", + final String secProviderName + = System.getProperty("httpclient.security.provider", "com.sun.crypto.provider.SunJCE"); try { java.security.Provider secProvider = (java.security.Provider) Class.forName(secProviderName).newInstance(); Security.addProvider(secProvider); } catch (ClassNotFoundException e) { - log.error("Specified security provider " + secProviderName + - " could not be found by the class loader", e); + LOG.error("Specified security provider " + secProviderName + + " could not be found by the class loader", e); } catch (ClassCastException e) { - log.error("Specified security provider " + secProviderName + - " is not of type java.security.Provider", e); + LOG.error("Specified security provider " + secProviderName + + " is not of type java.security.Provider", e); } catch (InstantiationException e) { - log.error("Specified security provider " + secProviderName + - " could not be instantiated", e); + LOG.error("Specified security provider " + secProviderName + + " could not be instantiated", e); } catch (IllegalAccessException e) { - log.error("Specified security provider " + secProviderName + - " does not allow access to the constructor", e); + LOG.error("Specified security provider " + secProviderName + + " does not allow access to the constructor", e); } } @@ -134,12 +139,16 @@ * @param message the message that was received from the server. * @param username the username to authenticate with. * @param password the password to authenticate with. + * @param host The host. * @param domain the NT domain to authenticate in. + * @return The response. + * @throws HttpException If the messages cannot be retrieved. */ public final String getResponseFor(String message, String username, String password, String host, String domain) throws HttpException { - String response = null; + + final String response; if (message == null || message.trim().equals("")) { response = getType1Message(host, domain); } else { @@ -149,9 +158,15 @@ return response; } + /** + * Return the cipher for the specified key. + * @param key The key. + * @return Cipher The cipher. + * @throws HttpException If the cipher cannot be retrieved. + */ private Cipher getCipher(byte[] key) throws HttpException { try { - Cipher ecipher = Cipher.getInstance("DES/ECB/NoPadding"); + final Cipher ecipher = Cipher.getInstance("DES/ECB/NoPadding"); key = setupKey(key); ecipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DES")); return ecipher; @@ -159,38 +174,47 @@ throw new HttpException("DES encryption is not available."); } catch (InvalidKeyException e) { throw new HttpException("Invalid key for DES encryption."); - } catch(NoSuchPaddingException e) { + } catch (NoSuchPaddingException e) { throw new HttpException( - "NoPadding option for DES is not available."); + "NoPadding option for DES is not available."); } } /** * Adds parity bits to the key. + * @param key56 The key + * @return The modified key. */ private byte[] setupKey(byte[] key56) { byte[] key = new byte[8]; - key[0] = (byte)((key56[0] >> 1) & 0xff); - key[1] = (byte)((((key56[0] & 0x01) << 6) | - (((key56[1] & 0xff)>>2) & 0xff)) & 0xff); - key[2] = (byte)((((key56[1] & 0x03) << 5) | - (((key56[2] & 0xff)>>3) & 0xff)) & 0xff); - key[3] = (byte)((((key56[2] & 0x07) << 4) | - (((key56[3] & 0xff)>>4) & 0xff)) & 0xff); - key[4] = (byte)((((key56[3] & 0x0f) << 3) | - (((key56[4] & 0xff)>>5) & 0xff)) & 0xff); - key[5] = (byte)((((key56[4] & 0x1f) << 2) | - (((key56[5] & 0xff)>>6) & 0xff)) & 0xff); - key[6] = (byte)((((key56[5] & 0x3f) << 1) | - (((key56[6] & 0xff)>>7) & 0xff)) & 0xff); - key[7] = (byte)(key56[6] & 0x7f); + key[0] = (byte) ((key56[0] >> 1) & 0xff); + key[1] = (byte) ((((key56[0] & 0x01) << 6) + | (((key56[1] & 0xff) >> 2) & 0xff)) & 0xff); + key[2] = (byte) ((((key56[1] & 0x03) << 5) + | (((key56[2] & 0xff) >> 3) & 0xff)) & 0xff); + key[3] = (byte) ((((key56[2] & 0x07) << 4) + | (((key56[3] & 0xff) >> 4) & 0xff)) & 0xff); + key[4] = (byte) ((((key56[3] & 0x0f) << 3) + | (((key56[4] & 0xff) >> 5) & 0xff)) & 0xff); + key[5] = (byte) ((((key56[4] & 0x1f) << 2) + | (((key56[5] & 0xff) >> 6) & 0xff)) & 0xff); + key[6] = (byte) ((((key56[5] & 0x3f) << 1) + | (((key56[6] & 0xff) >> 7) & 0xff)) & 0xff); + key[7] = (byte) (key56[6] & 0x7f); for (int i = 0; i < key.length; i++) { - key[i] = (byte)(key[i] << 1); + key[i] = (byte) (key[i] << 1); } return key; } + /** + * Encrypt the data. + * @param key The key. + * @param bytes The data + * @return byte[] The encrypted data + * @throws HttpException If {@link Cipher.doFinal(byte[])} fails + */ private byte[] encrypt(byte[] key, byte[] bytes) throws HttpException { Cipher ecipher = getCipher(key); @@ -210,8 +234,8 @@ * @param length the length of the response to prepare. */ private void prepareResponse(int length) { - currResponse = new byte[length]; - pos = 0; + currentResponse = new byte[length]; + currentPosition = 0; } /** @@ -219,8 +243,8 @@ * @param b the byte to add. */ private void addByte(byte b) { - currResponse[pos] = b; - pos++; + currentResponse[currentPosition] = b; + currentPosition++; } /** @@ -229,29 +253,36 @@ */ private void addBytes(byte[] bytes) { for (int i = 0; i < bytes.length; i++) { - currResponse[pos] = bytes[i]; - pos++; + currentResponse[currentPosition] = bytes[i]; + currentPosition++; } } /** - * Returns the response that has been generated after shrinking the - * array if required and base64 encodes the response. + * Returns the response that has been generated after shrinking the array if + * required and base64 encodes the response. + * @return The response as above. */ private String getResponse() { byte[] resp; - if (currResponse.length > pos) { - byte[] tmp = new byte[pos]; - for (int i = 0; i < pos; i++) { - tmp[i] = currResponse[i]; + if (currentResponse.length > currentPosition) { + byte[] tmp = new byte[currentPosition]; + for (int i = 0; i < currentPosition; i++) { + tmp[i] = currentResponse[i]; } resp = tmp; } else { - resp = currResponse; + resp = currentResponse; } return HttpConstants.getString(Base64.encode(resp)); } + /** + * TODO: Figure out what this method really does. + * @param host The host + * @param domain The domain + * @return String + */ private String getType1Message(String host, String domain) { host = host.toUpperCase(); domain = domain.toUpperCase(); @@ -260,57 +291,56 @@ int finalLength = 32 + hostBytes.length + domainBytes.length; prepareResponse(finalLength); - byte[] msg = new byte[finalLength]; // The initial id string. byte[] protocol = getBytes("NTLMSSP"); addBytes(protocol); - addByte((byte)0); + addByte((byte) 0); // Type - addByte((byte)1); - addByte((byte)0); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 1); + addByte((byte) 0); + addByte((byte) 0); + addByte((byte) 0); // Flags - addByte( (byte)6); - addByte( (byte)82); - addByte( (byte)0); - addByte( (byte)0); + addByte((byte) 6); + addByte((byte) 82); + addByte((byte) 0); + addByte((byte) 0); // Domain length (first time). int iDomLen = domainBytes.length; byte[] domLen = convertShort(iDomLen); - addByte( domLen[0]); - addByte( domLen[1]); + addByte(domLen[0]); + addByte(domLen[1]); // Domain length (second time). - addByte( domLen[0]); - addByte( domLen[1]); + addByte(domLen[0]); + addByte(domLen[1]); // Domain offset. byte[] domOff = convertShort(hostBytes.length + 32); - addByte( domOff[0]); - addByte( domOff[1]); - addByte( (byte)0); - addByte( (byte)0); + addByte(domOff[0]); + addByte(domOff[1]); + addByte((byte) 0); + addByte((byte) 0); // Host length (first time). byte[] hostLen = convertShort(hostBytes.length); - addByte( hostLen[0]); - addByte( hostLen[1]); + addByte(hostLen[0]); + addByte(hostLen[1]); // Host length (second time). - addByte( hostLen[0]); - addByte( hostLen[1]); + addByte(hostLen[0]); + addByte(hostLen[1]); // Host offset (always 32). byte[] hostOff = convertShort(32); - addByte( hostOff[0]); - addByte( hostOff[1]); - addByte( (byte)0); - addByte( (byte)0); + addByte(hostOff[0]); + addByte(hostOff[1]); + addByte((byte) 0); + addByte((byte) 0); // Host String. addBytes(hostBytes); @@ -324,13 +354,13 @@ /** * Extracts the server nonce out of the given message type 2. * - * @param msg the String containing the base64 encoded message. + * @param message the String containing the base64 encoded message. * @return an array of 8 bytes that the server sent to be used when * hashing the password. */ - private byte[] parseType2Message(String sMsg) { + private byte[] parseType2Message(String message) { // Decode the message first. - byte[] msg = Base64.decode(getBytes(sMsg)); + byte[] msg = Base64.decode(getBytes(message)); byte[] nonce = new byte[8]; // The nonce is the 8 bytes starting from the byte in position 24. for (int i = 0; i < 8; i++) { @@ -341,14 +371,20 @@ /** * Creates the type 3 message using the given server nonce. + * @param user The user. + * @param password The password. + * @param host The host. + * @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. */ private String getType3Message(String user, String password, String host, String domain, byte[] nonce) throws HttpException { - int nt_resp_len = 0; - int lm_resp_len = 24; + int ntRespLen = 0; + int lmRespLen = 24; domain = domain.toUpperCase(); host = host.toUpperCase(); user = user.toUpperCase(); @@ -358,16 +394,16 @@ int domainLen = domainBytes.length; int hostLen = hostBytes.length; int userLen = userBytes.length; - int finalLength = 64 + nt_resp_len + lm_resp_len + domainLen + - userLen + hostLen; + int finalLength = 64 + ntRespLen + lmRespLen + domainLen + + userLen + hostLen; prepareResponse(finalLength); byte[] ntlmssp = getBytes("NTLMSSP"); addBytes(ntlmssp); - addByte((byte)0); - addByte((byte)3); - addByte((byte)0); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 3); + addByte((byte) 0); + addByte((byte) 0); + addByte((byte) 0); // LM Resp Length (twice) addBytes(convertShort(24)); @@ -375,8 +411,8 @@ // LM Resp Offset addBytes(convertShort(finalLength - 24)); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 0); // NT Resp Length (twice) addBytes(convertShort(0)); @@ -384,8 +420,8 @@ // NT Resp Offset addBytes(convertShort(finalLength)); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 0); // Domain length (twice) addBytes(convertShort(domainLen)); @@ -393,8 +429,8 @@ // Domain offset. addBytes(convertShort(64)); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 0); // User Length (twice) addBytes(convertShort(userLen)); @@ -402,8 +438,8 @@ // User offset addBytes(convertShort(64 + domainLen)); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 0); // Host length (twice) addBytes(convertShort(hostLen)); @@ -413,19 +449,19 @@ addBytes(convertShort(64 + domainLen + userLen)); for (int i = 0; i < 6; i++) { - addByte((byte)0); + addByte((byte) 0); } // Message length addBytes(convertShort(finalLength)); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 0); + addByte((byte) 0); // Flags - addByte((byte)6); - addByte((byte)82); - addByte((byte)0); - addByte((byte)0); + addByte((byte) 6); + addByte((byte) 82); + addByte((byte) 0); + addByte((byte) 0); addBytes(domainBytes); addBytes(userBytes); @@ -437,14 +473,16 @@ /** * Creates the LANManager and NT response for the given password using the * given nonce. - * @param passw the password to create a hash for. + * @param password the password to create a hash for. * @param nonce the nonce sent by the server. + * @return The response. + * @throws HttpException If {@link #encrypt(byte[],byte[])} fails. */ private byte[] hashPassword(String password, byte[] nonce) throws HttpException { byte[] passw = getBytes(password.toUpperCase()); - byte[] lm_pw1 = new byte[7]; - byte[] lm_pw2 = new byte[7]; + byte[] lmPw1 = new byte[7]; + byte[] lmPw2 = new byte[7]; int len = passw.length; if (len > 7) { @@ -453,10 +491,10 @@ int idx; for (idx = 0; idx < len; idx++) { - lm_pw1[idx] = passw[idx]; + lmPw1[idx] = passw[idx]; } for (; idx < 7; idx++) { - lm_pw1[idx] = (byte)0; + lmPw1[idx] = (byte) 0; } len = passw.length; @@ -464,44 +502,52 @@ len = 14; } for (idx = 7; idx < len; idx++) { - lm_pw2[idx - 7] = passw[idx]; + lmPw2[idx - 7] = passw[idx]; } for (; idx < 14; idx++) { - lm_pw2[idx - 7] = (byte)0; + lmPw2[idx - 7] = (byte) 0; } // Create LanManager hashed Password - byte[] magic = {(byte)0x4B, (byte)0x47, (byte)0x53, (byte)0x21, (byte)0x40, (byte)0x23, (byte)0x24, (byte)0x25}; - - byte[] lm_hpw1; - lm_hpw1 = encrypt(lm_pw1, magic); - - byte[] lm_hpw2 = encrypt(lm_pw2, magic); - - byte[] lm_hpw = new byte[21]; - for (int i = 0; i < lm_hpw1.length; i++) { - lm_hpw[i] = lm_hpw1[i]; + byte[] magic = { + (byte) 0x4B, (byte) 0x47, (byte) 0x53, (byte) 0x21, + (byte) 0x40, (byte) 0x23, (byte) 0x24, (byte) 0x25 + }; + + byte[] lmHpw1; + lmHpw1 = encrypt(lmPw1, magic); + + byte[] lmHpw2 = encrypt(lmPw2, magic); + + byte[] lmHpw = new byte[21]; + for (int i = 0; i < lmHpw1.length; i++) { + lmHpw[i] = lmHpw1[i]; } - for (int i = 0; i < lm_hpw2.length; i++) { - lm_hpw[i + 8] = lm_hpw2[i]; + for (int i = 0; i < lmHpw2.length; i++) { + lmHpw[i + 8] = lmHpw2[i]; } for (int i = 0; i < 5; i++) { - lm_hpw[i + 16] = (byte)0; + lmHpw[i + 16] = (byte) 0; } // Create the responses. - byte[] lm_resp = new byte[24]; - calc_resp(lm_hpw, nonce, lm_resp); + byte[] lmResp = new byte[24]; + calcResp(lmHpw, nonce, lmResp); - return lm_resp; + return lmResp; } /** - * Takes a 21 byte array and treats it as 3 56-bit DES keys. The 8 - * byte plaintext is encrypted with each key and the resulting 24 - * bytes are stored in teh results array. + * Takes a 21 byte array and treats it as 3 56-bit DES keys. The 8 byte + * plaintext is encrypted with each key and the resulting 24 bytes are + * stored in the results array. + * + * @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. */ - private void calc_resp(byte[] keys, byte[] plaintext, byte[] results) + private void calcResp(byte[] keys, byte[] plaintext, byte[] results) throws HttpException { byte[] keys1 = new byte[7]; byte[] keys2 = new byte[7]; @@ -535,9 +581,9 @@ } /** - * Converts a given number to a two byte array in little endian - * order. + * Converts a given number to a two byte array in little endian order. * @param num the number to convert. + * @return The new array. */ private byte[] convertShort(int num) { byte[] val = new byte[2]; @@ -548,25 +594,24 @@ String low = hex.substring(2, 4); String high = hex.substring(0, 2); - val[0] = (byte)Integer.parseInt(low, 16); - val[1] = (byte)Integer.parseInt(high, 16); + val[0] = (byte) Integer.parseInt(low, 16); + val[1] = (byte) Integer.parseInt(high, 16); return val; } - - private static byte[] getBytes(final String s) - { - if (s == null) - { - throw new IllegalArgumentException("Parameter may not be null"); - } - try - { - return s.getBytes(DEFAULT_CHARSET); - } - catch(UnsupportedEncodingException unexpected_eexception) - { - throw new RuntimeException("NTLM requires ASCII support"); - } + /** + * Convert a string to a byte array. + * @param s The string + * @return byte[] The resulting byte array. + */ + private static byte[] getBytes(final String s) { + if (s == null) { + throw new IllegalArgumentException("Parameter may not be null"); + } + try { + return s.getBytes(DEFAULT_CHARSET); + } catch (UnsupportedEncodingException unexpectedEncodingException) { + throw new RuntimeException("NTLM requires ASCII support"); + } } } Index: httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java,v retrieving revision 1.12 diff -u -r1.12 NameValuePair.java --- httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java 28 Jan 2003 04:40:21 -0000 1.12 +++ httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java 29 Jan 2003 22:21:18 -0000 @@ -70,6 +70,7 @@ * * @author B.C. Holmes * @author Sean C. Sullivan + * @author Mike Bowler * * @version $Revision: 1.12 $ $Date: 2003/01/28 04:40:21 $ * @@ -83,17 +84,17 @@ * */ public NameValuePair() { - this(null,null); + this (null,null); } /** * Constructor. + * @param name The name. + * @param value The value. */ public NameValuePair(String name, String value) { - this.name = name; this.value = value; - } // ----------------------------------------------------- Instance Variables @@ -111,12 +112,10 @@ // ------------------------------------------------------------- Properties /** - * Name property setter. + * Set the name. * - * @param name - * + * @param name The new name * @see #getName() - * */ public void setName(String name) { this.name = name; @@ -124,12 +123,10 @@ /** - * Name property getter. + * Return the name. * - * @return String name - * + * @return String name The name * @see #setName(String) - * */ public String getName() { return name; @@ -137,12 +134,9 @@ /** - * Value property setter. + * Set the value. * - * @param value - * - * @see #getValue() - * + * @param value The new value. */ public void setValue(String value) { this.value = value; @@ -150,12 +144,9 @@ /** - * Value property getter. + * Return the current value. * - * @return String value - * - * @see #setValue(String) - * + * @return String value The current value. */ public String getValue() { return value; @@ -165,19 +156,20 @@ /** * Get a String representation of this pair. + * @return A string representation. */ public String toString() { return ("name=" + name + ", " + "value=" + value); } /** - * Test if the given object is equal to me. - * In this implementation, an object is - * equal to me iff it has the same runtime - * type and the name and value attributes - * are both equal (or ==). + * Test if the given object is equal to me. In this implementation, + * an object is equal to me iff it has the same runtime type and the + * name and value attributes are both equal (or + * ==). * * @param object the {@link Object} to compare to + * @return true if the objects are equal. */ public boolean equals(Object object) { if (this == object) { @@ -192,14 +184,14 @@ } /** - * hashCode. Returns a hash code for this object such - * that if a.{@link #equals equals}(b) then - * a.hashCode() == b.hashCode(). + * hashCode. Returns a hash code for this object such that if a.{@link + * #equals equals}(b) then a.hashCode() == b.hashCode(). + * @return The hash code. */ public int hashCode() { - return (this.getClass().hashCode() ^ - (null == name ? 0 : name.hashCode()) ^ - (null == value ? 0 : value.hashCode())); + return (this.getClass().hashCode() + ^ (null == name ? 0 : name.hashCode()) + ^ (null == value ? 0 : value.hashCode())); } /* Index: httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v retrieving revision 1.17 diff -u -r1.17 RequestOutputStream.java --- httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java 28 Jan 2003 04:40:21 -0000 1.17 +++ httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java 29 Jan 2003 22:21:19 -0000 @@ -77,6 +77,7 @@ * @author Remy Maucherat * @author Sean C. Sullivan * @author dIon Gillard + * @author Mike Bowler * @version $Revision: 1.17 $ $Date: 2003/01/28 04:40:21 $ * * @see ResponseInputStream @@ -115,10 +116,10 @@ // ------------------------------------------------------- Static Variables /** Log object for this class. */ - private static final Log log = LogFactory.getLog(RequestOutputStream.class); + private static final Log LOG = LogFactory.getLog(RequestOutputStream.class); /** Log for any wire messages. */ - private static final Log wireLog = LogFactory.getLog("httpclient.wire"); + private static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); // ----------------------------------------------------- Instance Variables @@ -178,7 +179,7 @@ * @throws IOException if an input or output exception occurred */ public void print(String s) throws IOException { - log.trace("enter RequestOutputStream.print(String)"); + LOG.trace("enter RequestOutputStream.print(String)"); if (s == null) { s = "null"; @@ -226,14 +227,14 @@ stream.write(CRLF, 0, CRLF.length); stream.write(b); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - if (wireLog.isDebugEnabled()) { - wireLog.debug(">> byte 1 \\r\\n (chunk length \"header\")"); - wireLog.debug(">> byte " + b + "\\r\\n (chunked byte)"); + if (WIRE_LOG.isDebugEnabled()) { + WIRE_LOG.debug(">> byte 1 \\r\\n (chunk length \"header\")"); + WIRE_LOG.debug(">> byte " + b + "\\r\\n (chunked byte)"); } } else { stream.write(b); - if (wireLog.isDebugEnabled()) { - wireLog.debug(">> byte " + b); + if (WIRE_LOG.isDebugEnabled()) { + WIRE_LOG.debug(">> byte " + b); } } } @@ -247,23 +248,23 @@ * @throws IOException when errors occur writing output */ public void write(byte[] b, int off, int len) throws IOException { - log.trace("enter RequestOutputStream.write(byte[], int, int)"); + LOG.trace("enter RequestOutputStream.write(byte[], int, int)"); if (useChunking) { byte chunkHeader[] = HttpConstants.getBytes(Integer.toHexString(len) + "\r\n"); stream.write(chunkHeader, 0, chunkHeader.length); stream.write(b, off, len); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - if (wireLog.isDebugEnabled()) { - wireLog.debug(">> byte(s)" + len + " \\r\\n (chunk length " + if (WIRE_LOG.isDebugEnabled()) { + WIRE_LOG.debug(">> byte(s)" + len + " \\r\\n (chunk length " + "\"header\")"); - wireLog.debug(">> \"" + new String(b, off, len) + WIRE_LOG.debug(">> \"" + new String(b, off, len) + "\"\\r\\n (chunked bytes)"); } } else { stream.write(b, off, len); - if (wireLog.isDebugEnabled() && len > 0) { - wireLog.debug(">> \"" + new String(b, off, len) + "\""); + if (WIRE_LOG.isDebugEnabled() && len > 0) { + WIRE_LOG.debug(">> \"" + new String(b, off, len) + "\""); } } } @@ -275,7 +276,7 @@ * @throws IOException if an error occurs closing the stream */ public void close() throws IOException { - log.trace("enter RequestOutputStream.close()"); + LOG.trace("enter RequestOutputStream.close()"); if (!closed) { try { @@ -284,10 +285,10 @@ stream.write(ZERO, 0, ZERO.length); stream.write(CRLF, 0, CRLF.length); stream.write(ENDCHUNK, 0, ENDCHUNK.length); - wireLog.debug(">> byte 0 \\r\\n\\r\\n (final chunk)"); + WIRE_LOG.debug(">> byte 0 \\r\\n\\r\\n (final chunk)"); } } catch (IOException ioe) { - log.debug("Unexpected exception caught when closing output " + LOG.debug("Unexpected exception caught when closing output " + " stream", ioe); throw ioe; } finally { Index: httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v retrieving revision 1.21 diff -u -r1.21 ResponseInputStream.java --- httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java 28 Jan 2003 04:40:21 -0000 1.21 +++ httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java 29 Jan 2003 22:21:18 -0000 @@ -75,6 +75,7 @@ * @author Remy Maucherat * @author Sean C. Sullivan * @author dIon Gillard + * @author Mike Bowler * @version $Revision: 1.21 $ $Date: 2003/01/28 04:40:21 $ * * @see RequestOutputStream @@ -85,10 +86,10 @@ // -------------------------------------------------------- Class Variables /** Log object for this class. */ - public static final Log log = LogFactory.getLog(ResponseInputStream.class); + public static final Log LOG = LogFactory.getLog(ResponseInputStream.class); /** Log for wire messages. */ - public static final Log wireLog = LogFactory.getLog("httpclient.wire"); + public static final Log WIRE_LOG = LogFactory.getLog("httpclient.wire"); // ----------------------------------------------------------- Constructors @@ -101,7 +102,7 @@ * */ public ResponseInputStream(InputStream stream, boolean chunked, int contentLength) { - log.trace("enter ResponseInputStream(InputStream, boolean, int)"); + LOG.trace("enter ResponseInputStream(InputStream, boolean, int)"); if (null == stream) { throw new NullPointerException("InputStream parameter is null"); @@ -122,17 +123,16 @@ */ public ResponseInputStream(InputStream stream, HttpMethod method) { super(); - log.trace("enter ResponseInputStream(InputStream, HttpMethod)"); + LOG.trace("enter ResponseInputStream(InputStream, HttpMethod)"); if (null == stream) { throw new NullPointerException("InputStream parameter is null"); } - if (null == method) { throw new NullPointerException("HttpMethod parameter is null"); } - + closed = false; count = 0; @@ -213,31 +213,35 @@ * any further attempt to read from this stream will throw an IOException. * If a content length has been set but not all of the bytes have yet been * consumed, the remaining bytes will be swallowed. + * + * @throws IOException If an IO problem occurs. */ public void close() throws IOException { - log.trace("enter ResponseInputStream.close()"); - /* + LOG.trace("enter ResponseInputStream.close()"); + /* // Xerces appears to doubly-close the input stream... if(closed) { throw new IOException("Stream is already closed"); } - */ + */ - //TODO: This close code is not very robust + //TODO: This close code is not very robust if (!closed) { try { if (chunk) { while (!endChunk) { int b = read(); - if (b < 0) + if (b < 0) { break; + } } } else { if (length > 0) { while (count < length) { int b = read(); - if (b < 0) + if (b < 0) { break; + } } } } @@ -262,20 +266,23 @@ * @param off The start offset into array b at which * the data is written * @param len The maximum number of bytes to read + * @return The number of bytes that were read. * * @exception IOException if an input/output error occurs */ public int read(byte b[], int off, int len) throws IOException { - log.trace("enter ResponseInputStream.read(byte, int, int)"); + LOG.trace("enter ResponseInputStream.read(byte, int, int)"); int avail = length - pos; - if ((avail == 0) && (!fillBuffer())) + if ((avail == 0) && (!fillBuffer())) { return (-1); + } avail = length - pos; - if (avail == 0) + if (avail == 0) { return (-1); + } int toCopy = avail; @@ -283,8 +290,9 @@ return (-1); } - if (avail > len) + if (avail > len) { toCopy = len; + } System.arraycopy(buffer, pos, b, off, toCopy); pos += toCopy; return toCopy; @@ -294,15 +302,16 @@ * Read and return a single byte from this input stream, or -1 if end of * file has been encountered. * + * @return The next byte in the stream or -1. * @exception IOException if an input/output error occurs */ - public int read() - throws IOException { - log.trace("enter ResponseInputStream.read()"); + public int read() throws IOException { + LOG.trace("enter ResponseInputStream.read()"); if (pos == length) { - if (!fillBuffer()) + if (!fillBuffer()) { return (-1); + } } return (buffer[pos++] & 0xff); @@ -314,17 +323,21 @@ /** * Fill the chunk buffer. + * @return true If successful + * @throws IOException If an IO problem occurs. */ private boolean fillBuffer() throws IOException { - log.trace("enter ResponseInputStream.fillBuffer()"); + LOG.trace("enter ResponseInputStream.fillBuffer()"); // Has this stream been closed? - if (closed) + if (closed) { return false; + } //throw new IOException("Stream is closed"); - if (endChunk) + if (endChunk) { return false; + } // Have we read the specified content length already? if ((contentLength >= 0) && (count >= contentLength)) { @@ -355,16 +368,17 @@ // Skipping trailing headers, if any String trailingLine = readLineFromStream(); - while (!trailingLine.equals("")) + while (!trailingLine.equals("")) { trailingLine = readLineFromStream(); + } endChunk = true; return false; } else { - if ((buffer == null) - || (length > buffer.length)) + if ((buffer == null) || (length > buffer.length)) { buffer = new byte[length]; + } // Now read the whole chunk into the buffer @@ -376,7 +390,7 @@ currentRead = stream.read(buffer, nbRead, length - nbRead); } catch (Throwable t) { - log.debug("Exception thrown reading chunk from response", t); + LOG.debug("Exception thrown reading chunk from response", t); throw new IOException(); } if (currentRead < 0) { @@ -386,19 +400,20 @@ } // Skipping the CRLF - String blank = readLineFromStream(); + readLineFromStream(); } } else { //not using chunking try { - if (buffer == null) + if (buffer == null) { buffer = new byte[4096]; + } length = stream.read(buffer); count += length; } catch (Throwable t) { - log.debug("Exception thrown reading from response", t); + LOG.debug("Exception thrown reading from response", t); throw new IOException(t.getMessage()); } @@ -419,7 +434,7 @@ */ private String readLineFromStream() throws IOException { - log.trace("enter ResponseInputStream.ReadLineFromStream()"); + LOG.trace("enter ResponseInputStream.ReadLineFromStream()"); StringBuffer sb = new StringBuffer(); while (true) { Index: httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java,v retrieving revision 1.8 diff -u -r1.8 SimpleHttpConnectionManager.java --- httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java 28 Jan 2003 04:40:21 -0000 1.8 +++ httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java 29 Jan 2003 22:21:19 -0000 @@ -76,11 +76,13 @@ * * @author Michael Becke * @author Eric Johnson + * @author Mike Bowler * * @since 2.0 */ public class SimpleHttpConnectionManager implements HttpConnectionManager { + /** The http connection */ private HttpConnection httpConnection; /** @@ -100,15 +102,16 @@ /** * @see org.apache.commons.httpclient.HttpConnectionManager#getConnection(HostConfiguration, long) */ - public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) { + public HttpConnection getConnection( + HostConfiguration hostConfiguration, long timeout) { Protocol protocol = hostConfiguration.getProtocol(); String host = hostConfiguration.getHost(); int port = hostConfiguration.getPort(); - if ( httpConnection == null ) { + if (httpConnection == null) { - if ( hostConfiguration.isProxySet() ) { + if (hostConfiguration.isProxySet()) { httpConnection = new HttpConnection( hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), @@ -124,11 +127,10 @@ // make sure the host and proxy are correct for this connection // close it and set the values if they are not - if ( - !hostConfiguration.hostEquals(httpConnection) - || !hostConfiguration.proxyEquals(httpConnection) - ) { - if ( httpConnection.isOpen() ) { + if (!hostConfiguration.hostEquals(httpConnection) + || !hostConfiguration.proxyEquals(httpConnection)) { + + if (httpConnection.isOpen()) { httpConnection.close(); } @@ -138,9 +140,7 @@ httpConnection.setProxyHost(hostConfiguration.getProxyHost()); httpConnection.setProxyPort(hostConfiguration.getProxyPort()); - - } - else { + } else { finishLastResponse(httpConnection); } } @@ -153,8 +153,9 @@ * @see org.apache.commons.httpclient.HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection) */ public void releaseConnection(HttpConnection conn) { - if (conn != httpConnection) + if (conn != httpConnection) { throw new IllegalStateException("Unexpected close on a different connection."); + } finishLastResponse(httpConnection); } @@ -163,15 +164,15 @@ * Since the same connection is about to be reused, make sure the * previous request was completely processed, and if not * consume it now. + * @param conn The connection */ static void finishLastResponse(HttpConnection conn) { InputStream lastResponse = conn.getLastResponseInputStream(); - if ( lastResponse != null) { + if (lastResponse != null) { conn.setLastResponseInputStream(null); try { lastResponse.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { //FIXME: badness - close to force reconnect. conn.close(); } Index: httpclient/src/java/org/apache/commons/httpclient/StatusLine.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java,v retrieving revision 1.7 diff -u -r1.7 StatusLine.java --- httpclient/src/java/org/apache/commons/httpclient/StatusLine.java 28 Jan 2003 04:40:21 -0000 1.7 +++ httpclient/src/java/org/apache/commons/httpclient/StatusLine.java 29 Jan 2003 22:21:18 -0000 @@ -83,6 +83,7 @@ * * @see HttpStatus * @author Jeff Dever + * @author Mike Bowler * @version $Id: StatusLine.java,v 1.7 2003/01/28 04:40:21 jsdever Exp $ * @since 2.0 */ @@ -120,9 +121,9 @@ //check validity of the Status-Line - if (! statusLine.startsWith("HTTP/")) { - throw new HttpException("Status-Line '" + statusLine + - "' does not start with HTTP/"); + if (!statusLine.startsWith("HTTP/")) { + throw new HttpException("Status-Line '" + statusLine + + "' does not start with HTTP/"); } //handle the HTTP-Version @@ -190,6 +191,10 @@ return reasonPhrase; } + /** + * Return a string representation of this object. + * @return a string represenation of this object. + */ public final String toString() { return statusLine; } Index: httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v retrieving revision 1.10 diff -u -r1.10 CookieSpecBase.java --- httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java 28 Jan 2003 22:09:48 -0000 1.10 +++ httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java 29 Jan 2003 22:21:19 -0000 @@ -445,8 +445,7 @@ "Illegal domain attribute \"" + cookie.getDomain() + "\". Domain of origin: \"" + host + "\""); } - } - else { + } else { if (!host.equals(cookie.getDomain())) { throw new MalformedCookieException( "Illegal domain attribute \"" + cookie.getDomain() @@ -601,8 +600,6 @@ path = PATH_DELIM; } host = host.toLowerCase(); - - StringBuffer value = new StringBuffer(); if (cookies.length <= 0) { return null; Index: httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java,v retrieving revision 1.10 diff -u -r1.10 RFC2109Spec.java --- httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java 28 Jan 2003 22:31:38 -0000 1.10 +++ httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java 29 Jan 2003 22:21:19 -0000 @@ -63,7 +63,6 @@ package org.apache.commons.httpclient.cookie; -import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.Cookie; @@ -177,7 +176,8 @@ + "\". Domain of origin: \"" + host + "\""); } // host minus domain may not contain any dots - String hostWithoutDomain = host.substring(0, host.length() - cookie.getDomain().length()); + String hostWithoutDomain = host.substring(0, host.length() + - cookie.getDomain().length()); if (hostWithoutDomain.indexOf('.') != -1) { throw new MalformedCookieException("Domain attribute \"" + cookie.getDomain() Index: httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java,v retrieving revision 1.9 diff -u -r1.9 TraceMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java 28 Jan 2003 22:25:29 -0000 1.9 +++ httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java 29 Jan 2003 22:21:20 -0000 @@ -79,6 +79,7 @@ * @see PutMethod * * @author Sean C. Sullivan + * @author Mike Bowler * * @since 2.0 * @@ -87,7 +88,7 @@ //~ Static variables/initializers ·········································· /** Log object for this class. */ - private static final Log log = LogFactory.getLog(TraceMethod.class); + private static final Log LOG = LogFactory.getLog(TraceMethod.class); //~ Constructors ··························································· Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java,v retrieving revision 1.11 diff -u -r1.11 UrlDeleteMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java 28 Jan 2003 22:25:29 -0000 1.11 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java 29 Jan 2003 22:21:20 -0000 @@ -74,11 +74,12 @@ * @deprecated use DeleteMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlDeleteMethod extends DeleteMethod implements HttpUrlMethod -{ +public class UrlDeleteMethod extends DeleteMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables + /** The URL */ private String url; /** @@ -92,6 +93,7 @@ /** * Path-setting constructor. * @param url the path of the request + * @throws MalformedURLException If the url is not valid. */ public UrlDeleteMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); @@ -104,18 +106,20 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url is not valid. */ public void setUrl(String url) throws MalformedURLException { setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } /** - * Gets the Url. + * Gets the URL. + * @return The URL. */ public String getUrl() { return url; Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlGetMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlGetMethod.java,v retrieving revision 1.11 diff -u -r1.11 UrlGetMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlGetMethod.java 28 Jan 2003 22:25:29 -0000 1.11 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlGetMethod.java 29 Jan 2003 22:21:20 -0000 @@ -77,31 +77,37 @@ * @deprecated use GetMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlGetMethod extends GetMethod implements HttpUrlMethod -{ +public class UrlGetMethod extends GetMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables + /** The URL */ private String url; /** * No-arg constructor. */ - public UrlGetMethod() - { + public UrlGetMethod() { super(); } /** - * + * Create an instance with the specified URL + * @param url The URL + * @throws MalformedURLException If the url isn't valid. */ - public UrlGetMethod(String url) throws MalformedURLException - { + public UrlGetMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); setUrl(url); } - public UrlGetMethod(String url, String tempDir) throws MalformedURLException - { + /** + * Create an instance with the specified URL and temporary directory. + * @param url The URL + * @param tempDir The temporary directory + * @throws MalformedURLException If the url isn't valid. + */ + public UrlGetMethod(String url, String tempDir) throws MalformedURLException { super(URIUtil.getPath(url), tempDir); setUrl(url); } @@ -111,10 +117,10 @@ * @param url the path of the request * @param tempDir the directory in which to store temporary files * @param tempFile the file (under tempDir) to buffer contents to - * @exception java.net.MalformedURLException + * @throws MalformedURLException If the url isn't valid. */ - public UrlGetMethod(String url, String tempDir, String tempFile) throws MalformedURLException - { + public UrlGetMethod(String url, String tempDir, String tempFile) + throws MalformedURLException { super(URIUtil.getPath(url), tempDir, tempFile); setUrl(url); } @@ -123,10 +129,10 @@ * Constructor. * @param url the path of the request * @param fileData the file to buffer contents to - * @exception java.net.MalformedURLException + * @throws MalformedURLException If the url isn't valid. */ - public UrlGetMethod(String url, File fileData) throws MalformedURLException - { + public UrlGetMethod(String url, File fileData) + throws MalformedURLException { super(URIUtil.getPath(url), fileData); setUrl(url); } @@ -137,13 +143,13 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url isn't valid. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { super.setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } @@ -153,8 +159,7 @@ * * @return the request's URL. */ - public String getUrl() - { + public String getUrl() { return url; } } Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlHeadMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlHeadMethod.java,v retrieving revision 1.11 diff -u -r1.11 UrlHeadMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlHeadMethod.java 28 Jan 2003 22:25:29 -0000 1.11 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlHeadMethod.java 29 Jan 2003 22:21:20 -0000 @@ -74,10 +74,11 @@ * @deprecated use HeadMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlHeadMethod extends HeadMethod implements HttpUrlMethod -{ +public class UrlHeadMethod extends HeadMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables + /** The URL */ private String url; /** @@ -91,9 +92,9 @@ /** * Path-setting constructor. * @param url the path of the request + * @throws MalformedURLException If the url isn't valid. */ - public UrlHeadMethod(String url) throws MalformedURLException - { + public UrlHeadMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); setUrl(url); } @@ -104,13 +105,13 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url isn't valid. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { super.setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } @@ -120,8 +121,7 @@ * * @return the request's URL. */ - public String getUrl() - { + public String getUrl() { return url; } } Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java,v retrieving revision 1.11 diff -u -r1.11 UrlOptionsMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java 28 Jan 2003 22:25:29 -0000 1.11 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java 29 Jan 2003 22:21:20 -0000 @@ -74,10 +74,11 @@ * @deprecated use OptionsMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlOptionsMethod extends OptionsMethod implements HttpUrlMethod -{ +public class UrlOptionsMethod extends OptionsMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables + /** The URL */ private String url; /** @@ -91,9 +92,9 @@ /** * Path-setting constructor. * @param url the path of the request + * @throws MalformedURLException If the url isn't valid. */ - public UrlOptionsMethod(String url) throws MalformedURLException - { + public UrlOptionsMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); setUrl(url); } @@ -104,13 +105,13 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url isn't valid. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { super.setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } @@ -120,8 +121,7 @@ * * @return the request's URL. */ - public String getUrl() - { + public String getUrl() { return url; } } Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlPostMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlPostMethod.java,v retrieving revision 1.10 diff -u -r1.10 UrlPostMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlPostMethod.java 28 Jan 2003 22:25:29 -0000 1.10 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlPostMethod.java 29 Jan 2003 22:21:20 -0000 @@ -74,27 +74,26 @@ * @deprecated use PostMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlPostMethod extends PostMethod implements HttpUrlMethod -{ +public class UrlPostMethod extends PostMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables + /** The URL */ private String url; /** * No-arg constructor. */ - public UrlPostMethod() - { + public UrlPostMethod() { super(); } /** * Path-setting constructor. * @param url the URL to request - * @exception java.net.MalformedURLException + * @throws MalformedURLException If the url isn't valid. */ - public UrlPostMethod(String url) throws MalformedURLException - { + public UrlPostMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); setUrl(url); } @@ -103,10 +102,9 @@ * Constructor. * @param url the URL to request * @param tempDir directory to store temp files in - * @exception java.net.MalformedURLException + * @throws MalformedURLException If the url isn't valid. */ - public UrlPostMethod(String url, String tempDir) throws MalformedURLException - { + public UrlPostMethod(String url, String tempDir) throws MalformedURLException { super(URIUtil.getPath(url), tempDir); setUrl(url); } @@ -116,10 +114,10 @@ * @param url the URL to request * @param tempDir directory to store temp files in * @param tempFile file to store temporary data in - * @exception java.net.MalformedURLException + * @throws MalformedURLException If the url isn't valid. */ - public UrlPostMethod(String url, String tempDir, String tempFile) throws MalformedURLException - { + public UrlPostMethod(String url, String tempDir, String tempFile) + throws MalformedURLException { super(URIUtil.getPath(url), tempDir, tempFile); setUrl(url); } @@ -130,13 +128,13 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url isn't valid. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { super.setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } @@ -146,8 +144,7 @@ * * @return the request's URL. */ - public String getUrl() - { + public String getUrl() { return url; } } Index: httpclient/src/java/org/apache/commons/httpclient/methods/UrlPutMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlPutMethod.java,v retrieving revision 1.11 diff -u -r1.11 UrlPutMethod.java --- httpclient/src/java/org/apache/commons/httpclient/methods/UrlPutMethod.java 28 Jan 2003 22:25:29 -0000 1.11 +++ httpclient/src/java/org/apache/commons/httpclient/methods/UrlPutMethod.java 29 Jan 2003 22:21:20 -0000 @@ -74,9 +74,9 @@ * @deprecated use PutMethod * * @author Marc A. Saegesser + * @author Mike Bowler */ -public class UrlPutMethod extends PutMethod implements HttpUrlMethod -{ +public class UrlPutMethod extends PutMethod implements HttpUrlMethod { // ----------------------------------------------------- Instance Variables private String url; @@ -91,6 +91,7 @@ /** * Path-setting constructor. * @param url the path of the request + * @throws MalformedURLException If the url isn't valid. */ public UrlPutMethod(String url) throws MalformedURLException { super(URIUtil.getPath(url)); @@ -103,13 +104,13 @@ * the underlying HttpMethod.setQueryString() is called. * * @param url - the URL for this request. + * @throws MalformedURLException If the url isn't valid. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQuery(url); - if(query != null && query.length() > 0){ + if (query != null && query.length() > 0) { super.setQueryString(query); } } @@ -119,8 +120,7 @@ * * @return the request's URL. */ - public String getUrl() - { + public String getUrl() { return url; } Index: httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java,v retrieving revision 1.6 diff -u -r1.6 FilePartSource.java --- httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java 28 Jan 2003 22:25:31 -0000 1.6 +++ httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java 29 Jan 2003 22:21:20 -0000 @@ -152,6 +152,7 @@ /** * Return a new {@link FileInputStream} for the current filename. * @return the new input stream. + * @throws IOException If an IO problem occurs. * @see PartSource#createInputStream() */ public InputStream createInputStream() throws IOException { Index: httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java,v retrieving revision 1.3 diff -u -r1.3 Protocol.java --- httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java 23 Jan 2003 22:48:21 -0000 1.3 +++ httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java 29 Jan 2003 22:21:19 -0000 @@ -80,12 +80,14 @@ * * @author Michael Becke * @author Jeff Dever + * @author Mike Bowler * * @since 2.0 */ public class Protocol { - private static Map protocols = Collections.synchronizedMap( new HashMap() ); + /** The available protocols */ + private static final Map PROTOCOLS = Collections.synchronizedMap(new HashMap()); /** * Registers a new protocol with the given identifier. If a protocol with @@ -97,17 +99,16 @@ * * @see #getProtocol(String) */ - public static void registerProtocol( String id, Protocol protocol ) { + public static void registerProtocol(String id, Protocol protocol) { - if ( id == null ) { - throw new IllegalArgumentException( "id is null" ); + if (id == null) { + throw new IllegalArgumentException("id is null"); } - if ( protocol == null ) { - throw new IllegalArgumentException( "protocol is null" ); + if (protocol == null) { + throw new IllegalArgumentException("protocol is null"); } - protocols.put( id, protocol ); - + PROTOCOLS.put(id, protocol); } /** @@ -115,14 +116,13 @@ * * @param id the ID of the protocol to remove */ - public static void unregisterProtocol( String id ) { + public static void unregisterProtocol(String id) { - if ( id == null ) { - throw new IllegalArgumentException( "id is null" ); + if (id == null) { + throw new IllegalArgumentException("id is null"); } - protocols.remove( id ); - + PROTOCOLS.remove(id); } /** @@ -134,20 +134,20 @@ * * @throws IllegalStateException if a protocol with the ID cannot be found */ - public static Protocol getProtocol( String id ) { + public static Protocol getProtocol(String id) + throws IllegalStateException { - if ( id == null ) { - throw new IllegalArgumentException( "id is null" ); + if (id == null) { + throw new IllegalArgumentException("id is null"); } - Protocol protocol = (Protocol)protocols.get( id ); + Protocol protocol = (Protocol) PROTOCOLS.get(id); - if ( protocol == null ) { + if (protocol == null) { protocol = lazyRegisterProtocol(id); } return protocol; - } /** @@ -159,40 +159,37 @@ * * @throws IllegalStateException if the protocol with id is not recognized */ - private static Protocol lazyRegisterProtocol(String id) { + private static Protocol lazyRegisterProtocol(String id) + throws IllegalStateException { if ("http".equals(id)) { - Protocol HTTP = new Protocol( - "http", - new DefaultProtocolSocketFactory(), - 80 - ); - Protocol.registerProtocol( "http", HTTP ); - return HTTP; + final Protocol http + = new Protocol("http", new DefaultProtocolSocketFactory(), 80); + Protocol.registerProtocol("http", http); + return http; } if ("https".equals(id)) { - Protocol HTTPS = new Protocol( - "https", - new SSLProtocolSocketFactory(), - 443 - ); - Protocol.registerProtocol( "https", HTTPS ); - return HTTPS; + final Protocol https + = new Protocol("https", new SSLProtocolSocketFactory(), 443); + Protocol.registerProtocol("https", https); + return https; } - throw new IllegalStateException( "unsupported protocol: '" + id + "'"); - + throw new IllegalStateException("unsupported protocol: '" + id + "'"); } /** the scheme of this protocol (e.g. http, https) */ private String scheme; + /** The socket factory for this protocol */ private ProtocolSocketFactory socketFactory; + /** The default port for this protocol */ private int defaultPort; + /** True if this protocol is secure */ private boolean secure; /** @@ -203,23 +200,22 @@ * this protocol * @param defaultPort the port this protocol defaults to */ - public Protocol( String scheme, ProtocolSocketFactory factory, int defaultPort ) { + public Protocol(String scheme, ProtocolSocketFactory factory, int defaultPort) { - if ( scheme == null ) { - throw new IllegalArgumentException( "scheme is null" ); + if (scheme == null) { + throw new IllegalArgumentException("scheme is null"); } - if ( factory == null ) { - throw new IllegalArgumentException( "socketFactory is null" ); + if (factory == null) { + throw new IllegalArgumentException("socketFactory is null"); } - if ( defaultPort <= 0 ) { - throw new IllegalArgumentException( "port is invalid: " + defaultPort ); + if (defaultPort <= 0) { + throw new IllegalArgumentException("port is invalid: " + defaultPort); } this.scheme = scheme; this.socketFactory = factory; this.defaultPort = defaultPort; this.secure = false; - } /** @@ -230,23 +226,23 @@ * this protocol * @param defaultPort the port this protocol defaults to */ - public Protocol( String scheme, SecureProtocolSocketFactory factory, int defaultPort ) { + public Protocol(String scheme, + SecureProtocolSocketFactory factory, int defaultPort) { - if ( scheme == null ) { - throw new IllegalArgumentException( "scheme is null" ); + if (scheme == null) { + throw new IllegalArgumentException("scheme is null"); } - if ( factory == null ) { - throw new IllegalArgumentException( "socketFactory is null" ); + if (factory == null) { + throw new IllegalArgumentException("socketFactory is null"); } - if ( defaultPort <= 0 ) { - throw new IllegalArgumentException( "port is invalid: " + defaultPort ); + if (defaultPort <= 0) { + throw new IllegalArgumentException("port is invalid: " + defaultPort); } this.scheme = scheme; this.socketFactory = factory; this.defaultPort = defaultPort; this.secure = true; - } /** @@ -268,15 +264,15 @@ /** * Returns the scheme. - * @return String + * @return The scheme */ public String getScheme() { return scheme; } /** - * Returns the secure. - * @return boolean + * Returns true if this protocol is secure + * @return true if this protocol is secure */ public boolean isSecure() { return secure; @@ -290,32 +286,34 @@ * * @return the given port or the defaultPort */ - public int resolvePort( int port ) { + public int resolvePort(int port) { return port <= 0 ? getDefaultPort() : port; } /** - * @see java.lang.Object#toString() + * Return a string representation of this object. + * @return a string representation of this object. */ public String toString() { return scheme + ":" + defaultPort; } /** - * @see java.lang.Object#equals(java.lang.Object) + * Return true if the specified object equals this object. + * @param obj The object to compare against. + * @return true if the objects are equal. */ public boolean equals(Object obj) { - if ( obj instanceof Protocol ) { + if (obj instanceof Protocol) { - Protocol p = (Protocol)obj; + Protocol p = (Protocol) obj; return ( defaultPort == p.getDefaultPort() - && scheme.equalsIgnoreCase( p.getScheme() ) + && scheme.equalsIgnoreCase(p.getScheme()) && secure == p.isSecure() - && socketFactory.equals( p.getSocketFactory() ) - ); + && socketFactory.equals(p.getSocketFactory())); } else { return false; @@ -324,10 +322,10 @@ } /** - * @see java.lang.Object#hashCode() + * Return a hash code for this object + * @return The hash code. */ public int hashCode() { return scheme.hashCode(); } - } Index: httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java,v retrieving revision 1.3 diff -u -r1.3 ProtocolSocketFactory.java --- httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java 23 Jan 2003 22:48:21 -0000 1.3 +++ httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java 29 Jan 2003 22:21:19 -0000 @@ -73,6 +73,7 @@ * @see Protocol * * @author Michael Becke + * @author Mike Bowler * * @since 2.0 */ @@ -92,7 +93,7 @@ * @throws UnknownHostException if the IP address of the host cannot be * determined */ - public Socket createSocket( + Socket createSocket( String host, int port, InetAddress clientHost, @@ -111,7 +112,7 @@ * @throws UnknownHostException if the IP address of the host cannot be * determined */ - public Socket createSocket( + Socket createSocket( String host, int port ) throws IOException, UnknownHostException; Index: httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java,v retrieving revision 1.3 diff -u -r1.3 SSLProtocolSocketFactory.java --- httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java 23 Jan 2003 22:48:21 -0000 1.3 +++ httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java 29 Jan 2003 22:21:20 -0000 @@ -73,6 +73,7 @@ * A SecureProtocolSocketFactory that uses JSSE to create sockets. * * @author Michael Becke + * @author Mike Bowler * * @since 2.0 */ @@ -122,7 +123,7 @@ int port, boolean autoClose) throws IOException, UnknownHostException { - return ((SSLSocketFactory)SSLSocketFactory.getDefault()).createSocket( + return ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket( socket, host, port, Index: httpclient/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java,v retrieving revision 1.2 diff -u -r1.2 SecureProtocolSocketFactory.java --- httpclient/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java 23 Jan 2003 22:48:21 -0000 1.2 +++ httpclient/src/java/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java 29 Jan 2003 22:21:19 -0000 @@ -72,7 +72,7 @@ * @see org.apache.commons.httpclient.protocol.ProtocolSocketFactory * * @author Michael Becke - * + * @author Mike Bowler * @since 2.0 */ public interface SecureProtocolSocketFactory extends ProtocolSocketFactory { @@ -94,7 +94,7 @@ * @throws UnknownHostException if the IP address of the host cannot be * determined */ - public Socket createSocket( + Socket createSocket( Socket socket, String host, int port,