Remove duplicate code
git-svn-id: https://svn.apache.org/repos/asf/mina/ftpserver/trunk@1332847 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java b/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
index acc8827..06e030c 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java
@@ -21,6 +21,8 @@
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 @@
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 @@
// check parameter
String authType = request.getArgument().toUpperCase();
- if (authType.equals("SSL")) {
+ if (VALID_AUTH_TYPES.contains(authType)) {
try {
- secureSession(session, "SSL");
+ secureSession(session, authType);
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")) {
- try {
- secureSession(session, "TLS");
- session.write(LocalizedFtpReply.translate(session, request, context,
- 234, "AUTH.TLS", null));
+ 234, "AUTH." + authType, null));
} catch (FtpException ex) {
throw ex;
} catch (Exception ex) {