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:45:05 UTC
svn commit: r1332847 -
/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
Author: ngn
Date: Tue May 1 21:45:04 2012
New Revision: 1332847
URL: http://svn.apache.org/viewvc?rev=1332847&view=rev
Log:
Remove duplicate code
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java?rev=1332847&r1=1332846&r2=1332847&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java Tue May 1 21:45:04 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) {