You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rw...@apache.org on 2009/02/07 12:05:43 UTC

svn commit: r741874 - in /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net: SocketClient.java ftp/FTPClient.java ftp/FTPReply.java ftp/FTPSClient.java ftp/FTPSCommand.java ftp/FTPSServerSocketFactory.java

Author: rwinston
Date: Sat Feb  7 11:05:43 2009
New Revision: 741874

URL: http://svn.apache.org/viewvc?rev=741874&view=rev
Log:
Some FTPS javadoc changes ; add error code 522

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPClient.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPReply.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java Sat Feb  7 11:05:43 2009
@@ -63,6 +63,7 @@
     private static final SocketFactory __DEFAULT_SOCKET_FACTORY =
             SocketFactory.getDefault();
     
+    /** The default {@link ServerSocketFactory} */
     private static final ServerSocketFactory __DEFAULT_SERVER_SOCKET_FACTORY = 
             ServerSocketFactory.getDefault();
 
@@ -578,9 +579,16 @@
     public int getConnectTimeout() {
         return connectTimeout;
     }
-    
-    
-    
+
+    /**
+     * Get the underlying {@link ServerSocketFactory}
+     * @return The server socket factory
+     * @since 2.1
+     */
+	public ServerSocketFactory getServerSocketFactory() {
+		return _serverSocketFactory_;
+	}
+	
 }
 
 

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPClient.java Sat Feb  7 11:05:43 2009
@@ -2293,6 +2293,7 @@
 
         FTPListParseEngine engine = new FTPListParseEngine(parser);
 
