You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gg...@apache.org on 2022/12/04 14:57:22 UTC
[mina-ftpserver] branch 1.2.X updated: Fix indentation
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch 1.2.X
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/1.2.X by this push:
new 7f9b5e6b Fix indentation
7f9b5e6b is described below
commit 7f9b5e6bf08aebaee419df20c77670b00d188c7b
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Sun Dec 4 09:57:18 2022 -0500
Fix indentation
---
.../org/apache/ftpserver/command/impl/AUTH.java | 110 ++++++++++-----------
1 file changed, 54 insertions(+), 56 deletions(-)
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 3e7fa1af..b172f303 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
@@ -56,65 +56,63 @@ public class AUTH extends AbstractCommand {
* Execute command
*/
public void execute(final FtpIoSession session, final FtpServerContext context, final FtpRequest request)
- throws IOException, FtpException {
+ throws IOException, FtpException {
- // reset state variables
- session.resetState();
+ // reset state variables
+ session.resetState();
- // argument check
- if (!request.hasArgument()) {
- session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "AUTH", null));
- return;
- }
-
- // check SSL configuration
- if (session.getListener().getSslConfiguration() == null) {
- session.write(LocalizedFtpReply.translate(session, request, context, 431, "AUTH", null));
- return;
- }
+ // argument check
+ if (!request.hasArgument()) {
+ session.write(LocalizedFtpReply.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "AUTH", null));
+ return;
+ }
- // check that we don't already have a SSL filter in place due to running
- // in implicit mode
- // or because the AUTH command has already been issued. This is what the
- // RFC says:
-
- // "Some servers will allow the AUTH command to be reissued in order
- // to establish new authentication. The AUTH command, if accepted,
- // removes any state associated with prior FTP Security commands.
- // The server must also require that the user reauthorize (that is,
- // reissue some or all of the USER, PASS, and ACCT commands) in this
- // case (see section 4 for an explanation of "authorize" in this
- // context)."
-
- // Here we choose not to support reissued AUTH
- if (session.getFilterChain().contains(SslFilter.class)) {
- session.write(LocalizedFtpReply.translate(session, request, context, 534, "AUTH", null));
- return;
- }
+ // check SSL configuration
+ if (session.getListener().getSslConfiguration() == null) {
+ session.write(LocalizedFtpReply.translate(session, request, context, 431, "AUTH", null));
+ return;
+ }
- // check parameter
- String authType = request.getArgument().toUpperCase();
- if (VALID_AUTH_TYPES.contains(authType)) {
- if (authType.equals("TLS-C")) {
- authType = "TLS";
- } else if (authType.equals("TLS-P")) {
- authType = "SSL";
+ // check that we don't already have a SSL filter in place due to running
+ // in implicit mode
+ // or because the AUTH command has already been issued. This is what the
+ // RFC says:
+
+ // "Some servers will allow the AUTH command to be reissued in order
+ // to establish new authentication. The AUTH command, if accepted,
+ // removes any state associated with prior FTP Security commands.
+ // The server must also require that the user reauthorize (that is,
+ // reissue some or all of the USER, PASS, and ACCT commands) in this
+ // case (see section 4 for an explanation of "authorize" in this
+ // context)."
+
+ // Here we choose not to support reissued AUTH
+ if (session.getFilterChain().contains(SslFilter.class)) {
+ session.write(LocalizedFtpReply.translate(session, request, context, 534, "AUTH", null));
+ return;
}
- try {
- secureSession(session, authType);
- session.write(LocalizedFtpReply.translate(session, request, context, 234, "AUTH." + authType, null));
- } catch (FtpException ex) {
- throw ex;
- } catch (Exception ex) {
- LOG.warn("AUTH.execute()", ex);
- throw new FtpException("AUTH.execute()", ex);
+ // check parameter
+ String authType = request.getArgument().toUpperCase();
+ if (VALID_AUTH_TYPES.contains(authType)) {
+ if (authType.equals("TLS-C")) {
+ authType = "TLS";
+ } else if (authType.equals("TLS-P")) {
+ authType = "SSL";
+ }
+
+ try {
+ secureSession(session, authType);
+ session.write(LocalizedFtpReply.translate(session, request, context, 234, "AUTH." + authType, null));
+ } catch (FtpException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ LOG.warn("AUTH.execute()", ex);
+ throw new FtpException("AUTH.execute()", ex);
+ }
+ } else {
+ session.write(LocalizedFtpReply.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "AUTH", null));
}
- } else {
- session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "AUTH", null));
- }
}
private void secureSession(final FtpIoSession session, final String type)
@@ -126,9 +124,9 @@ public class AUTH extends AbstractCommand {
SslFilter sslFilter = new SslFilter(ssl.getSSLContext());
if (ssl.getClientAuth() == ClientAuth.NEED) {
- sslFilter.setNeedClientAuth(true);
+ sslFilter.setNeedClientAuth(true);
} else if (ssl.getClientAuth() == ClientAuth.WANT) {
- sslFilter.setWantClientAuth(true);
+ sslFilter.setWantClientAuth(true);
}
// note that we do not care about the protocol, we allow both types
@@ -136,7 +134,7 @@ public class AUTH extends AbstractCommand {
// use. Thus the type argument is ignored.
if (ssl.getEnabledCipherSuites() != null) {
- sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
+ sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
}
if (ssl.getEnabledProtocols() != null) {
@@ -146,7 +144,7 @@ public class AUTH extends AbstractCommand {
session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME, sslFilter);
if ("SSL".equals(type)) {
- session.getDataConnection().setSecure(true);
+ session.getDataConnection().setSecure(true);
}
} else {
throw new FtpException("Socket factory SSL not configured");