Remove duplicate code git-svn-id: https://svn.apache.org/repos/asf/mina/ftpserver/trunk@1332847 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/commit/ba0962b9 Tree: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/tree/ba0962b9 Diff: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/diff/ba0962b9 Branch: refs/heads/trunk Commit: ba0962b9c0ba5152e15104be213b6ea80d63344e Parents: 18c6424 Author: Niklas Gustavsson <[email protected]> Authored: Tue May 1 21:45:04 2012 +0000 Committer: Niklas Gustavsson <[email protected]> Committed: Tue May 1 21:45:04 2012 +0000 ---------------------------------------------------------------------- .../org/apache/ftpserver/command/impl/AUTH.java | 21 +++++++------------- 1 file changed, 7 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-ftpserver/blob/ba0962b9/core/src/main/java/org/apache/ftpserver/command/impl/AUTH.java ---------------------------------------------------------------------- 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 @@ package org.apache.ftpserver.command.impl; 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 AbstractCommand { 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 AbstractCommand { // 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) {