+        // TODO is this the correct thing to do? Should we throw an exception here?
         if ((socket = _openDataConnection_(FTPCommand.LIST, getListArguments(pathname))) == null)
         {
             return engine;

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPReply.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPReply.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPReply.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPReply.java Sat Feb  7 11:05:43 2009
@@ -27,6 +27,7 @@
  * <p>
  * <p>
  * @author Daniel F. Savarese
+ * TODO replace with an enum
  ***/
 
 public final class FTPReply
@@ -124,6 +125,8 @@
     public static final int CODE_335 = 335;
     /** @since 2.0 */
     public static final int CODE_431 = 431;
+    /** @since 2.1 */
+    public static final int CODE_522 = 522;
     /** @since 2.0 */
     public static final int CODE_533 = 533;
     /** @since 2.0 */
@@ -143,6 +146,8 @@
     public static final int SECURITY_DATA_IS_ACCEPTABLE = CODE_335;
     /** @since 2.0 */
     public static final int UNAVAILABLE_RESOURCE = CODE_431;
+    /** @since 2.1 */
+    public static final int BAD_TLS_NEGOTIATION_OR_DATA_ENCRYPTION_REQUIRED = CODE_522;
     /** @since 2.0 */
     public static final int DENIED_FOR_POLICY_REASONS = CODE_533;
     /** @since 2.0 */

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSClient.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSClient.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSClient.java Sat Feb  7 11:05:43 2009
@@ -29,7 +29,6 @@
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocket;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
@@ -68,7 +67,7 @@
     /** The context object. */
     private SSLContext context;
     /** The socket object. */
-    private Socket planeSocket;
+    private Socket plainSocket;
     /** The established socket flag. */
     private boolean isCreation = true;
     /** The use client mode flag. */
@@ -217,9 +216,7 @@
      * @throws IOException A handicap breaks out by sever negotiation.
      */
     private void sslNegotiation() throws IOException {
-        // Evacuation not ssl socket.
-        planeSocket = _socket_;
-        
+        plainSocket = _socket_;
         initSslContext();
 
         SSLSocketFactory ssf = context.getSocketFactory();
@@ -271,9 +268,11 @@
         this.isCreation = isCreation;
     }
 
-    /**
+	/**
      * Returns true if new SSL sessions may be established by this socket.
-     * When a socket does not have a ssl socket, This return False.
+     * When the underlying {@link Socket} instance is not SSL-enabled (i.e. an
+     * instance of {@link SSLSocket} with {@link SSLSocket}{@link #getEnableSessionCreation()}) enabled,
+     * this returns False.
      * @return true - Indicates that sessions may be created;
      * this is the default. 
      * false - indicates that an existing session must be resumed.
@@ -294,7 +293,7 @@
 
     /**
      * Returns true if the socket will require client authentication.
-     * When a socket does not have a ssl socket, This return False.
+     * When the underlying {@link Socket} is not an {@link SSLSocket} instance, returns false.
      * @return true - If the server mode socket should request 
      * that the client authenticate itself.
      */
@@ -316,7 +315,7 @@
 
     /**
      * Returns true if the socket will request client authentication.
-     * When a socket does not have a ssl socket, This return False.
+     * When the underlying {@link Socket} is not an {@link SSLSocket} instance, returns false.
      * @return true - If the server mode socket should request 
      * that the client authenticate itself.
      */
@@ -338,7 +337,7 @@
     /**
      * Returns true if the socket is set to use client mode 
      * in its first handshake.
-     * When a socket does not have a ssl socket, This return False.
+     * When the underlying {@link Socket} is not an {@link SSLSocket} instance, returns false.
      * @return true - If the socket should start its first handshake 
      * in "client" mode.
      */
@@ -350,7 +349,7 @@
 
     /**
      * Controls which particular cipher suites are enabled for use on this 
-     * connection. I perform setting before a server negotiation.
+     * connection. Called before server negotiation.
      * @param cipherSuites The cipher suites.
      */
     public void setEnabledCipherSuites(String[] cipherSuites) {
@@ -361,7 +360,7 @@
     /**
      * Returns the names of the cipher suites which could be enabled 
      * for use on this connection.
-     * When a socket does not have a ssl socket, This return null.
+     * When the underlying {@link Socket} is not an {@link SSLSocket} instance, returns false.
      * @return An array of cipher suite names.
      */
     public String[] getEnabledCipherSuites() {
@@ -383,7 +382,7 @@
     /**
      * Returns the names of the protocol versions which are currently 
      * enabled for use on this connection.
-     * When a socket does not have a ssl socket, This return null.
+     * When the underlying {@link Socket} is not an {@link SSLSocket} instance, returns false.
      * @return An array of protocols.
      */
     public String[] getEnabledProtocols() {
@@ -395,8 +394,8 @@
     /**
      * PBSZ command. pbsz value: 0 to (2^32)-1 decimal integer.
      * @param pbsz Protection Buffer Size.
-     * @throws SSLException If it server reply code not equal "200".
-     * @throws IOException If an I/O error occurs while either sending 
+     * @throws SSLException If the server reply code does not equal "200".
+     * @throws IOException If an I/O error occurs while sending 
      * the command.
      */
     public void execPBSZ(long pbsz) throws SSLException, IOException {
@@ -414,8 +413,8 @@
      * E - Confidential(SSL protocol only)</br>
      * P - Private
      * @param prot Data Channel Protection Level.
-     * @throws SSLException If it server reply code not equal "200".
-     * @throws IOException If an I/O error occurs while either sending 
+     * @throws SSLException If the server reply code does not equal "200".
+     * @throws IOException If an I/O error occurs while sending 
      * the command.
      */
     public void execPROT(String prot) throws SSLException, IOException {
@@ -436,7 +435,7 @@
     }
 
     /**
-     * I check the value that I can set in PROT Command value.
+     * Check the value that can be set in PROT Command value.
      * @param prot Data Channel Protection Level.
      * @return True - A set point is right / False - A set point is not right
      */
@@ -448,12 +447,12 @@
     }
 
     /**
-     * I carry out an ftp command.
-     * When a CCC command was carried out, I steep socket and SocketFactory 
-     * in a state of not ssl.
-     * @parm command ftp command.
+     * Send an FTP command.
+     * The CCC (Clear Command Channel) command causes the underlying {@link SSLSocket} instance  to be assigned 
+     * to a plain {@link Socket} instances
+     * @param command The FTP command.
      * @return server reply.
-     * @throws IOException If an I/O error occurs while either sending 
+     * @throws IOException If an I/O error occurs while sending 
      * the command.
      * @see org.apache.commons.net.ftp.FTP#sendCommand(java.lang.String)
      */
@@ -462,8 +461,7 @@
         int repCode = super.sendCommand(command, args);
         if (FTPSCommand._commands[FTPSCommand.CCC].equals(command)) {
             if (FTPReply.COMMAND_OK == repCode) {
-                    // TODO Check this - is this necessary at all?
-                _socket_ = planeSocket;
+                _socket_ = plainSocket;
                 setSocketFactory(null);
             } else {
                 throw new SSLException(getReplyString());
@@ -475,11 +473,11 @@
     /**
      * Returns a socket of the data connection. 
      * Wrapped as an {@link SSLSocket}, which carries out handshake processing.
-     * @pram command The text representation of the FTP command to send.
+     * @param command The textual representation of the FTP command to send.
      * @param arg The arguments to the FTP command. 
      * If this parameter is set to null, then the command is sent with 
-     * no argument.
-     * @return A Socket corresponding to the established data connection. 
+     * no arguments.
+     * @return corresponding to the established data connection. 
      * Null is returned if an FTP protocol error is reported at any point 
      * during the establishment and initialization of the connection.
      * @throws IOException If there is any problem with the connection.
@@ -523,8 +521,5 @@
      */
     public void setTrustManager(TrustManager trustManager) {
         this.trustManager = trustManager;
-    }
-    
-    
-    
+    }    
 }

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java Sat Feb  7 11:05:43 2009
@@ -18,7 +18,7 @@
 package org.apache.commons.net.ftp;
 
 /**
- * I acquire a command added in FTPS.
+ * FTPS-specific command
  * @since 2.0
  */
 public final class FTPSCommand {

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java?rev=741874&r1=741873&r2=741874&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java Sat Feb  7 11:05:43 2009
@@ -30,6 +30,7 @@
  */
 public class FTPSServerSocketFactory extends ServerSocketFactory {
     
+	/** Factory for secure socket factories */
     private SSLContext context;
     
     public FTPSServerSocketFactory(SSLContext context) {
@@ -37,15 +38,15 @@
     }
     
     public ServerSocket createServerSocket(int port) throws IOException {
-        return this.init(this.context.getServerSocketFactory().createServerSocket(port));
+        return init(this.context.getServerSocketFactory().createServerSocket(port));
     }
 
     public ServerSocket createServerSocket(int port, int backlog) throws IOException {
-        return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog));
+        return 	init(this.context.getServerSocketFactory().createServerSocket(port, backlog));
     }
 
     public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
-        return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
+    	return init(this.context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
     }
         
     public ServerSocket init(ServerSocket socket) throws IOException {