commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r438459 - in /jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net: ./ bsd/ ftp/
Date Wed, 30 Aug 2006 11:04:27 GMT
Author: rwinston
Date: Wed Aug 30 04:04:26 2006
New Revision: 438459

URL: http://svn.apache.org/viewvc?rev=438459&view=rev
Log:
* Refactor SocketClient to use JDK SocketClient
* DatagramSocketClient still uses commons-net impl
* Added default ServerSocketFactory
* Merged FTPSReply.java into FTPReply.java and removed

Removed:
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSReply.java
Modified:
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/SocketClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RExecClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPReply.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/DefaultSocketFactory.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Wed Aug 30 04:04:26 2006
@@ -21,6 +21,8 @@
 import java.net.Socket;
 import java.net.UnknownHostException;
 
+import javax.net.SocketFactory;
+
 /***
  * DefaultSocketFactory implements the SocketFactory interface by
  * simply wrapping the java.net.Socket and java.net.ServerSocket
@@ -35,7 +37,7 @@
  * @see SocketClient#setSocketFactory
  ***/
 
-public class DefaultSocketFactory implements SocketFactory
+public class DefaultSocketFactory extends SocketFactory
 {
 
     /***

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/SocketClient.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/SocketClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/SocketClient.java
Wed Aug 30 04:04:26 2006
@@ -22,6 +22,10 @@
 import java.net.Socket;
 import java.net.SocketException;
 
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+
 /**
  * The SocketClient provides the basic operations that are required of
  * client objects accessing sockets.  It is meant to be
@@ -53,7 +57,10 @@
 
     /** The default SocketFactory shared by all SocketClient instances. */
     private static final SocketFactory __DEFAULT_SOCKET_FACTORY =
-        new DefaultSocketFactory();
+    		SocketFactory.getDefault();
+    
+    private static final ServerSocketFactory __DEFAULT_SERVER_SOCKET_FACTORY = 
+    		ServerSocketFactory.getDefault();
 
     /** The timeout to use after opening a socket. */
     protected int _timeout_;
@@ -77,6 +84,8 @@
 
     /** The socket's SocketFactory. */
     protected SocketFactory _socketFactory_;
+    
+    protected ServerSocketFactory _serverSocketFactory_;
 
 
     /**
@@ -499,6 +508,21 @@
         else
             _socketFactory_ = factory;
     }
+    
+    /**
+     * Sets the ServerSocketFactory used by the SocketClient to open ServerSocket
+     * connections.  If the factory value is null, then a default
+     * factory is used (only do this to reset the factory after having
+     * previously altered it).
+     * <p>
+     * @param factory  The new ServerSocketFactory the SocketClient should use.
+     */
+    public void setServerSocketFactory(ServerSocketFactory factory) {
+		if (factory == null)
+			_serverSocketFactory_ = __DEFAULT_SERVER_SOCKET_FACTORY;
+		else
+			_serverSocketFactory_ = factory;
+	}
 }
 
 

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RCommandClient.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
Wed Aug 30 04:04:26 2006
@@ -118,7 +118,7 @@
         {
             try
             {
-                server = _socketFactory_.createServerSocket(localPort, 1,
+                server = _serverSocketFactory_.createServerSocket(localPort, 1,
                          getLocalAddress());
             }
             catch (SocketException e)

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RExecClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RExecClient.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RExecClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/bsd/RExecClient.java
Wed Aug 30 04:04:26 2006
@@ -86,7 +86,7 @@
         ServerSocket server;
         Socket socket;
 
-        server = _socketFactory_.createServerSocket(0, 1, getLocalAddress());
+        server = _serverSocketFactory_.createServerSocket(0, 1, getLocalAddress());
 
         _output_.write(Integer.toString(server.getLocalPort()).getBytes());
         _output_.write('\0');

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPClient.java
Wed Aug 30 04:04:26 2006
@@ -474,7 +474,7 @@
         if (__dataConnectionMode == ACTIVE_LOCAL_DATA_CONNECTION_MODE)
         {
             ServerSocket server;
-            server = _socketFactory_.createServerSocket(0, 1, getLocalAddress());
+            server = _serverSocketFactory_.createServerSocket(0, 1, getLocalAddress());
 
             if (!FTPReply.isPositiveCompletion(port(getLocalAddress(),
                                                     server.getLocalPort())))

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPReply.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPReply.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPReply.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPReply.java
Wed Aug 30 04:04:26 2006
@@ -110,6 +110,28 @@
     public static final int PAGE_TYPE_UNKNOWN = CODE_551;
     public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552;
     public static final int FILE_NAME_NOT_ALLOWED = CODE_553;
+    
+    // FTPS Reply Codes
+    public static final int CODE_234 = 234;
+    public static final int CODE_235 = 235;
+    public static final int CODE_334 = 334;
+    public static final int CODE_335 = 335;
+    public static final int CODE_431 = 431;
+    public static final int CODE_533 = 533;
+    public static final int CODE_534 = 534;
+    public static final int CODE_535 = 535;
+    public static final int CODE_536 = 536;
+    
+    public static final int SECURITY_DATA_EXCHANGE_COMPLETE = CODE_234;
+    public static final int SECURITY_DATA_EXCHANGE_SUCCESSFULLY = CODE_235;
+    public static final int SECURITY_MECHANISM_IS_OK = CODE_334;
+    public static final int SECURITY_DATA_IS_ACCEPTABLE = CODE_335;
+    public static final int UNAVAILABLE_RESOURCE = CODE_431;
+    public static final int DENIED_FOR_POLICY_REASONS = CODE_533;
+    public static final int REQUEST_DENIED = CODE_534;
+    public static final int FAILED_SECURITY_CHECK = CODE_535;
+    public static final int REQUESTED_PROT_LEVEL_NOT_SUPPORTED = CODE_536;
+    
 
     // Cannot be instantiated
     private FTPReply()

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
Wed Aug 30 04:04:26 2006
@@ -172,10 +172,10 @@
     private void execAUTH() throws SSLException, IOException {
         int replyCode = sendCommand(
                 FTPSCommand._commands[FTPSCommand.AUTH], auth);
-        if (FTPSReply.SECURITY_MECHANISM_IS_OK == replyCode) {
+        if (FTPReply.SECURITY_MECHANISM_IS_OK == replyCode) {
             // replyCode = 334
             // I carry out an ADAT command.
-        } else if (FTPSReply.SECURITY_DATA_EXCHANGE_COMPLETE != replyCode) {
+        } else if (FTPReply.SECURITY_DATA_EXCHANGE_COMPLETE != replyCode) {
             throw new SSLException(getReplyString());
         }
     }
@@ -356,7 +356,7 @@
     public void execPBSZ(long pbsz) throws SSLException, IOException {
         if (pbsz < 0 || 4294967295L < pbsz) 
             throw new IllegalArgumentException();
-        if (FTPSReply.COMMAND_OK != sendCommand(
+        if (FTPReply.COMMAND_OK != sendCommand(
                 FTPSCommand._commands[FTPSCommand.PBSZ],String.valueOf(pbsz)))
             throw new SSLException(getReplyString());
     }
@@ -375,7 +375,7 @@
     public void execPROT(String prot) throws SSLException, IOException {
         if (prot == null) prot = DEFAULT_PROT;
         if (!checkPROTValue(prot)) throw new IllegalArgumentException();
-        if (FTPSReply.COMMAND_OK != sendCommand(
+        if (FTPReply.COMMAND_OK != sendCommand(
                 FTPSCommand._commands[FTPSCommand.PROT], prot)) 
             throw new SSLException(getReplyString());
         if (DEFAULT_PROT.equals(prot)) {
@@ -410,7 +410,7 @@
     public int sendCommand(String command, String args) throws IOException {
         int repCode = super.sendCommand(command, args);
         if (FTPSCommand._commands[FTPSCommand.CCC].equals(command)) {
-            if (FTPSReply.COMMAND_OK == repCode) {
+            if (FTPReply.COMMAND_OK == repCode) {
             		// TODO Check this - is this necessary at all?
                 _socket_ = planeSocket;
                 setSocketFactory(null);

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java?rev=438459&r1=438458&r2=438459&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
Wed Aug 30 04:04:26 2006
@@ -22,17 +22,17 @@
 import java.net.Socket;
 import java.net.UnknownHostException;
 
+import javax.net.SocketFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLServerSocket;
 
-import org.apache.commons.net.SocketFactory;
 
 /**
  * 
  * Implementation of org.apache.commons.net.SocketFactory
  *
  */
-public class FTPSSocketFactory implements SocketFactory {
+public class FTPSSocketFactory extends SocketFactory {
 
     private SSLContext context;
     



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message