You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2012/05/01 23:37:10 UTC

svn commit: r1332843 - /mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java

Author: ngn
Date: Tue May  1 21:37:10 2012
New Revision: 1332843

URL: http://svn.apache.org/viewvc?rev=1332843&view=rev
Log:
Remove duplicate code

Modified:
    mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java

Modified: mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java?rev=1332843&r1=1332842&r2=1332843&view=diff
==============================================================================
--- mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java (original)
+++ mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java Tue May  1 21:37:10 2012
@@ -21,6 +21,8 @@ package org.apache.ftpserver.command.imp
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.ftpserver.command.AbstractCommand;
 import org.apache.ftpserver.ftplet.FtpException;
@@ -48,6 +50,8 @@ public class AUTH extends AbstractComman
 
     private final Logger LOG = LoggerFactory.getLogger(AUTH.class);
 
+    private static final List<String> VALID_AUTH_TYPES = Arrays.asList("SSL", "TLS");
+
     /**
      * Execute command
      */
@@ -95,22 +99,11 @@ public class AUTH extends AbstractComman
 
         // check parameter
         String authType = request.getArgument().toUpperCase();
-        if (authType.equals("SSL")) {
-            try {
-                secureSession(session, "SSL");
-                session.write(LocalizedFtpReply.translate(session, request, context,
-                        234, "AUTH.SSL", null));
-            } catch (FtpException ex) {
-                throw ex;
-            } catch (Exception ex) {
-                LOG.warn("AUTH.execute()", ex);
-                throw new FtpException("AUTH.execute()", ex);
-            }
-        } else if (authType.equals("TLS")) {
+        if (VALID_AUTH_TYPES.contains(authType)) {
             try {
-                secureSession(session, "TLS");
+                secureSession(session, authType);
                 session.write(LocalizedFtpReply.translate(session, request, context,
-                        234, "AUTH.TLS", null));
+                        234, "AUTH." + authType, null));
             } catch (FtpException ex) {
                 throw ex;
             } catch (Exception ex) {