You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2022/01/03 16:22:56 UTC
[mina-ftpserver] branch master updated: Replaced tabs by spaves
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/master by this push:
new a2ea5ad Replaced tabs by spaves
a2ea5ad is described below
commit a2ea5adb465d6a834370b00c4f7240f39e93c588
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Mon Jan 3 17:22:47 2022 +0100
Replaced tabs by spaves
---
.../resources/spring-config/config-ftplets.xml | 37 +-
.../resources/spring-config/config-full.xml | 84 +-
.../resources/spring-config/config-minimal.xml | 12 +-
.../resources/spring-config/config-typical.xml | 54 +-
.../ftpserver/DataConnectionConfiguration.java | 20 +-
.../DataConnectionConfigurationFactory.java | 62 +-
.../org/apache/ftpserver/command/impl/AUTH.java | 184 ++---
.../org/apache/ftpserver/command/impl/EPRT.java | 4 +-
.../org/apache/ftpserver/command/impl/LIST.java | 2 +-
.../org/apache/ftpserver/command/impl/MD5.java | 4 +-
.../org/apache/ftpserver/command/impl/PORT.java | 6 +-
.../org/apache/ftpserver/command/impl/RMD.java | 2 +-
.../org/apache/ftpserver/command/impl/STAT.java | 7 +-
.../spring/ListenerBeanDefinitionParser.java | 4 +-
.../apache/ftpserver/config/spring/SpringUtil.java | 10 +-
.../filesystem/nativefs/impl/NativeFtpFile.java | 16 +-
.../impl/DefaultDataConnectionConfiguration.java | 52 +-
.../apache/ftpserver/impl/DefaultFtpRequest.java | 14 +-
.../apache/ftpserver/impl/FtpReplyTranslator.java | 858 ++++++++++-----------
.../ftpserver/impl/IODataConnectionFactory.java | 524 ++++++-------
.../impl/LocalizedDataTransferFtpReply.java | 182 ++---
.../impl/LocalizedFileActionFtpReply.java | 98 +--
.../apache/ftpserver/impl/LocalizedFtpReply.java | 14 +-
.../ftpserver/impl/LocalizedRenameFtpReply.java | 124 +--
.../apache/ftpserver/ipfilter/IpFilterType.java | 50 +-
.../ftpserver/listener/nio/AbstractListener.java | 4 +-
.../apache/ftpserver/listener/nio/NioListener.java | 238 +++---
.../ftpserver/ssl/SslConfigurationFactory.java | 202 ++---
.../ssl/impl/DefaultSslConfiguration.java | 72 +-
.../usermanager/Md5PasswordEncryptor.java | 36 +-
.../usermanager/SaltedPasswordEncryptor.java | 74 +-
.../apache/ftpserver/usermanager/UserFactory.java | 200 ++---
.../ftpserver/usermanager/impl/DbUserManager.java | 28 +-
.../org/apache/ftpserver/util/PasswordUtil.java | 156 ++--
.../ftpserver/config/spring/ftpserver-1.0.xsd | 532 ++++++-------
.../ftpserver/clienttests/ClientTestTemplate.java | 12 +-
.../apache/ftpserver/clienttests/FtpMd5Test.java | 2 +-
.../apache/ftpserver/clienttests/IpFilterTest.java | 12 +-
.../apache/ftpserver/clienttests/LoginTest.java | 14 +-
.../clienttests/PasvPortUnavailableTest.java | 36 +-
.../org/apache/ftpserver/clienttests/PortTest.java | 2 +-
.../impl/listing/LISTFileFormaterTest.java | 2 +-
.../impl/listing/MLSTFileFormaterTest.java | 2 +-
.../impl/listing/NLSTFileFormaterTest.java | 2 +-
.../ftpserver/config/spring/FtpletsConfigTest.java | 2 +-
.../ftpserver/config/spring/SpringConfigTest.java | 2 +-
.../nativefs/impl/NativeFtpFileTest.java | 26 +-
.../ftpletcontainer/FtpLetReturnDefaultTest.java | 4 +-
.../apache/ftpserver/impl/PassivePortsTest.java | 12 +-
.../apache/ftpserver/ssl/MinaCipherSuitesTest.java | 34 +-
.../impl/PropertiesUserManagerTest.java | 38 +-
.../spring-config/config-property-placeholder.xml | 31 +-
.../resources/spring-config/config-spring-1.xml | 124 +--
distribution/res/conf/ftpd-full.xml | 200 ++---
distribution/res/conf/ftpd-typical.xml | 50 +-
.../resources/META-INF/spring/bundle-context.xml | 82 +-
.../ftpserver/ftplet/DataTransferFtpReply.java | 14 +-
.../apache/ftpserver/ftplet/DefaultFtpReply.java | 20 +-
.../ftpserver/ftplet/FileActionFtpReply.java | 16 +-
.../java/org/apache/ftpserver/ftplet/Ftplet.java | 50 +-
.../apache/ftpserver/ftplet/RenameFtpReply.java | 28 +-
61 files changed, 2396 insertions(+), 2387 deletions(-)
diff --git a/core/src/examples/resources/spring-config/config-ftplets.xml b/core/src/examples/resources/spring-config/config-ftplets.xml
index 1744aa3..d3278d6 100644
--- a/core/src/examples/resources/spring-config/config-ftplets.xml
+++ b/core/src/examples/resources/spring-config/config-ftplets.xml
@@ -17,28 +17,29 @@
specific language governing permissions and limitations
under the License. -->
<beans:beans xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- ">
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ ">
<beans:bean id="ftpletBean2" class="org.apache.ftpserver.examples.MyFtplet">
<beans:property name="foo" value="123"/>
</beans:bean>
- <server id="myServer">
- <ftplets>
- <ftplet name="ftplet1">
- <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
- <beans:property name="foo" value="123"/>
- </beans:bean>
- </ftplet>
- <ftplet name="ftplet2">
- <beans:ref name="ftpletBean2" />
- </ftplet>
- </ftplets>
- </server>
+ <server id="myServer">
+ <ftplets>
+ <ftplet name="ftplet1">
+ <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
+ <beans:property name="foo" value="123"/>
+ </beans:bean>
+ </ftplet>
+
+ <ftplet name="ftplet2">
+ <beans:ref name="ftpletBean2" />
+ </ftplet>
+ </ftplets>
+ </server>
</beans:beans>
diff --git a/core/src/examples/resources/spring-config/config-full.xml b/core/src/examples/resources/spring-config/config-full.xml
index ecd15e0..3dc6c75 100644
--- a/core/src/examples/resources/spring-config/config-full.xml
+++ b/core/src/examples/resources/spring-config/config-full.xml
@@ -17,44 +17,50 @@
specific language governing permissions and limitations
under the License. -->
<beans:beans xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- ">
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ ">
- <server id="myServer">
- <listeners>
- <nio-listener name="default" port="2222" implicit-ssl="true" idle-timeout="60" local-address="1.2.3.4">
- <ssl>
- <keystore file="mykeystore.jks" password="secret" key-password="otherSecret" />
- <truststore file="mytruststore.jks" password="secret"/>
- </ssl>
- <data-connection idle-timeout="60">
- <active enabled="true" local-address="1.2.3.4" local-port="2323" ip-check="true"/>
- <passive ports="123-125" address="1.2.3.4" external-address="1.2.3.4" />
- </data-connection>
- <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
- </nio-listener>
- <listener name="myCustomListener">
- <beans:bean class="org.apache.ftpserver.examples.MyListener" />
- </listener>
- </listeners>
- <ftplets>
- <ftplet name="ftplet1">
- <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
- <beans:property name="foo" value="123"/>
- </beans:bean>
- </ftplet>
- </ftplets>
- <file-user-manager file="users.properties" encrypt-passwords="true" />
- <native-filesystem case-insensitive="false" create-home="true" />
- <commands use-default="false">
- <command name="MYHELP">
- <beans:bean class="org.apache.ftpserver.examples.MYHELP" />
- </command>
- </commands>
- <messages languages="se, no ,da" />
- </server>
+ <server id="myServer">
+ <listeners>
+ <nio-listener name="default" port="2222" implicit-ssl="true" idle-timeout="60" local-address="1.2.3.4">
+ <ssl>
+ <keystore file="mykeystore.jks" password="secret" key-password="otherSecret" />
+ <truststore file="mytruststore.jks" password="secret"/>
+ </ssl>
+
+ <data-connection idle-timeout="60">
+ <active enabled="true" local-address="1.2.3.4" local-port="2323" ip-check="true"/>
+ <passive ports="123-125" address="1.2.3.4" external-address="1.2.3.4" />
+ </data-connection>
+ <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
+ </nio-listener>
+
+ <listener name="myCustomListener">
+ beans:bean class="org.apache.ftpserver.examples.MyListener" />
+ </listener>
+ </listeners>
+
+ <ftplets>
+ <ftplet name="ftplet1">
+ <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
+ <beans:property name="foo" value="123"/>
+ </beans:bean>
+ </ftplet>
+ </ftplets>
+
+ <file-user-manager file="users.properties" encrypt-passwords="true" />
+ <native-filesystem case-insensitive="false" create-home="true" />
+
+ <commands use-default="false">
+ <command name="MYHELP">
+ <beans:bean class="org.apache.ftpserver.examples.MYHELP" />
+ </command>
+ </commands>
+
+ <messages languages="se, no ,da" />
+ </server>
</beans:beans>
\ No newline at end of file
diff --git a/core/src/examples/resources/spring-config/config-minimal.xml b/core/src/examples/resources/spring-config/config-minimal.xml
index 85bdd7e..c252b6e 100644
--- a/core/src/examples/resources/spring-config/config-minimal.xml
+++ b/core/src/examples/resources/spring-config/config-minimal.xml
@@ -17,9 +17,9 @@
specific language governing permissions and limitations
under the License. -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- "
- id="myServer" />
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ id="myServer" />
diff --git a/core/src/examples/resources/spring-config/config-typical.xml b/core/src/examples/resources/spring-config/config-typical.xml
index 3c07f63..44e6c43 100644
--- a/core/src/examples/resources/spring-config/config-typical.xml
+++ b/core/src/examples/resources/spring-config/config-typical.xml
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- "
- id="myServer">
- <listeners>
- <nio-listener name="default" port="2121">
- <ssl>
- <keystore file="mykeystore.jks" password="secret" />
- </ssl>
- </nio-listener>
- </listeners>
- <file-user-manager file="users.properties" />
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ id="myServer">
+ <listeners>
+ <nio-listener name="default" port="2121">
+ <ssl>
+ <keystore file="mykeystore.jks" password="secret" />
+ </ssl>
+ </nio-listener>
+ </listeners>
+ <file-user-manager file="users.properties" />
</server>
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java b/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
index 136d6f1..c3d4c73 100644
--- a/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
+++ b/core/src/main/java/org/apache/ftpserver/DataConnectionConfiguration.java
@@ -93,16 +93,16 @@ public interface DataConnectionConfiguration {
String getPassivePorts();
/**
- * Tells whether or not IP address check is performed when accepting a
- * passive data connection.
- *
- * @return <code>true</code>, if the IP address checking is enabled;
- * <code>false</code>, otherwise. A value of <code>true</code> means
- * that site to site transfers are disabled. In other words, a
- * passive data connection MUST be made from the same IP address
- * that issued the PASV command.
- */
- boolean isPassiveIpCheck();
+ * Tells whether or not IP address check is performed when accepting a
+ * passive data connection.
+ *
+ * @return <code>true</code>, if the IP address checking is enabled;
+ * <code>false</code>, otherwise. A value of <code>true</code> means
+ * that site to site transfers are disabled. In other words, a
+ * passive data connection MUST be made from the same IP address
+ * that issued the PASV command.
+ */
+ boolean isPassiveIpCheck();
/**
* Request a passive port. Will block until a port is available
diff --git a/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java b/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
index 51d4ca2..960b65b 100644
--- a/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
+++ b/core/src/main/java/org/apache/ftpserver/DataConnectionConfigurationFactory.java
@@ -59,7 +59,7 @@ public class DataConnectionConfigurationFactory {
* @return The {@link DataConnectionConfiguration} instance
*/
public DataConnectionConfiguration createDataConnectionConfiguration() {
- checkValidAddresses();
+ checkValidAddresses();
return new DefaultDataConnectionConfiguration(idleTime,
ssl, activeEnabled, activeIpCheck,
activeLocalAddress, activeLocalPort,
@@ -72,12 +72,12 @@ public class DataConnectionConfigurationFactory {
* are valid.
*/
private void checkValidAddresses(){
- try{
- InetAddress.getByName(passiveAddress);
- InetAddress.getByName(passiveExternalAddress);
- }catch(UnknownHostException ex){
- throw new FtpServerConfigurationException("Unknown host", ex);
- }
+ try{
+ InetAddress.getByName(passiveAddress);
+ InetAddress.getByName(passiveExternalAddress);
+ }catch(UnknownHostException ex){
+ throw new FtpServerConfigurationException("Unknown host", ex);
+ }
}
/**
@@ -199,30 +199,30 @@ public class DataConnectionConfigurationFactory {
}
/**
- * Tells whether or not IP address check is performed when accepting a
- * passive data connection.
- *
- * @return <code>true</code>, if the IP address checking is enabled;
- * <code>false</code>, otherwise. A value of <code>true</code> means
- * that site to site transfers are disabled. In other words, a
- * passive data connection MUST be made from the same IP address
- * that issued the PASV command.
- */
- public boolean isPassiveIpCheck() {
- return passiveIpCheck;
- }
-
- /**
- * Sets whether or not IP check is performed before accepting a passive data
- * connection.
- *
- * @param passiveIpCheck
- * whether or not IP check is performed before accepting a
- * passive data connection.
- */
- public void setPassiveIpCheck(boolean passiveIpCheck) {
- this.passiveIpCheck = passiveIpCheck;
- }
+ * Tells whether or not IP address check is performed when accepting a
+ * passive data connection.
+ *
+ * @return <code>true</code>, if the IP address checking is enabled;
+ * <code>false</code>, otherwise. A value of <code>true</code> means
+ * that site to site transfers are disabled. In other words, a
+ * passive data connection MUST be made from the same IP address
+ * that issued the PASV command.
+ */
+ public boolean isPassiveIpCheck() {
+ return passiveIpCheck;
+ }
+
+ /**
+ * Sets whether or not IP check is performed before accepting a passive data
+ * connection.
+ *
+ * @param passiveIpCheck
+ * whether or not IP check is performed before accepting a
+ * passive data connection.
+ */
+ public void setPassiveIpCheck(boolean passiveIpCheck) {
+ this.passiveIpCheck = passiveIpCheck;
+ }
/**
* Get passive data port. Data port number zero (0) means that any available
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 2d8d997..b5956cd 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,100 +56,100 @@ public class AUTH extends AbstractCommand {
* Execute command
*/
public void execute(final FtpIoSession session, final FtpServerContext context, final FtpRequest request)
- throws IOException, FtpException {
-
- // 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;
- }
-
- // 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 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));
- }
+ throws IOException, FtpException {
+
+ // 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;
+ }
+
+ // 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 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));
+ }
}
private void secureSession(final FtpIoSession session, final String type)
- throws GeneralSecurityException, FtpException {
- SslConfiguration ssl = session.getListener().getSslConfiguration();
-
- if (ssl != null) {
- session.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE);
-
- SslFilter sslFilter = new SslFilter(ssl.getSSLContext());
- if (ssl.getClientAuth() == ClientAuth.NEED) {
- sslFilter.setNeedClientAuth(true);
- } else if (ssl.getClientAuth() == ClientAuth.WANT) {
- sslFilter.setWantClientAuth(true);
- }
-
- // note that we do not care about the protocol, we allow both types
- // and leave it to the SSL handshake to determine the protocol to
- // use. Thus the type argument is ignored.
-
- if (ssl.getEnabledCipherSuites() != null) {
- sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
- }
-
- if (ssl.getEnabledProtocol() != null) {
- sslFilter.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
- }
-
- session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME, sslFilter);
-
- if ("SSL".equals(type)) {
- session.getDataConnection().setSecure(true);
- }
- } else {
- throw new FtpException("Socket factory SSL not configured");
- }
+ throws GeneralSecurityException, FtpException {
+ SslConfiguration ssl = session.getListener().getSslConfiguration();
+
+ if (ssl != null) {
+ session.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE);
+
+ SslFilter sslFilter = new SslFilter(ssl.getSSLContext());
+ if (ssl.getClientAuth() == ClientAuth.NEED) {
+ sslFilter.setNeedClientAuth(true);
+ } else if (ssl.getClientAuth() == ClientAuth.WANT) {
+ sslFilter.setWantClientAuth(true);
+ }
+
+ // note that we do not care about the protocol, we allow both types
+ // and leave it to the SSL handshake to determine the protocol to
+ // use. Thus the type argument is ignored.
+
+ if (ssl.getEnabledCipherSuites() != null) {
+ sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
+ }
+
+ if (ssl.getEnabledProtocol() != null) {
+ sslFilter.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
+ }
+
+ session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME, sslFilter);
+
+ if ("SSL".equals(type)) {
+ session.getDataConnection().setSecure(true);
+ }
+ } else {
+ throw new FtpException("Socket factory SSL not configured");
+ }
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/EPRT.java b/core/src/main/java/org/apache/ftpserver/command/impl/EPRT.java
index 5d44704..01dd3b4 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/EPRT.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/EPRT.java
@@ -73,7 +73,7 @@ public class EPRT extends AbstractCommand {
.getDataConnectionConfiguration();
if (!dataCfg.isActiveEnabled()) {
session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT.disabled", null));
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT.disabled", null));
return;
}
@@ -88,7 +88,7 @@ public class EPRT extends AbstractCommand {
} catch (Exception ex) {
LOG.debug("Exception parsing host and port: " + arg, ex);
session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT", null));
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "EPRT", null));
return;
}
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/LIST.java b/core/src/main/java/org/apache/ftpserver/command/impl/LIST.java
index e7c5de7..004c4ca 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/LIST.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/LIST.java
@@ -124,7 +124,7 @@ public class LIST extends AbstractCommand {
// transfer listing data
boolean failure = false;
String dirList = directoryLister.listFiles(parsedArg,
- session.getFileSystemView(), LIST_FILE_FORMATER);
+ session.getFileSystemView(), LIST_FILE_FORMATER);
try {
dataConnection.transferToClient(session.getFtpletSession(), dirList);
} catch (SocketException ex) {
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/MD5.java b/core/src/main/java/org/apache/ftpserver/command/impl/MD5.java
index de069ab..881951a 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/MD5.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/MD5.java
@@ -137,11 +137,11 @@ public class MD5 extends AbstractCommand {
}
boolean nameHasSpaces = fileName.indexOf(' ') >= 0;
if(nameHasSpaces) {
- sb.append('"');
+ sb.append('"');
}
sb.append(fileName);
if(nameHasSpaces) {
- sb.append('"');
+ sb.append('"');
}
sb.append(' ');
sb.append(md5Hash);
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/PORT.java b/core/src/main/java/org/apache/ftpserver/command/impl/PORT.java
index f6ba67a..b8038be 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/PORT.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/PORT.java
@@ -84,7 +84,7 @@ public class PORT extends AbstractCommand {
.getDataConnectionConfiguration();
if (!dataCfg.isActiveEnabled()) {
session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT.disabled", null));
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT.disabled", null));
return;
}
@@ -94,11 +94,11 @@ public class PORT extends AbstractCommand {
// port must not be 0
if(address.getPort() == 0) {
- throw new IllegalPortException("PORT port must not be 0");
+ throw new IllegalPortException("PORT port must not be 0");
}
} catch (IllegalInetAddressException e) {
session.write(LocalizedFtpReply.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
return;
} catch (IllegalPortException e) {
LOG.debug("Invalid data port: " + request.getArgument(), e);
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/RMD.java b/core/src/main/java/org/apache/ftpserver/command/impl/RMD.java
index 46a6f0b..a816253 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/RMD.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/RMD.java
@@ -125,7 +125,7 @@ public class RMD extends AbstractCommand {
ftpStat.setRmdir(session, file);
} else {
-
+
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "RMD",
fileName, file));
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java b/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
index 661bdb0..a49f040 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
@@ -81,14 +81,13 @@ public class STAT extends AbstractCommand {
int replyCode;
if(file.isDirectory()) {
- replyCode = FtpReply.REPLY_212_DIRECTORY_STATUS;
+ replyCode = FtpReply.REPLY_212_DIRECTORY_STATUS;
} else {
- replyCode = FtpReply.REPLY_213_FILE_STATUS;
+ replyCode = FtpReply.REPLY_213_FILE_STATUS;
}
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
- replyCode, "STAT",
- dirList, file));
+ replyCode, "STAT", dirList, file));
} catch (FtpException e) {
session
diff --git a/core/src/main/java/org/apache/ftpserver/config/spring/ListenerBeanDefinitionParser.java b/core/src/main/java/org/apache/ftpserver/config/spring/ListenerBeanDefinitionParser.java
index 68cf398..9c668b3 100644
--- a/core/src/main/java/org/apache/ftpserver/config/spring/ListenerBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/ftpserver/config/spring/ListenerBeanDefinitionParser.java
@@ -258,7 +258,7 @@ public class ListenerBeanDefinitionParser extends
String localAddress = SpringUtil.parseStringFromInetAddress(
activeElm, "local-address");
if (localAddress != null) {
- dc.setActiveLocalAddress(localAddress);
+ dc.setActiveLocalAddress(localAddress);
}
}
@@ -268,7 +268,7 @@ public class ListenerBeanDefinitionParser extends
String address = SpringUtil.parseStringFromInetAddress(passiveElm,
"address");
if (address != null) {
- dc.setPassiveAddress(address);
+ dc.setPassiveAddress(address);
}
String externalAddress = SpringUtil.parseStringFromInetAddress(
diff --git a/core/src/main/java/org/apache/ftpserver/config/spring/SpringUtil.java b/core/src/main/java/org/apache/ftpserver/config/spring/SpringUtil.java
index dbd96b8..7ba5780 100644
--- a/core/src/main/java/org/apache/ftpserver/config/spring/SpringUtil.java
+++ b/core/src/main/java/org/apache/ftpserver/config/spring/SpringUtil.java
@@ -264,10 +264,10 @@ public class SpringUtil {
* @return The attribute string value.
*/
public static String parseStringFromInetAddress(final Element parent,
- final String attrName){
- if ( parseInetAddress(parent, attrName)!=null){
- return parent.getAttribute(attrName);
- }
- return null;
+ final String attrName){
+ if ( parseInetAddress(parent, attrName)!=null){
+ return parent.getAttribute(attrName);
+ }
+ return null;
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java b/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
index 3d1bf3c..9529a94 100644
--- a/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
+++ b/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
@@ -417,12 +417,12 @@ public class NativeFtpFile implements FtpFile {
return false;
}
- @Override
- public int hashCode() {
- try {
- return file.getCanonicalPath().hashCode();
- } catch (IOException e) {
- return 0;
- }
- }
+ @Override
+ public int hashCode() {
+ try {
+ return file.getCanonicalPath().hashCode();
+ } catch (IOException e) {
+ return 0;
+ }
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/DefaultDataConnectionConfiguration.java b/core/src/main/java/org/apache/ftpserver/impl/DefaultDataConnectionConfiguration.java
index c8b26eb..a1e3c0d 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/DefaultDataConnectionConfiguration.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/DefaultDataConnectionConfiguration.java
@@ -50,26 +50,26 @@ public class DefaultDataConnectionConfiguration implements
private final boolean implicitSsl;
/**
- * Internal constructor, do not use directly. Use
- * {@link DataConnectionConfigurationFactory} instead.
- */
- public DefaultDataConnectionConfiguration(int idleTime,
- SslConfiguration ssl, boolean activeEnabled, boolean activeIpCheck,
- String activeLocalAddress, int activeLocalPort, String passiveAddress,
- PassivePorts passivePorts, String passiveExternalAddress,
- boolean passiveIpCheck, boolean implicitSsl) {
- this.idleTime = idleTime;
- this.ssl = ssl;
- this.activeEnabled = activeEnabled;
- this.activeIpCheck = activeIpCheck;
- this.activeLocalAddress = activeLocalAddress;
- this.activeLocalPort = activeLocalPort;
- this.passiveAddress = passiveAddress;
- this.passivePorts = passivePorts;
- this.passiveExternalAddress = passiveExternalAddress;
- this.passiveIpCheck = passiveIpCheck;
- this.implicitSsl = implicitSsl;
- }
+ * Internal constructor, do not use directly. Use
+ * {@link DataConnectionConfigurationFactory} instead.
+ */
+ public DefaultDataConnectionConfiguration(int idleTime,
+ SslConfiguration ssl, boolean activeEnabled, boolean activeIpCheck,
+ String activeLocalAddress, int activeLocalPort, String passiveAddress,
+ PassivePorts passivePorts, String passiveExternalAddress,
+ boolean passiveIpCheck, boolean implicitSsl) {
+ this.idleTime = idleTime;
+ this.ssl = ssl;
+ this.activeEnabled = activeEnabled;
+ this.activeIpCheck = activeIpCheck;
+ this.activeLocalAddress = activeLocalAddress;
+ this.activeLocalPort = activeLocalPort;
+ this.passiveAddress = passiveAddress;
+ this.passivePorts = passivePorts;
+ this.passiveExternalAddress = passiveExternalAddress;
+ this.passiveIpCheck = passiveIpCheck;
+ this.implicitSsl = implicitSsl;
+ }
/**
* Get the maximum idle time in seconds.
@@ -117,19 +117,19 @@ public class DefaultDataConnectionConfiguration implements
* Get external passive host.
*/
public String getPassiveExernalAddress() {
- return passiveExternalAddress;
+ return passiveExternalAddress;
+ }
+
+ public boolean isPassiveIpCheck() {
+ return passiveIpCheck;
}
- public boolean isPassiveIpCheck() {
- return passiveIpCheck;
- }
-
/**
* Get passive data port. Data port number zero (0) means that any available
* port will be used.
*/
public synchronized int requestPassivePort() {
- return passivePorts.reserveNextPort();
+ return passivePorts.reserveNextPort();
}
/**
diff --git a/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpRequest.java b/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpRequest.java
index a33845c..6f8f919 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpRequest.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpRequest.java
@@ -45,12 +45,12 @@ public class DefaultFtpRequest implements FtpRequest {
* Default constructor.
*/
public DefaultFtpRequest(final String requestLine) {
- //Assuming we create the request as soon as we receive the command from
- //the client, set the received time to current time. If we do a whole
- //bunch of things after we receive the command from the client and
- //before constructing this FtpRequest object, then this method is not
- //going to be accurate and need to look for an alternative solution.
- this.receivedTime = System.currentTimeMillis();
+ //Assuming we create the request as soon as we receive the command from
+ //the client, set the received time to current time. If we do a whole
+ //bunch of things after we receive the command from the client and
+ //before constructing this FtpRequest object, then this method is not
+ //going to be accurate and need to look for an alternative solution.
+ this.receivedTime = System.currentTimeMillis();
line = requestLine.trim();
int spInd = line.indexOf(' ');
command = parseCmd(line, spInd);
@@ -113,7 +113,7 @@ public class DefaultFtpRequest implements FtpRequest {
}
public long getReceivedTime() {
- return receivedTime;
+ return receivedTime;
}
/*
diff --git a/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java b/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java
index 15a74e2..dc53f5d 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/FtpReplyTranslator.java
@@ -39,466 +39,466 @@ import org.apache.ftpserver.util.DateUtils;
public class FtpReplyTranslator {
- public static final String CLIENT_ACCESS_TIME = "client.access.time";
+ public static final String CLIENT_ACCESS_TIME = "client.access.time";
- public static final String CLIENT_CON_TIME = "client.con.time";
+ public static final String CLIENT_CON_TIME = "client.con.time";
- public static final String CLIENT_DIR = "client.dir";
+ public static final String CLIENT_DIR = "client.dir";
- public static final String CLIENT_HOME = "client.home";
+ public static final String CLIENT_HOME = "client.home";
- public static final String CLIENT_IP = "client.ip";
+ public static final String CLIENT_IP = "client.ip";
- public static final String CLIENT_LOGIN_NAME = "client.login.name";
+ public static final String CLIENT_LOGIN_NAME = "client.login.name";
- public static final String CLIENT_LOGIN_TIME = "client.login.time";
+ public static final String CLIENT_LOGIN_TIME = "client.login.time";
- public static final String OUTPUT_CODE = "output.code";
+ public static final String OUTPUT_CODE = "output.code";
- public static final String OUTPUT_MSG = "output.msg";
+ public static final String OUTPUT_MSG = "output.msg";
- public static final String REQUEST_ARG = "request.arg";
+ public static final String REQUEST_ARG = "request.arg";
- public static final String REQUEST_CMD = "request.cmd";
+ public static final String REQUEST_CMD = "request.cmd";
- public static final String REQUEST_LINE = "request.line";
+ public static final String REQUEST_LINE = "request.line";
- // /////////////////////// All Server Vatiables /////////////////////////
- public static final String SERVER_IP = "server.ip";
+ // /////////////////////// All Server Vatiables /////////////////////////
+ public static final String SERVER_IP = "server.ip";
- public static final String SERVER_PORT = "server.port";
+ public static final String SERVER_PORT = "server.port";
- public static final String STAT_CON_CURR = "stat.con.curr";
+ public static final String STAT_CON_CURR = "stat.con.curr";
- public static final String STAT_CON_TOTAL = "stat.con.total";
+ public static final String STAT_CON_TOTAL = "stat.con.total";
- public static final String STAT_DIR_CREATE_COUNT = "stat.dir.create.count";
+ public static final String STAT_DIR_CREATE_COUNT = "stat.dir.create.count";
- public static final String STAT_DIR_DELETE_COUNT = "stat.dir.delete.count";
+ public static final String STAT_DIR_DELETE_COUNT = "stat.dir.delete.count";
- public static final String STAT_FILE_DELETE_COUNT = "stat.file.delete.count";
+ public static final String STAT_FILE_DELETE_COUNT = "stat.file.delete.count";
- public static final String STAT_FILE_DOWNLOAD_BYTES = "stat.file.download.bytes";
+ public static final String STAT_FILE_DOWNLOAD_BYTES = "stat.file.download.bytes";
- public static final String STAT_FILE_DOWNLOAD_COUNT = "stat.file.download.count";
+ public static final String STAT_FILE_DOWNLOAD_COUNT = "stat.file.download.count";
- public static final String STAT_FILE_UPLOAD_BYTES = "stat.file.upload.bytes";
+ public static final String STAT_FILE_UPLOAD_BYTES = "stat.file.upload.bytes";
- public static final String STAT_FILE_UPLOAD_COUNT = "stat.file.upload.count";
+ public static final String STAT_FILE_UPLOAD_COUNT = "stat.file.upload.count";
- public static final String STAT_LOGIN_ANON_CURR = "stat.login.anon.curr";
+ public static final String STAT_LOGIN_ANON_CURR = "stat.login.anon.curr";
- public static final String STAT_LOGIN_ANON_TOTAL = "stat.login.anon.total";
+ public static final String STAT_LOGIN_ANON_TOTAL = "stat.login.anon.total";
- public static final String STAT_LOGIN_CURR = "stat.login.curr";
+ public static final String STAT_LOGIN_CURR = "stat.login.curr";
- public static final String STAT_LOGIN_TOTAL = "stat.login.total";
+ public static final String STAT_LOGIN_TOTAL = "stat.login.total";
- public static final String STAT_START_TIME = "stat.start.time";
+ public static final String STAT_START_TIME = "stat.start.time";
- /**
- * Returns the translated message.
- *
- * @param session
- * the FTP session for which a reply is to be sent
- * @param request
- * the FTP request object
- * @param context
- * the FTP server context
- * @param code
- * the reply code
- * @param subId
- * the ID of the sub message
- * @param basicMsg
- * the basic message
- * @return the translated message
- */
- public static String translateMessage(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code, String subId,
- String basicMsg) {
- MessageResource resource = context.getMessageResource();
- String lang = session.getLanguage();
+ /**
+ * Returns the translated message.
+ *
+ * @param session
+ * the FTP session for which a reply is to be sent
+ * @param request
+ * the FTP request object
+ * @param context
+ * the FTP server context
+ * @param code
+ * the reply code
+ * @param subId
+ * the ID of the sub message
+ * @param basicMsg
+ * the basic message
+ * @return the translated message
+ */
+ public static String translateMessage(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code, String subId,
+ String basicMsg) {
+ MessageResource resource = context.getMessageResource();
+ String lang = session.getLanguage();
- String msg = null;
- if (resource != null) {
- msg = resource.getMessage(code, subId, lang);
- }
- if (msg == null) {
- msg = "";
- }
- msg = replaceVariables(session, request, context, code, basicMsg, msg);
+ String msg = null;
+ if (resource != null) {
+ msg = resource.getMessage(code, subId, lang);
+ }
+ if (msg == null) {
+ msg = "";
+ }
+ msg = replaceVariables(session, request, context, code, basicMsg, msg);
- return msg;
- }
+ return msg;
+ }
- /**
- * Replace server variables.
- */
- private static String replaceVariables(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code,
- String basicMsg, String str) {
+ /**
+ * Replace server variables.
+ */
+ private static String replaceVariables(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code,
+ String basicMsg, String str) {
- int startIndex = 0;
- int openIndex = str.indexOf('{', startIndex);
- if (openIndex == -1) {
- return str;
- }
-
- int closeIndex = str.indexOf('}', startIndex);
- if ((closeIndex == -1) || (openIndex > closeIndex)) {
- return str;
- }
-
- StringBuilder sb = new StringBuilder(128);
- sb.append(str.substring(startIndex, openIndex));
- while (true) {
- String varName = str.substring(openIndex + 1, closeIndex);
- sb.append(getVariableValue(session, request, context, code,
- basicMsg, varName));
-
- startIndex = closeIndex + 1;
- openIndex = str.indexOf('{', startIndex);
- if (openIndex == -1) {
- sb.append(str.substring(startIndex));
- break;
- }
-
- closeIndex = str.indexOf('}', startIndex);
- if ((closeIndex == -1) || (openIndex > closeIndex)) {
- sb.append(str.substring(startIndex));
- break;
- }
- sb.append(str.substring(startIndex, openIndex));
- }
- return sb.toString();
- }
-
- /**
- * Get the variable value.
- */
- private static String getVariableValue(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code,
- String basicMsg, String varName) {
-
- String varVal = null;
-
- // all output variables
- if (varName.startsWith("output.")) {
- varVal = getOutputVariableValue(session, code, basicMsg, varName);
- }
-
- // all server variables
- else if (varName.startsWith("server.")) {
- varVal = getServerVariableValue(session, varName);
- }
-
- // all request variables
- else if (varName.startsWith("request.")) {
- varVal = getRequestVariableValue(session, request, varName);
- }
-
- // all statistical variables
- else if (varName.startsWith("stat.")) {
- varVal = getStatisticalVariableValue(session, context, varName);
- }
-
- // all client variables
- else if (varName.startsWith("client.")) {
- varVal = getClientVariableValue(session, varName);
- }
-
- if (varVal == null) {
- varVal = "";
- }
- return varVal;
- }
-
- /**
- * Get client variable value.
- */
- private static String getClientVariableValue(FtpIoSession session,
- String varName) {
-
- String varVal = null;
-
- // client ip
- if (varName.equals(CLIENT_IP)) {
- if (session.getRemoteAddress() instanceof InetSocketAddress) {
- InetSocketAddress remoteSocketAddress = (InetSocketAddress) session.getRemoteAddress();
- varVal = remoteSocketAddress.getAddress().getHostAddress();
- }
-
- }
-
- // client connection time
- else if (varName.equals(CLIENT_CON_TIME)) {
- varVal = DateUtils.getISO8601Date(session.getCreationTime());
- }
-
- // client login name
- else if (varName.equals(CLIENT_LOGIN_NAME)) {
- if (session.getUser() != null) {
- varVal = session.getUser().getName();
- }
- }
-
- // client login time
- else if (varName.equals(CLIENT_LOGIN_TIME)) {
- varVal = DateUtils.getISO8601Date(session.getLoginTime().getTime());
- }
-
- // client last access time
- else if (varName.equals(CLIENT_ACCESS_TIME)) {
- varVal = DateUtils.getISO8601Date(session.getLastAccessTime().getTime());
- }
-
- // client home
- else if (varName.equals(CLIENT_HOME)) {
- varVal = session.getUser().getHomeDirectory();
- }
-
- // client directory
- else if (varName.equals(CLIENT_DIR)) {
- FileSystemView fsView = session.getFileSystemView();
- if (fsView != null) {
- try {
- varVal = fsView.getWorkingDirectory().getAbsolutePath();
- }
- catch (Exception ex) {
- varVal = "";
- }
- }
- }
- return varVal;
- }
-
- /**
- * Get output variable value.
- */
- private static String getOutputVariableValue(FtpIoSession session,
- int code, String basicMsg, String varName) {
- String varVal = null;
-
- // output code
- if (varName.equals(OUTPUT_CODE)) {
- varVal = String.valueOf(code);
- }
-
- // output message
- else if (varName.equals(OUTPUT_MSG)) {
- varVal = basicMsg;
- }
-
- return varVal;
- }
-
- /**
- * Get request variable value.
- */
- private static String getRequestVariableValue(FtpIoSession session,
- FtpRequest request, String varName) {
-
- String varVal = null;
-
- if (request == null) {
- return "";
- }
-
- // request line
- if (varName.equals(REQUEST_LINE)) {
- varVal = request.getRequestLine();
- }
-
- // request command
- else if (varName.equals(REQUEST_CMD)) {
- varVal = request.getCommand();
- }
-
- // request argument
- else if (varName.equals(REQUEST_ARG)) {
- varVal = request.getArgument();
- }
-
- return varVal;
- }
-
- /**
- * Get server variable value.
- */
- private static String getServerVariableValue(FtpIoSession session,
- String varName) {
-
- String varVal = null;
-
- SocketAddress localSocketAddress = session.getLocalAddress();
-
- if (localSocketAddress instanceof InetSocketAddress) {
- InetSocketAddress localInetSocketAddress = (InetSocketAddress) localSocketAddress;
- // server address
- if (varName.equals(SERVER_IP)) {
-
- InetAddress addr = localInetSocketAddress.getAddress();
-
- if (addr != null) {
- varVal = addr.getHostAddress();
- }
- }
-
- // server port
- else if (varName.equals(SERVER_PORT)) {
- varVal = String.valueOf(localInetSocketAddress.getPort());
- }
- }
-
- return varVal;
- }
-
- /**
- * Get statistical connection variable value.
- */
- private static String getStatisticalConnectionVariableValue(
- FtpIoSession session, FtpServerContext context, String varName) {
- String varVal = null;
- FtpStatistics stat = context.getFtpStatistics();
-
- // total connection number
- if (varName.equals(STAT_CON_TOTAL)) {
- varVal = String.valueOf(stat.getTotalConnectionNumber());
- }
-
- // current connection number
- else if (varName.equals(STAT_CON_CURR)) {
- varVal = String.valueOf(stat.getCurrentConnectionNumber());
- }
-
- return varVal;
- }
-
- /**
- * Get statistical directory variable value.
- */
- private static String getStatisticalDirectoryVariableValue(
- FtpIoSession session, FtpServerContext context, String varName) {
- String varVal = null;
- FtpStatistics stat = context.getFtpStatistics();
-
- // total directory created
- if (varName.equals(STAT_DIR_CREATE_COUNT)) {
- varVal = String.valueOf(stat.getTotalDirectoryCreated());
- }
-
- // total directory removed
- else if (varName.equals(STAT_DIR_DELETE_COUNT)) {
- varVal = String.valueOf(stat.getTotalDirectoryRemoved());
- }
-
- return varVal;
- }
-
- /**
- * Get statistical file variable value.
- */
- private static String getStatisticalFileVariableValue(FtpIoSession session,
- FtpServerContext context, String varName) {
- String varVal = null;
- FtpStatistics stat = context.getFtpStatistics();
-
- // total number of file upload
- if (varName.equals(STAT_FILE_UPLOAD_COUNT)) {
- varVal = String.valueOf(stat.getTotalUploadNumber());
- }
-
- // total bytes uploaded
- else if (varName.equals(STAT_FILE_UPLOAD_BYTES)) {
- varVal = String.valueOf(stat.getTotalUploadSize());
- }
-
- // total number of file download
- else if (varName.equals(STAT_FILE_DOWNLOAD_COUNT)) {
- varVal = String.valueOf(stat.getTotalDownloadNumber());
- }
-
- // total bytes downloaded
- else if (varName.equals(STAT_FILE_DOWNLOAD_BYTES)) {
- varVal = String.valueOf(stat.getTotalDownloadSize());
- }
-
- // total number of files deleted
- else if (varName.equals(STAT_FILE_DELETE_COUNT)) {
- varVal = String.valueOf(stat.getTotalDeleteNumber());
- }
-
- return varVal;
- }
-
- /**
- * Get statistical login variable value.
- */
- private static String getStatisticalLoginVariableValue(
- FtpIoSession session, FtpServerContext context, String varName) {
- String varVal = null;
- FtpStatistics stat = context.getFtpStatistics();
-
- // total login number
- if (varName.equals(STAT_LOGIN_TOTAL)) {
- varVal = String.valueOf(stat.getTotalLoginNumber());
- }
-
- // current login number
- else if (varName.equals(STAT_LOGIN_CURR)) {
- varVal = String.valueOf(stat.getCurrentLoginNumber());
- }
-
- // total anonymous login number
- else if (varName.equals(STAT_LOGIN_ANON_TOTAL)) {
- varVal = String.valueOf(stat.getTotalAnonymousLoginNumber());
- }
-
- // current anonymous login number
- else if (varName.equals(STAT_LOGIN_ANON_CURR)) {
- varVal = String.valueOf(stat.getCurrentAnonymousLoginNumber());
- }
-
- return varVal;
- }
-
- /**
- * Get statistical variable value.
- */
- private static String getStatisticalVariableValue(FtpIoSession session,
- FtpServerContext context, String varName) {
-
- String varVal = null;
- FtpStatistics stat = context.getFtpStatistics();
-
- // server start time
- if (varName.equals(STAT_START_TIME)) {
- varVal = DateUtils.getISO8601Date(stat.getStartTime().getTime());
- }
-
- // connection statistical variables
- else if (varName.startsWith("stat.con")) {
- varVal = getStatisticalConnectionVariableValue(session, context,
- varName);
- }
-
- // login statistical variables
- else if (varName.startsWith("stat.login.")) {
- varVal = getStatisticalLoginVariableValue(session, context, varName);
- }
-
- // file statistical variable
- else if (varName.startsWith("stat.file")) {
- varVal = getStatisticalFileVariableValue(session, context, varName);
- }
-
- // directory statistical variable
- else if (varName.startsWith("stat.dir.")) {
- varVal = getStatisticalDirectoryVariableValue(session, context,
- varName);
- }
-
- return varVal;
- }
+ int startIndex = 0;
+ int openIndex = str.indexOf('{', startIndex);
+ if (openIndex == -1) {
+ return str;
+ }
+
+ int closeIndex = str.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex)) {
+ return str;
+ }
+
+ StringBuilder sb = new StringBuilder(128);
+ sb.append(str.substring(startIndex, openIndex));
+ while (true) {
+ String varName = str.substring(openIndex + 1, closeIndex);
+ sb.append(getVariableValue(session, request, context, code,
+ basicMsg, varName));
+
+ startIndex = closeIndex + 1;
+ openIndex = str.indexOf('{', startIndex);
+ if (openIndex == -1) {
+ sb.append(str.substring(startIndex));
+ break;
+ }
+
+ closeIndex = str.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex)) {
+ sb.append(str.substring(startIndex));
+ break;
+ }
+ sb.append(str.substring(startIndex, openIndex));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Get the variable value.
+ */
+ private static String getVariableValue(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code,
+ String basicMsg, String varName) {
+
+ String varVal = null;
+
+ // all output variables
+ if (varName.startsWith("output.")) {
+ varVal = getOutputVariableValue(session, code, basicMsg, varName);
+ }
+
+ // all server variables
+ else if (varName.startsWith("server.")) {
+ varVal = getServerVariableValue(session, varName);
+ }
+
+ // all request variables
+ else if (varName.startsWith("request.")) {
+ varVal = getRequestVariableValue(session, request, varName);
+ }
+
+ // all statistical variables
+ else if (varName.startsWith("stat.")) {
+ varVal = getStatisticalVariableValue(session, context, varName);
+ }
+
+ // all client variables
+ else if (varName.startsWith("client.")) {
+ varVal = getClientVariableValue(session, varName);
+ }
+
+ if (varVal == null) {
+ varVal = "";
+ }
+ return varVal;
+ }
+
+ /**
+ * Get client variable value.
+ */
+ private static String getClientVariableValue(FtpIoSession session,
+ String varName) {
+
+ String varVal = null;
+
+ // client ip
+ if (varName.equals(CLIENT_IP)) {
+ if (session.getRemoteAddress() instanceof InetSocketAddress) {
+ InetSocketAddress remoteSocketAddress = (InetSocketAddress) session.getRemoteAddress();
+ varVal = remoteSocketAddress.getAddress().getHostAddress();
+ }
+
+ }
+
+ // client connection time
+ else if (varName.equals(CLIENT_CON_TIME)) {
+ varVal = DateUtils.getISO8601Date(session.getCreationTime());
+ }
+
+ // client login name
+ else if (varName.equals(CLIENT_LOGIN_NAME)) {
+ if (session.getUser() != null) {
+ varVal = session.getUser().getName();
+ }
+ }
+
+ // client login time
+ else if (varName.equals(CLIENT_LOGIN_TIME)) {
+ varVal = DateUtils.getISO8601Date(session.getLoginTime().getTime());
+ }
+
+ // client last access time
+ else if (varName.equals(CLIENT_ACCESS_TIME)) {
+ varVal = DateUtils.getISO8601Date(session.getLastAccessTime().getTime());
+ }
+
+ // client home
+ else if (varName.equals(CLIENT_HOME)) {
+ varVal = session.getUser().getHomeDirectory();
+ }
+
+ // client directory
+ else if (varName.equals(CLIENT_DIR)) {
+ FileSystemView fsView = session.getFileSystemView();
+ if (fsView != null) {
+ try {
+ varVal = fsView.getWorkingDirectory().getAbsolutePath();
+ }
+ catch (Exception ex) {
+ varVal = "";
+ }
+ }
+ }
+ return varVal;
+ }
+
+ /**
+ * Get output variable value.
+ */
+ private static String getOutputVariableValue(FtpIoSession session,
+ int code, String basicMsg, String varName) {
+ String varVal = null;
+
+ // output code
+ if (varName.equals(OUTPUT_CODE)) {
+ varVal = String.valueOf(code);
+ }
+
+ // output message
+ else if (varName.equals(OUTPUT_MSG)) {
+ varVal = basicMsg;
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get request variable value.
+ */
+ private static String getRequestVariableValue(FtpIoSession session,
+ FtpRequest request, String varName) {
+
+ String varVal = null;
+
+ if (request == null) {
+ return "";
+ }
+
+ // request line
+ if (varName.equals(REQUEST_LINE)) {
+ varVal = request.getRequestLine();
+ }
+
+ // request command
+ else if (varName.equals(REQUEST_CMD)) {
+ varVal = request.getCommand();
+ }
+
+ // request argument
+ else if (varName.equals(REQUEST_ARG)) {
+ varVal = request.getArgument();
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get server variable value.
+ */
+ private static String getServerVariableValue(FtpIoSession session,
+ String varName) {
+
+ String varVal = null;
+
+ SocketAddress localSocketAddress = session.getLocalAddress();
+
+ if (localSocketAddress instanceof InetSocketAddress) {
+ InetSocketAddress localInetSocketAddress = (InetSocketAddress) localSocketAddress;
+ // server address
+ if (varName.equals(SERVER_IP)) {
+
+ InetAddress addr = localInetSocketAddress.getAddress();
+
+ if (addr != null) {
+ varVal = addr.getHostAddress();
+ }
+ }
+
+ // server port
+ else if (varName.equals(SERVER_PORT)) {
+ varVal = String.valueOf(localInetSocketAddress.getPort());
+ }
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get statistical connection variable value.
+ */
+ private static String getStatisticalConnectionVariableValue(
+ FtpIoSession session, FtpServerContext context, String varName) {
+ String varVal = null;
+ FtpStatistics stat = context.getFtpStatistics();
+
+ // total connection number
+ if (varName.equals(STAT_CON_TOTAL)) {
+ varVal = String.valueOf(stat.getTotalConnectionNumber());
+ }
+
+ // current connection number
+ else if (varName.equals(STAT_CON_CURR)) {
+ varVal = String.valueOf(stat.getCurrentConnectionNumber());
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get statistical directory variable value.
+ */
+ private static String getStatisticalDirectoryVariableValue(
+ FtpIoSession session, FtpServerContext context, String varName) {
+ String varVal = null;
+ FtpStatistics stat = context.getFtpStatistics();
+
+ // total directory created
+ if (varName.equals(STAT_DIR_CREATE_COUNT)) {
+ varVal = String.valueOf(stat.getTotalDirectoryCreated());
+ }
+
+ // total directory removed
+ else if (varName.equals(STAT_DIR_DELETE_COUNT)) {
+ varVal = String.valueOf(stat.getTotalDirectoryRemoved());
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get statistical file variable value.
+ */
+ private static String getStatisticalFileVariableValue(FtpIoSession session,
+ FtpServerContext context, String varName) {
+ String varVal = null;
+ FtpStatistics stat = context.getFtpStatistics();
+
+ // total number of file upload
+ if (varName.equals(STAT_FILE_UPLOAD_COUNT)) {
+ varVal = String.valueOf(stat.getTotalUploadNumber());
+ }
+
+ // total bytes uploaded
+ else if (varName.equals(STAT_FILE_UPLOAD_BYTES)) {
+ varVal = String.valueOf(stat.getTotalUploadSize());
+ }
+
+ // total number of file download
+ else if (varName.equals(STAT_FILE_DOWNLOAD_COUNT)) {
+ varVal = String.valueOf(stat.getTotalDownloadNumber());
+ }
+
+ // total bytes downloaded
+ else if (varName.equals(STAT_FILE_DOWNLOAD_BYTES)) {
+ varVal = String.valueOf(stat.getTotalDownloadSize());
+ }
+
+ // total number of files deleted
+ else if (varName.equals(STAT_FILE_DELETE_COUNT)) {
+ varVal = String.valueOf(stat.getTotalDeleteNumber());
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get statistical login variable value.
+ */
+ private static String getStatisticalLoginVariableValue(
+ FtpIoSession session, FtpServerContext context, String varName) {
+ String varVal = null;
+ FtpStatistics stat = context.getFtpStatistics();
+
+ // total login number
+ if (varName.equals(STAT_LOGIN_TOTAL)) {
+ varVal = String.valueOf(stat.getTotalLoginNumber());
+ }
+
+ // current login number
+ else if (varName.equals(STAT_LOGIN_CURR)) {
+ varVal = String.valueOf(stat.getCurrentLoginNumber());
+ }
+
+ // total anonymous login number
+ else if (varName.equals(STAT_LOGIN_ANON_TOTAL)) {
+ varVal = String.valueOf(stat.getTotalAnonymousLoginNumber());
+ }
+
+ // current anonymous login number
+ else if (varName.equals(STAT_LOGIN_ANON_CURR)) {
+ varVal = String.valueOf(stat.getCurrentAnonymousLoginNumber());
+ }
+
+ return varVal;
+ }
+
+ /**
+ * Get statistical variable value.
+ */
+ private static String getStatisticalVariableValue(FtpIoSession session,
+ FtpServerContext context, String varName) {
+
+ String varVal = null;
+ FtpStatistics stat = context.getFtpStatistics();
+
+ // server start time
+ if (varName.equals(STAT_START_TIME)) {
+ varVal = DateUtils.getISO8601Date(stat.getStartTime().getTime());
+ }
+
+ // connection statistical variables
+ else if (varName.startsWith("stat.con")) {
+ varVal = getStatisticalConnectionVariableValue(session, context,
+ varName);
+ }
+
+ // login statistical variables
+ else if (varName.startsWith("stat.login.")) {
+ varVal = getStatisticalLoginVariableValue(session, context, varName);
+ }
+
+ // file statistical variable
+ else if (varName.startsWith("stat.file")) {
+ varVal = getStatisticalFileVariableValue(session, context, varName);
+ }
+
+ // directory statistical variable
+ else if (varName.startsWith("stat.dir.")) {
+ varVal = getStatisticalDirectoryVariableValue(session, context,
+ varName);
+ }
+
+ return varVal;
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/IODataConnectionFactory.java b/core/src/main/java/org/apache/ftpserver/impl/IODataConnectionFactory.java
index 3da1cf3..bf1b792 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/IODataConnectionFactory.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/IODataConnectionFactory.java
@@ -72,11 +72,11 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
FtpIoSession session;
public IODataConnectionFactory(final FtpServerContext serverContext, final FtpIoSession session) {
- this.session = session;
- this.serverContext = serverContext;
- if ((session != null) && (session.getListener() != null) && session.getListener().getDataConnectionConfiguration().isImplicitSsl()) {
- secure = true;
- }
+ this.session = session;
+ this.serverContext = serverContext;
+ if ((session != null) && (session.getListener() != null) && session.getListener().getDataConnectionConfiguration().isImplicitSsl()) {
+ secure = true;
+ }
}
/**
@@ -84,36 +84,36 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
*/
public synchronized void closeDataConnection() {
- // close client socket if any
- if (dataSoc != null) {
- try {
- dataSoc.close();
- } catch (Exception ex) {
- LOG.warn("FtpDataConnection.closeDataSocket()", ex);
- }
- dataSoc = null;
- }
-
- // close server socket if any
- if (servSoc != null) {
- try {
- servSoc.close();
- } catch (Exception ex) {
- LOG.warn("FtpDataConnection.closeDataSocket()", ex);
- }
-
- if (session != null) {
- DataConnectionConfiguration dcc = session.getListener().getDataConnectionConfiguration();
- if (dcc != null) {
- dcc.releasePassivePort(port);
- }
- }
-
- servSoc = null;
- }
-
- // reset request time
- requestTime = 0L;
+ // close client socket if any
+ if (dataSoc != null) {
+ try {
+ dataSoc.close();
+ } catch (Exception ex) {
+ LOG.warn("FtpDataConnection.closeDataSocket()", ex);
+ }
+ dataSoc = null;
+ }
+
+ // close server socket if any
+ if (servSoc != null) {
+ try {
+ servSoc.close();
+ } catch (Exception ex) {
+ LOG.warn("FtpDataConnection.closeDataSocket()", ex);
+ }
+
+ if (session != null) {
+ DataConnectionConfiguration dcc = session.getListener().getDataConnectionConfiguration();
+ if (dcc != null) {
+ dcc.releasePassivePort(port);
+ }
+ }
+
+ servSoc = null;
+ }
+
+ // reset request time
+ requestTime = 0L;
}
/**
@@ -121,86 +121,86 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
*/
public synchronized void initActiveDataConnection(final InetSocketAddress address) {
- // close old sockets if any
- closeDataConnection();
+ // close old sockets if any
+ closeDataConnection();
- // set variables
- passive = false;
- this.address = address.getAddress();
- port = address.getPort();
- requestTime = System.currentTimeMillis();
+ // set variables
+ passive = false;
+ this.address = address.getAddress();
+ port = address.getPort();
+ requestTime = System.currentTimeMillis();
}
private SslConfiguration getSslConfiguration() {
- DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
+ DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
- SslConfiguration configuration = dataCfg.getSslConfiguration();
+ SslConfiguration configuration = dataCfg.getSslConfiguration();
- // fall back if no configuration has been provided on the data connection config
- if (configuration == null) {
- configuration = session.getListener().getSslConfiguration();
- }
+ // fall back if no configuration has been provided on the data connection config
+ if (configuration == null) {
+ configuration = session.getListener().getSslConfiguration();
+ }
- return configuration;
+ return configuration;
}
/**
* Initiate a data connection in passive mode (server listening).
*/
public synchronized InetSocketAddress initPassiveDataConnection() throws DataConnectionException {
- LOG.debug("Initiating passive data connection");
- // close old sockets if any
- closeDataConnection();
-
- // get the passive port
- int passivePort = session.getListener().getDataConnectionConfiguration().requestPassivePort();
- if (passivePort == -1) {
- servSoc = null;
- throw new DataConnectionException("Cannot find an available passive port.");
- }
-
- // open passive server socket and get parameters
- try {
- DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
-
- String passiveAddress = dataCfg.getPassiveAddress();
-
- if (passiveAddress == null) {
- address = serverControlAddress;
- } else {
- address = resolveAddress(dataCfg.getPassiveAddress());
- }
-
- if (secure) {
- LOG.debug("Opening SSL passive data connection on address \"{}\" and port {}", address, passivePort);
- SslConfiguration ssl = getSslConfiguration();
- if (ssl == null) {
- throw new DataConnectionException("Data connection SSL required but not configured.");
- }
-
- // this method does not actually create the SSL socket, due to a JVM bug
- // (https://issues.apache.org/jira/browse/FTPSERVER-241).
- // Instead, it creates a regular
- // ServerSocket that will be wrapped as a SSL socket in createDataSocket()
- servSoc = new ServerSocket(passivePort, 0, address);
- LOG.debug("SSL Passive data connection created on address \"{}\" and port {}", address, passivePort);
- } else {
- LOG.debug("Opening passive data connection on address \"{}\" and port {}", address, passivePort);
- servSoc = new ServerSocket(passivePort, 0, address);
- LOG.debug("Passive data connection created on address \"{}\" and port {}", address, passivePort);
- }
- port = servSoc.getLocalPort();
- servSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);
-
- // set different state variables
- passive = true;
- requestTime = System.currentTimeMillis();
-
- return new InetSocketAddress(address, port);
- } catch (Exception ex) {
- closeDataConnection();
- throw new DataConnectionException("Failed to initate passive data connection: " + ex.getMessage(), ex);
- }
+ LOG.debug("Initiating passive data connection");
+ // close old sockets if any
+ closeDataConnection();
+
+ // get the passive port
+ int passivePort = session.getListener().getDataConnectionConfiguration().requestPassivePort();
+ if (passivePort == -1) {
+ servSoc = null;
+ throw new DataConnectionException("Cannot find an available passive port.");
+ }
+
+ // open passive server socket and get parameters
+ try {
+ DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
+
+ String passiveAddress = dataCfg.getPassiveAddress();
+
+ if (passiveAddress == null) {
+ address = serverControlAddress;
+ } else {
+ address = resolveAddress(dataCfg.getPassiveAddress());
+ }
+
+ if (secure) {
+ LOG.debug("Opening SSL passive data connection on address \"{}\" and port {}", address, passivePort);
+ SslConfiguration ssl = getSslConfiguration();
+ if (ssl == null) {
+ throw new DataConnectionException("Data connection SSL required but not configured.");
+ }
+
+ // this method does not actually create the SSL socket, due to a JVM bug
+ // (https://issues.apache.org/jira/browse/FTPSERVER-241).
+ // Instead, it creates a regular
+ // ServerSocket that will be wrapped as a SSL socket in createDataSocket()
+ servSoc = new ServerSocket(passivePort, 0, address);
+ LOG.debug("SSL Passive data connection created on address \"{}\" and port {}", address, passivePort);
+ } else {
+ LOG.debug("Opening passive data connection on address \"{}\" and port {}", address, passivePort);
+ servSoc = new ServerSocket(passivePort, 0, address);
+ LOG.debug("Passive data connection created on address \"{}\" and port {}", address, passivePort);
+ }
+ port = servSoc.getLocalPort();
+ servSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);
+
+ // set different state variables
+ passive = true;
+ requestTime = System.currentTimeMillis();
+
+ return new InetSocketAddress(address, port);
+ } catch (Exception ex) {
+ closeDataConnection();
+ throw new DataConnectionException("Failed to initate passive data connection: " + ex.getMessage(), ex);
+ }
}
/*
@@ -209,7 +209,7 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
* @see org.apache.ftpserver.FtpDataConnectionFactory2#getInetAddress()
*/
public InetAddress getInetAddress() {
- return address;
+ return address;
}
/*
@@ -218,7 +218,7 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
* @see org.apache.ftpserver.FtpDataConnectionFactory2#getPort()
*/
public int getPort() {
- return port;
+ return port;
}
/*
@@ -227,7 +227,7 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
* @see org.apache.ftpserver.FtpDataConnectionFactory2#openConnection()
*/
public DataConnection openConnection() throws Exception {
- return new IODataConnection(createDataSocket(), session, this);
+ return new IODataConnection(createDataSocket(), session, this);
}
/**
@@ -235,145 +235,145 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
*/
private synchronized Socket createDataSocket() throws Exception {
- // get socket depending on the selection
- dataSoc = null;
- DataConnectionConfiguration dataConfig = session.getListener().getDataConnectionConfiguration();
- try {
- if (!passive) {
- if (secure) {
- LOG.debug("Opening secure active data connection");
- SslConfiguration ssl = getSslConfiguration();
- if (ssl == null) {
- throw new FtpException("Data connection SSL not configured");
- }
-
- // get socket factory
- SSLSocketFactory socFactory = ssl.getSocketFactory();
-
- // create socket
- SSLSocket ssoc = (SSLSocket) socFactory.createSocket();
- ssoc.setUseClientMode(false);
-
- // initialize socket
- if (ssl.getEnabledCipherSuites() != null) {
- ssoc.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
- }
-
- if (ssl.getEnabledProtocol() != null) {
- ssoc.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
- }
- dataSoc = ssoc;
- } else {
- LOG.debug("Opening active data connection");
- dataSoc = new Socket();
- }
-
- dataSoc.setReuseAddress(true);
-
- InetAddress localAddr = resolveAddress(dataConfig.getActiveLocalAddress());
-
- // if no local address has been configured, make sure we use the same as the client connects from
- if (localAddr == null) {
- localAddr = ((InetSocketAddress) session.getLocalAddress()).getAddress();
- }
-
- SocketAddress localSocketAddress = new InetSocketAddress(localAddr, dataConfig.getActiveLocalPort());
-
- LOG.debug("Binding active data connection to {}", localSocketAddress);
- dataSoc.bind(localSocketAddress);
-
- dataSoc.connect(new InetSocketAddress(address, port));
- } else {
-
- if (secure) {
- LOG.debug("Opening secure passive data connection");
- // this is where we wrap the unsecured socket as a SSLSocket. This is
- // due to the JVM bug described in FTPSERVER-241.
-
- // get server socket factory
- SslConfiguration ssl = getSslConfiguration();
-
- // we've already checked this, but let's do it again
- if (ssl == null) {
- throw new FtpException("Data connection SSL not configured");
- }
-
- SSLSocketFactory ssocketFactory = ssl.getSocketFactory();
-
- Socket serverSocket = servSoc.accept();
-
- SSLSocket sslSocket = (SSLSocket) ssocketFactory.createSocket(serverSocket, serverSocket.getInetAddress().getHostAddress(), serverSocket.getPort(), true);
- sslSocket.setUseClientMode(false);
-
- // initialize server socket
- if (ssl.getClientAuth() == ClientAuth.NEED) {
- sslSocket.setNeedClientAuth(true);
- } else if (ssl.getClientAuth() == ClientAuth.WANT) {
- sslSocket.setWantClientAuth(true);
- }
-
- if (ssl.getEnabledCipherSuites() != null) {
- sslSocket.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
- }
-
- if (ssl.getEnabledProtocol() != null) {
- sslSocket.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
- }
-
- dataSoc = sslSocket;
- } else {
- LOG.debug("Opening passive data connection");
-
- dataSoc = servSoc.accept();
- }
-
- if (dataConfig.isPassiveIpCheck()) {
- // Let's make sure we got the connection from the same
- // client that we are expecting
- InetAddress remoteAddress = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
- InetAddress dataSocketAddress = dataSoc.getInetAddress();
- if (!dataSocketAddress.equals(remoteAddress)) {
- LOG.warn("Passive IP Check failed. Closing data connection from " + dataSocketAddress + " as it does not match the expected address " + remoteAddress);
- closeDataConnection();
- return null;
- }
- }
-
- DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
-
- dataSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);
- LOG.debug("Passive data connection opened");
- }
- } catch (Exception ex) {
- closeDataConnection();
- LOG.warn("FtpDataConnection.getDataSocket()", ex);
- throw ex;
- }
- dataSoc.setSoTimeout(dataConfig.getIdleTime() * 1000);
-
- // Make sure we initiate the SSL handshake, or we'll
- // get an error if we turn out not to send any data
- // e.g. during the listing of an empty directory
- if (dataSoc instanceof SSLSocket) {
- ((SSLSocket) dataSoc).startHandshake();
- }
-
- return dataSoc;
+ // get socket depending on the selection
+ dataSoc = null;
+ DataConnectionConfiguration dataConfig = session.getListener().getDataConnectionConfiguration();
+ try {
+ if (!passive) {
+ if (secure) {
+ LOG.debug("Opening secure active data connection");
+ SslConfiguration ssl = getSslConfiguration();
+ if (ssl == null) {
+ throw new FtpException("Data connection SSL not configured");
+ }
+
+ // get socket factory
+ SSLSocketFactory socFactory = ssl.getSocketFactory();
+
+ // create socket
+ SSLSocket ssoc = (SSLSocket) socFactory.createSocket();
+ ssoc.setUseClientMode(false);
+
+ // initialize socket
+ if (ssl.getEnabledCipherSuites() != null) {
+ ssoc.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
+ }
+
+ if (ssl.getEnabledProtocol() != null) {
+ ssoc.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
+ }
+ dataSoc = ssoc;
+ } else {
+ LOG.debug("Opening active data connection");
+ dataSoc = new Socket();
+ }
+
+ dataSoc.setReuseAddress(true);
+
+ InetAddress localAddr = resolveAddress(dataConfig.getActiveLocalAddress());
+
+ // if no local address has been configured, make sure we use the same as the client connects from
+ if (localAddr == null) {
+ localAddr = ((InetSocketAddress) session.getLocalAddress()).getAddress();
+ }
+
+ SocketAddress localSocketAddress = new InetSocketAddress(localAddr, dataConfig.getActiveLocalPort());
+
+ LOG.debug("Binding active data connection to {}", localSocketAddress);
+ dataSoc.bind(localSocketAddress);
+
+ dataSoc.connect(new InetSocketAddress(address, port));
+ } else {
+
+ if (secure) {
+ LOG.debug("Opening secure passive data connection");
+ // this is where we wrap the unsecured socket as a SSLSocket. This is
+ // due to the JVM bug described in FTPSERVER-241.
+
+ // get server socket factory
+ SslConfiguration ssl = getSslConfiguration();
+
+ // we've already checked this, but let's do it again
+ if (ssl == null) {
+ throw new FtpException("Data connection SSL not configured");
+ }
+
+ SSLSocketFactory ssocketFactory = ssl.getSocketFactory();
+
+ Socket serverSocket = servSoc.accept();
+
+ SSLSocket sslSocket = (SSLSocket) ssocketFactory.createSocket(serverSocket, serverSocket.getInetAddress().getHostAddress(), serverSocket.getPort(), true);
+ sslSocket.setUseClientMode(false);
+
+ // initialize server socket
+ if (ssl.getClientAuth() == ClientAuth.NEED) {
+ sslSocket.setNeedClientAuth(true);
+ } else if (ssl.getClientAuth() == ClientAuth.WANT) {
+ sslSocket.setWantClientAuth(true);
+ }
+
+ if (ssl.getEnabledCipherSuites() != null) {
+ sslSocket.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
+ }
+
+ if (ssl.getEnabledProtocol() != null) {
+ sslSocket.setEnabledProtocols(new String[] { ssl.getEnabledProtocol() });
+ }
+
+ dataSoc = sslSocket;
+ } else {
+ LOG.debug("Opening passive data connection");
+
+ dataSoc = servSoc.accept();
+ }
+
+ if (dataConfig.isPassiveIpCheck()) {
+ // Let's make sure we got the connection from the same
+ // client that we are expecting
+ InetAddress remoteAddress = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
+ InetAddress dataSocketAddress = dataSoc.getInetAddress();
+ if (!dataSocketAddress.equals(remoteAddress)) {
+ LOG.warn("Passive IP Check failed. Closing data connection from " + dataSocketAddress + " as it does not match the expected address " + remoteAddress);
+ closeDataConnection();
+ return null;
+ }
+ }
+
+ DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
+
+ dataSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);
+ LOG.debug("Passive data connection opened");
+ }
+ } catch (Exception ex) {
+ closeDataConnection();
+ LOG.warn("FtpDataConnection.getDataSocket()", ex);
+ throw ex;
+ }
+ dataSoc.setSoTimeout(dataConfig.getIdleTime() * 1000);
+
+ // Make sure we initiate the SSL handshake, or we'll
+ // get an error if we turn out not to send any data
+ // e.g. during the listing of an empty directory
+ if (dataSoc instanceof SSLSocket) {
+ ((SSLSocket) dataSoc).startHandshake();
+ }
+
+ return dataSoc;
}
/*
* (non-Javadoc) Returns an InetAddress object from a hostname or IP address.
*/
private InetAddress resolveAddress(String host) throws DataConnectionException {
- if (host == null) {
- return null;
- } else {
- try {
- return InetAddress.getByName(host);
- } catch (UnknownHostException ex) {
- throw new DataConnectionException("Failed to resolve address", ex);
- }
- }
+ if (host == null) {
+ return null;
+ } else {
+ try {
+ return InetAddress.getByName(host);
+ } catch (UnknownHostException ex) {
+ throw new DataConnectionException("Failed to resolve address", ex);
+ }
+ }
}
/*
@@ -382,14 +382,14 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
* @see org.apache.ftpserver.DataConnectionFactory#isSecure()
*/
public boolean isSecure() {
- return secure;
+ return secure;
}
/**
* Set the security protocol.
*/
public void setSecure(final boolean secure) {
- this.secure = secure;
+ this.secure = secure;
}
/*
@@ -398,14 +398,14 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
* @see org.apache.ftpserver.DataConnectionFactory#isZipMode()
*/
public boolean isZipMode() {
- return isZip;
+ return isZip;
}
/**
* Set zip mode.
*/
public void setZipMode(final boolean zip) {
- isZip = zip;
+ isZip = zip;
}
/**
@@ -413,41 +413,41 @@ public class IODataConnectionFactory implements ServerDataConnectionFactory {
*/
public synchronized boolean isTimeout(final long currTime) {
- // data connection not requested - not a timeout
- if (requestTime == 0L) {
- return false;
- }
+ // data connection not requested - not a timeout
+ if (requestTime == 0L) {
+ return false;
+ }
- // data connection active - not a timeout
- if (dataSoc != null) {
- return false;
- }
+ // data connection active - not a timeout
+ if (dataSoc != null) {
+ return false;
+ }
- // no idle time limit - not a timeout
- int maxIdleTime = session.getListener().getDataConnectionConfiguration().getIdleTime() * 1000;
- if (maxIdleTime == 0) {
- return false;
- }
+ // no idle time limit - not a timeout
+ int maxIdleTime = session.getListener().getDataConnectionConfiguration().getIdleTime() * 1000;
+ if (maxIdleTime == 0) {
+ return false;
+ }
- // idle time is within limit - not a timeout
- if ((currTime - requestTime) < maxIdleTime) {
- return false;
- }
+ // idle time is within limit - not a timeout
+ if ((currTime - requestTime) < maxIdleTime) {
+ return false;
+ }
- return true;
+ return true;
}
/**
* Dispose data connection - close all the sockets.
*/
public void dispose() {
- closeDataConnection();
+ closeDataConnection();
}
/**
* Sets the server's control address.
*/
public void setServerControlAddress(final InetAddress serverControlAddress) {
- this.serverControlAddress = serverControlAddress;
+ this.serverControlAddress = serverControlAddress;
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/LocalizedDataTransferFtpReply.java b/core/src/main/java/org/apache/ftpserver/impl/LocalizedDataTransferFtpReply.java
index 12f367e..47eb0ca 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/LocalizedDataTransferFtpReply.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/LocalizedDataTransferFtpReply.java
@@ -31,104 +31,104 @@ import org.apache.ftpserver.ftplet.FtpRequest;
*/
public class LocalizedDataTransferFtpReply extends LocalizedFtpReply implements
- DataTransferFtpReply {
+ DataTransferFtpReply {
- /**
- * The file or directory that data transfer is related to.
- */
- private final FtpFile file;
+ /**
+ * The file or directory that data transfer is related to.
+ */
+ private final FtpFile file;
- /**
- * total number of bytes transferred (bytes sent to the client or receivved
- * from the client)
- */
- private final long bytesTransferred;
+ /**
+ * total number of bytes transferred (bytes sent to the client or receivved
+ * from the client)
+ */
+ private final long bytesTransferred;
- /**
- * Creates a new instance of <code>LocalizedFileTransferReply</code>.
- *
- * @param code
- * the reply code
- * @param message
- * the detailed message
- * @param file
- * the file or directory the data transfer is related to
- * @param bytesTransferred
- * the number of bytes transferred
- */
- public LocalizedDataTransferFtpReply(int code, String message,
- FtpFile file, long bytesTransferred) {
- super(code, message);
- this.file = file;
- this.bytesTransferred = bytesTransferred;
- }
+ /**
+ * Creates a new instance of <code>LocalizedFileTransferReply</code>.
+ *
+ * @param code
+ * the reply code
+ * @param message
+ * the detailed message
+ * @param file
+ * the file or directory the data transfer is related to
+ * @param bytesTransferred
+ * the number of bytes transferred
+ */
+ public LocalizedDataTransferFtpReply(int code, String message,
+ FtpFile file, long bytesTransferred) {
+ super(code, message);
+ this.file = file;
+ this.bytesTransferred = bytesTransferred;
+ }
- public FtpFile getFile() {
- return file;
- }
+ public FtpFile getFile() {
+ return file;
+ }
- public long getBytesTransferred() {
- return bytesTransferred;
- }
+ public long getBytesTransferred() {
+ return bytesTransferred;
+ }
- /**
- * Returns the localized reply that contains all details about the data
- * transfer.
- *
- * @param session
- * the FTP session
- * @param request
- * the FTP request
- * @param context
- * the FTP server context
- * @param code
- * the reply code
- * @param subId
- * the sub message ID
- * @param basicMsg
- * the basic message
- * @param file
- * the file or directory that was transferred
- * @return the localized reply
- */
- public static LocalizedDataTransferFtpReply translate(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code, String subId,
- String basicMsg, FtpFile file) {
- String msg = FtpReplyTranslator.translateMessage(session, request,
- context, code, subId, basicMsg);
+ /**
+ * Returns the localized reply that contains all details about the data
+ * transfer.
+ *
+ * @param session
+ * the FTP session
+ * @param request
+ * the FTP request
+ * @param context
+ * the FTP server context
+ * @param code
+ * the reply code
+ * @param subId
+ * the sub message ID
+ * @param basicMsg
+ * the basic message
+ * @param file
+ * the file or directory that was transferred
+ * @return the localized reply
+ */
+ public static LocalizedDataTransferFtpReply translate(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code, String subId,
+ String basicMsg, FtpFile file) {
+ String msg = FtpReplyTranslator.translateMessage(session, request,
+ context, code, subId, basicMsg);
- return new LocalizedDataTransferFtpReply(code, msg, file, 0);
- }
+ return new LocalizedDataTransferFtpReply(code, msg, file, 0);
+ }
- /**
- * Returns the localized reply that contains all details about the data
- * transfer.
- *
- * @param session
- * the FTP session
- * @param request
- * the FTP request
- * @param context
- * the FTP server context
- * @param code
- * the reply code
- * @param subId
- * the sub message ID
- * @param basicMsg
- * the basic message
- * @param file
- * the file or directory that was transferred
- * @param bytesTransferred
- * total number of bytes transferred
- * @return the localized reply
- */
- public static LocalizedDataTransferFtpReply translate(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code, String subId,
- String basicMsg, FtpFile file, long bytesTransferred) {
- String msg = FtpReplyTranslator.translateMessage(session, request,
- context, code, subId, basicMsg);
+ /**
+ * Returns the localized reply that contains all details about the data
+ * transfer.
+ *
+ * @param session
+ * the FTP session
+ * @param request
+ * the FTP request
+ * @param context
+ * the FTP server context
+ * @param code
+ * the reply code
+ * @param subId
+ * the sub message ID
+ * @param basicMsg
+ * the basic message
+ * @param file
+ * the file or directory that was transferred
+ * @param bytesTransferred
+ * total number of bytes transferred
+ * @return the localized reply
+ */
+ public static LocalizedDataTransferFtpReply translate(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code, String subId,
+ String basicMsg, FtpFile file, long bytesTransferred) {
+ String msg = FtpReplyTranslator.translateMessage(session, request,
+ context, code, subId, basicMsg);
- return new LocalizedDataTransferFtpReply(code, msg, file,
- bytesTransferred);
- }
+ return new LocalizedDataTransferFtpReply(code, msg, file,
+ bytesTransferred);
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/LocalizedFileActionFtpReply.java b/core/src/main/java/org/apache/ftpserver/impl/LocalizedFileActionFtpReply.java
index a867c70..e641a4f 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/LocalizedFileActionFtpReply.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/LocalizedFileActionFtpReply.java
@@ -31,58 +31,58 @@ import org.apache.ftpserver.ftplet.FtpRequest;
*/
public class LocalizedFileActionFtpReply extends LocalizedFtpReply implements
- FileActionFtpReply {
+ FileActionFtpReply {
- /**
- * The file or directory that data transfer is related to.
- */
- private final FtpFile file;
+ /**
+ * The file or directory that data transfer is related to.
+ */
+ private final FtpFile file;
- /**
- * Creates a new instance of <code>LocalizedFileTransferReply</code>.
- *
- * @param code
- * the reply code
- * @param message
- * the detailed message
- * @param file
- * the file or directory the data transfer is related to
- */
- public LocalizedFileActionFtpReply(int code, String message, FtpFile file) {
- super(code, message);
- this.file = file;
- }
+ /**
+ * Creates a new instance of <code>LocalizedFileTransferReply</code>.
+ *
+ * @param code
+ * the reply code
+ * @param message
+ * the detailed message
+ * @param file
+ * the file or directory the data transfer is related to
+ */
+ public LocalizedFileActionFtpReply(int code, String message, FtpFile file) {
+ super(code, message);
+ this.file = file;
+ }
- public FtpFile getFile() {
- return file;
- }
+ public FtpFile getFile() {
+ return file;
+ }
- /**
- * Returns the localized reply that contains all details about the data
- * transfer.
- *
- * @param session
- * the FTP session
- * @param request
- * the FTP request
- * @param context
- * the FTP server context
- * @param code
- * the reply code
- * @param subId
- * the sub message ID
- * @param basicMsg
- * the basic message
- * @param file
- * the file or directory that was transferred
- * @return the localized reply
- */
- public static LocalizedFileActionFtpReply translate(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code, String subId,
- String basicMsg, FtpFile file) {
- String msg = FtpReplyTranslator.translateMessage(session, request,
- context, code, subId, basicMsg);
+ /**
+ * Returns the localized reply that contains all details about the data
+ * transfer.
+ *
+ * @param session
+ * the FTP session
+ * @param request
+ * the FTP request
+ * @param context
+ * the FTP server context
+ * @param code
+ * the reply code
+ * @param subId
+ * the sub message ID
+ * @param basicMsg
+ * the basic message
+ * @param file
+ * the file or directory that was transferred
+ * @return the localized reply
+ */
+ public static LocalizedFileActionFtpReply translate(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code, String subId,
+ String basicMsg, FtpFile file) {
+ String msg = FtpReplyTranslator.translateMessage(session, request,
+ context, code, subId, basicMsg);
- return new LocalizedFileActionFtpReply(code, msg, file);
- }
+ return new LocalizedFileActionFtpReply(code, msg, file);
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/LocalizedFtpReply.java b/core/src/main/java/org/apache/ftpserver/impl/LocalizedFtpReply.java
index 675df07..7c85a93 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/LocalizedFtpReply.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/LocalizedFtpReply.java
@@ -40,13 +40,13 @@ public class LocalizedFtpReply extends DefaultFtpReply {
}
/**
- * Creates a new instance of <code>LocalizedFtpReply</code>.
- *
- * @param code
- * the reply code
- * @param message
- * the reply text
- */
+ * Creates a new instance of <code>LocalizedFtpReply</code>.
+ *
+ * @param code
+ * the reply code
+ * @param message
+ * the reply text
+ */
public LocalizedFtpReply(int code, String message) {
super(code, message);
}
diff --git a/core/src/main/java/org/apache/ftpserver/impl/LocalizedRenameFtpReply.java b/core/src/main/java/org/apache/ftpserver/impl/LocalizedRenameFtpReply.java
index f822506..f74418b 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/LocalizedRenameFtpReply.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/LocalizedRenameFtpReply.java
@@ -32,72 +32,72 @@ import org.apache.ftpserver.ftplet.RenameFtpReply;
*/
public class LocalizedRenameFtpReply extends LocalizedFtpReply implements
- RenameFtpReply {
+ RenameFtpReply {
- /**
- * The from file
- */
- private final FtpFile from;
+ /**
+ * The from file
+ */
+ private final FtpFile from;
- /**
- * The to file
- */
- private final FtpFile to;
+ /**
+ * The to file
+ */
+ private final FtpFile to;
- /**
- * Creates a new instance of <code>LocalizedRenameFtpReply</code>.
- *
- * @param code
- * the reply code
- * @param message
- * the detailed message
- * @param from
- * the old file
- * @param to
- * the new file
- */
- public LocalizedRenameFtpReply(int code, String message, FtpFile from,
- FtpFile to) {
- super(code, message);
- this.from = from;
- this.to = to;
- }
+ /**
+ * Creates a new instance of <code>LocalizedRenameFtpReply</code>.
+ *
+ * @param code
+ * the reply code
+ * @param message
+ * the detailed message
+ * @param from
+ * the old file
+ * @param to
+ * the new file
+ */
+ public LocalizedRenameFtpReply(int code, String message, FtpFile from,
+ FtpFile to) {
+ super(code, message);
+ this.from = from;
+ this.to = to;
+ }
- public FtpFile getFrom() {
- return from;
- }
+ public FtpFile getFrom() {
+ return from;
+ }
- public FtpFile getTo() {
- return to;
- }
+ public FtpFile getTo() {
+ return to;
+ }
- /**
- * Returns the localized reply that contains all details about the rename
- * operation.
- *
- * @param session
- * the FTP session
- * @param request
- * the FTP request
- * @param context
- * the FTP server context
- * @param code
- * the reply code
- * @param subId
- * the sub message ID
- * @param basicMsg
- * the basic message
- * @param from
- * the file or directory as it was before the rename
- * @param to
- * the file or directory after the rename
- * @return the localized reply
- */
- public static LocalizedRenameFtpReply translate(FtpIoSession session,
- FtpRequest request, FtpServerContext context, int code, String subId,
- String basicMsg, FtpFile from, FtpFile to) {
- String msg = FtpReplyTranslator.translateMessage(session, request,
- context, code, subId, basicMsg);
- return new LocalizedRenameFtpReply(code, msg, from, to);
- }
+ /**
+ * Returns the localized reply that contains all details about the rename
+ * operation.
+ *
+ * @param session
+ * the FTP session
+ * @param request
+ * the FTP request
+ * @param context
+ * the FTP server context
+ * @param code
+ * the reply code
+ * @param subId
+ * the sub message ID
+ * @param basicMsg
+ * the basic message
+ * @param from
+ * the file or directory as it was before the rename
+ * @param to
+ * the file or directory after the rename
+ * @return the localized reply
+ */
+ public static LocalizedRenameFtpReply translate(FtpIoSession session,
+ FtpRequest request, FtpServerContext context, int code, String subId,
+ String basicMsg, FtpFile from, FtpFile to) {
+ String msg = FtpReplyTranslator.translateMessage(session, request,
+ context, code, subId, basicMsg);
+ return new LocalizedRenameFtpReply(code, msg, from, to);
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/ipfilter/IpFilterType.java b/core/src/main/java/org/apache/ftpserver/ipfilter/IpFilterType.java
index 569417d..0924b0f 100644
--- a/core/src/main/java/org/apache/ftpserver/ipfilter/IpFilterType.java
+++ b/core/src/main/java/org/apache/ftpserver/ipfilter/IpFilterType.java
@@ -27,32 +27,32 @@ package org.apache.ftpserver.ipfilter;
*/
public enum IpFilterType {
- /**
- * filter type that allows a set of predefined IP addresses, also known as a
- * white list.
- */
- ALLOW,
+ /**
+ * filter type that allows a set of predefined IP addresses, also known as a
+ * white list.
+ */
+ ALLOW,
- /**
- * filter type that blocks a set of predefined IP addresses, also known as a
- * black list.
- */
- DENY;
+ /**
+ * filter type that blocks a set of predefined IP addresses, also known as a
+ * black list.
+ */
+ DENY;
- /**
- * Parses the given string into its equivalent enum.
- *
- * @param value
- * the string value to parse.
- * @return the equivalent enum
- */
- public static IpFilterType parse(String value) {
- for (IpFilterType type : values()) {
- if (type.name().equalsIgnoreCase(value)) {
- return type;
- }
- }
- throw new IllegalArgumentException("Invalid IpFilterType: " + value);
- }
+ /**
+ * Parses the given string into its equivalent enum.
+ *
+ * @param value
+ * the string value to parse.
+ * @return the equivalent enum
+ */
+ public static IpFilterType parse(String value) {
+ for (IpFilterType type : values()) {
+ if (type.name().equalsIgnoreCase(value)) {
+ return type;
+ }
+ }
+ throw new IllegalArgumentException("Invalid IpFilterType: " + value);
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/listener/nio/AbstractListener.java b/core/src/main/java/org/apache/ftpserver/listener/nio/AbstractListener.java
index bb51923..7a4477f 100644
--- a/core/src/main/java/org/apache/ftpserver/listener/nio/AbstractListener.java
+++ b/core/src/main/java/org/apache/ftpserver/listener/nio/AbstractListener.java
@@ -73,8 +73,8 @@ public abstract class AbstractListener implements Listener {
this.ssl = sslConfiguration;
this.idleTimeout = idleTimeout;
this.sessionFilter = createBlackListFilter(blockedAddresses, blockedSubnets);
- this.blockedAddresses = blockedAddresses;
- this.blockedSubnets = blockedSubnets;
+ this.blockedAddresses = blockedAddresses;
+ this.blockedSubnets = blockedSubnets;
}
/**
diff --git a/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java b/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
index 4cbf62a..0b1e5a7 100644
--- a/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
+++ b/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
@@ -79,133 +79,133 @@ public class NioListener extends AbstractListener {
*/
@Deprecated
public NioListener(String serverAddress, int port, boolean implicitSsl, SslConfiguration sslConfiguration, DataConnectionConfiguration dataConnectionConfig, int idleTimeout, List<InetAddress> blockedAddresses, List<Subnet> blockedSubnets) {
- super(serverAddress, port, implicitSsl, sslConfiguration, dataConnectionConfig, idleTimeout, blockedAddresses, blockedSubnets);
+ super(serverAddress, port, implicitSsl, sslConfiguration, dataConnectionConfig, idleTimeout, blockedAddresses, blockedSubnets);
}
/**
* Constructor for internal use, do not use directly. Instead use {@link ListenerFactory}
*/
public NioListener(String serverAddress, int port, boolean implicitSsl, SslConfiguration sslConfiguration, DataConnectionConfiguration dataConnectionConfig, int idleTimeout, SessionFilter sessionFilter) {
- super(serverAddress, port, implicitSsl, sslConfiguration, dataConnectionConfig, idleTimeout, sessionFilter);
+ super(serverAddress, port, implicitSsl, sslConfiguration, dataConnectionConfig, idleTimeout, sessionFilter);
}
/**
* @see Listener#start(FtpServerContext)
*/
public synchronized void start(FtpServerContext context) {
- if (!isStopped()) {
- // listener already started, don't allow
- throw new IllegalStateException("Listener already started");
- }
-
- try {
-
- this.context = context;
-
- acceptor = new NioSocketAcceptor(Runtime.getRuntime().availableProcessors());
-
- if (getServerAddress() != null) {
- address = new InetSocketAddress(getServerAddress(), getPort());
- } else {
- address = new InetSocketAddress(getPort());
- }
-
- acceptor.setReuseAddress(true);
- acceptor.getSessionConfig().setReadBufferSize(2048);
- acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, getIdleTimeout());
- // Decrease the default receiver buffer size
- acceptor.getSessionConfig().setReceiveBufferSize(512);
-
- MdcInjectionFilter mdcFilter = new MdcInjectionFilter();
-
- acceptor.getFilterChain().addLast("mdcFilter", mdcFilter);
-
- SessionFilter sessionFilter = getSessionFilter();
- if (sessionFilter != null) {
- // add and IP filter to the filter chain.
- acceptor.getFilterChain().addLast("sessionFilter", new MinaSessionFilter(sessionFilter));
- }
-
- acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(context.getThreadPoolExecutor()));
- acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new FtpServerProtocolCodecFactory()));
- acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
- acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter());
-
- if (isImplicitSsl()) {
- SslConfiguration ssl_conf = getSslConfiguration();
- SslFilter ssl_filter;
- try {
- ssl_filter = new SslFilter(ssl_conf.getSSLContext());
- } catch (GeneralSecurityException e) {
- throw new FtpServerConfigurationException("SSL could not be initialized, check configuration");
- }
-
- if (ssl_conf.getClientAuth() == ClientAuth.NEED) {
- ssl_filter.setNeedClientAuth(true);
- } else if (ssl_conf.getClientAuth() == ClientAuth.WANT) {
- ssl_filter.setWantClientAuth(true);
- }
-
- if (ssl_conf.getEnabledProtocol() != null) {
- ssl_filter.setEnabledProtocols(new String[] { ssl_conf.getEnabledProtocol() });
- }
-
- if (ssl_conf.getEnabledCipherSuites() != null) {
- ssl_filter.setEnabledCipherSuites(ssl_conf.getEnabledCipherSuites());
- }
-
- acceptor.getFilterChain().addFirst("sslFilter", ssl_filter);
- }
-
- handler.init(context, this);
- acceptor.setHandler(new FtpHandlerAdapter(context, handler));
-
- try {
- acceptor.bind(address);
- } catch (IOException e) {
- throw new FtpServerConfigurationException("Failed to bind to address " + address + ", check configuration", e);
- }
-
- updatePort();
-
- } catch (RuntimeException e) {
- // clean up if we fail to start
- stop();
-
- throw e;
- }
+ if (!isStopped()) {
+ // listener already started, don't allow
+ throw new IllegalStateException("Listener already started");
+ }
+
+ try {
+
+ this.context = context;
+
+ acceptor = new NioSocketAcceptor(Runtime.getRuntime().availableProcessors());
+
+ if (getServerAddress() != null) {
+ address = new InetSocketAddress(getServerAddress(), getPort());
+ } else {
+ address = new InetSocketAddress(getPort());
+ }
+
+ acceptor.setReuseAddress(true);
+ acceptor.getSessionConfig().setReadBufferSize(2048);
+ acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, getIdleTimeout());
+ // Decrease the default receiver buffer size
+ acceptor.getSessionConfig().setReceiveBufferSize(512);
+
+ MdcInjectionFilter mdcFilter = new MdcInjectionFilter();
+
+ acceptor.getFilterChain().addLast("mdcFilter", mdcFilter);
+
+ SessionFilter sessionFilter = getSessionFilter();
+ if (sessionFilter != null) {
+ // add and IP filter to the filter chain.
+ acceptor.getFilterChain().addLast("sessionFilter", new MinaSessionFilter(sessionFilter));
+ }
+
+ acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(context.getThreadPoolExecutor()));
+ acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new FtpServerProtocolCodecFactory()));
+ acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
+ acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter());
+
+ if (isImplicitSsl()) {
+ SslConfiguration ssl_conf = getSslConfiguration();
+ SslFilter ssl_filter;
+ try {
+ ssl_filter = new SslFilter(ssl_conf.getSSLContext());
+ } catch (GeneralSecurityException e) {
+ throw new FtpServerConfigurationException("SSL could not be initialized, check configuration");
+ }
+
+ if (ssl_conf.getClientAuth() == ClientAuth.NEED) {
+ ssl_filter.setNeedClientAuth(true);
+ } else if (ssl_conf.getClientAuth() == ClientAuth.WANT) {
+ ssl_filter.setWantClientAuth(true);
+ }
+
+ if (ssl_conf.getEnabledProtocol() != null) {
+ ssl_filter.setEnabledProtocols(new String[] { ssl_conf.getEnabledProtocol() });
+ }
+
+ if (ssl_conf.getEnabledCipherSuites() != null) {
+ ssl_filter.setEnabledCipherSuites(ssl_conf.getEnabledCipherSuites());
+ }
+
+ acceptor.getFilterChain().addFirst("sslFilter", ssl_filter);
+ }
+
+ handler.init(context, this);
+ acceptor.setHandler(new FtpHandlerAdapter(context, handler));
+
+ try {
+ acceptor.bind(address);
+ } catch (IOException e) {
+ throw new FtpServerConfigurationException("Failed to bind to address " + address + ", check configuration", e);
+ }
+
+ updatePort();
+
+ } catch (RuntimeException e) {
+ // clean up if we fail to start
+ stop();
+
+ throw e;
+ }
}
private void updatePort() {
- // update the port to the real port bound by the listener
- setPort(acceptor.getLocalAddress().getPort());
+ // update the port to the real port bound by the listener
+ setPort(acceptor.getLocalAddress().getPort());
}
/**
* @see Listener#stop()
*/
public synchronized void stop() {
- // close server socket
- if (acceptor != null) {
- acceptor.unbind();
- acceptor.dispose();
- acceptor = null;
- }
- context = null;
+ // close server socket
+ if (acceptor != null) {
+ acceptor.unbind();
+ acceptor.dispose();
+ acceptor = null;
+ }
+ context = null;
}
/**
* @see Listener#isStopped()
*/
public boolean isStopped() {
- return acceptor == null;
+ return acceptor == null;
}
/**
* @see Listener#isSuspended()
*/
public boolean isSuspended() {
- return suspended;
+ return suspended;
}
@@ -213,44 +213,44 @@ public class NioListener extends AbstractListener {
* @see Listener#resume()
*/
public synchronized void resume() {
- if (acceptor != null && suspended) {
- try {
- LOG.debug("Resuming listener");
- acceptor.bind(address);
- LOG.debug("Listener resumed");
-
- updatePort();
-
- suspended = false;
- } catch (IOException e) {
- LOG.error("Failed to resume listener", e);
- }
- }
+ if (acceptor != null && suspended) {
+ try {
+ LOG.debug("Resuming listener");
+ acceptor.bind(address);
+ LOG.debug("Listener resumed");
+
+ updatePort();
+
+ suspended = false;
+ } catch (IOException e) {
+ LOG.error("Failed to resume listener", e);
+ }
+ }
}
/**
* @see Listener#suspend()
*/
public synchronized void suspend() {
- if (acceptor != null && !suspended) {
- LOG.debug("Suspending listener");
- acceptor.unbind();
+ if (acceptor != null && !suspended) {
+ LOG.debug("Suspending listener");
+ acceptor.unbind();
- suspended = true;
- LOG.debug("Listener suspended");
- }
+ suspended = true;
+ LOG.debug("Listener suspended");
+ }
}
/**
* @see Listener#getActiveSessions()
*/
public synchronized Set<FtpIoSession> getActiveSessions() {
- Map<Long, IoSession> sessions = acceptor.getManagedSessions();
+ Map<Long, IoSession> sessions = acceptor.getManagedSessions();
- Set<FtpIoSession> ftpSessions = new HashSet<FtpIoSession>();
- for (IoSession session : sessions.values()) {
- ftpSessions.add(new FtpIoSession(session, context));
- }
- return ftpSessions;
+ Set<FtpIoSession> ftpSessions = new HashSet<FtpIoSession>();
+ for (IoSession session : sessions.values()) {
+ ftpSessions.add(new FtpIoSession(session, context));
+ }
+ return ftpSessions;
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java b/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
index a590148..b6778d7 100644
--- a/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
+++ b/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
@@ -76,7 +76,7 @@ public class SslConfigurationFactory {
* @return The key store file
*/
public File getKeystoreFile() {
- return keystoreFile;
+ return keystoreFile;
}
/**
@@ -86,9 +86,9 @@ public class SslConfigurationFactory {
* A path to an existing key store file
*/
public void setKeystoreFile(File keyStoreFile) {
- if (keyStoreFile == null || keyStoreFile.length() == 0)
- throw new FtpServerConfigurationException("KeystoreFile must not be null or zero length");
- this.keystoreFile = keyStoreFile;
+ if (keyStoreFile == null || keyStoreFile.length() == 0)
+ throw new FtpServerConfigurationException("KeystoreFile must not be null or zero length");
+ this.keystoreFile = keyStoreFile;
}
/**
@@ -97,7 +97,7 @@ public class SslConfigurationFactory {
* @return The password
*/
public String getKeystorePassword() {
- return keystorePass;
+ return keystorePass;
}
/**
@@ -107,7 +107,7 @@ public class SslConfigurationFactory {
* The password
*/
public void setKeystorePassword(String keystorePass) {
- this.keystorePass = keystorePass;
+ this.keystorePass = keystorePass;
}
/**
@@ -116,7 +116,7 @@ public class SslConfigurationFactory {
* @return The key store type
*/
public String getKeystoreType() {
- return keystoreType;
+ return keystoreType;
}
/**
@@ -126,9 +126,9 @@ public class SslConfigurationFactory {
* The key store type
*/
public void setKeystoreType(String keystoreType) {
- if (keystoreType == null || keystoreType.length() == 0)
- throw new FtpServerConfigurationException("KeystoreType must not be null or zero length");
- this.keystoreType = keystoreType;
+ if (keystoreType == null || keystoreType.length() == 0)
+ throw new FtpServerConfigurationException("KeystoreType must not be null or zero length");
+ this.keystoreType = keystoreType;
}
/**
@@ -137,7 +137,7 @@ public class SslConfigurationFactory {
* @return The key store algorithm
*/
public String getKeystoreAlgorithm() {
- return keystoreAlgorithm;
+ return keystoreAlgorithm;
}
/**
@@ -147,9 +147,9 @@ public class SslConfigurationFactory {
* The key store algorithm
*/
public void setKeystoreAlgorithm(String keystoreAlgorithm) {
- if (keystoreAlgorithm == null || keystoreAlgorithm.length() == 0)
- throw new FtpServerConfigurationException("KeystoreAlgorithm must not be null or zero length");
- this.keystoreAlgorithm = keystoreAlgorithm;
+ if (keystoreAlgorithm == null || keystoreAlgorithm.length() == 0)
+ throw new FtpServerConfigurationException("KeystoreAlgorithm must not be null or zero length");
+ this.keystoreAlgorithm = keystoreAlgorithm;
}
@@ -159,7 +159,7 @@ public class SslConfigurationFactory {
* @return The SSL protocol
*/
public String getSslProtocol() {
- return sslProtocol;
+ return sslProtocol;
}
/**
@@ -169,9 +169,9 @@ public class SslConfigurationFactory {
* The SSL protocol
*/
public void setSslProtocol(String sslProtocol) {
- if (sslProtocol == null || sslProtocol.length() == 0)
- throw new FtpServerConfigurationException("SslProcotol must not be null or zero length");
- this.sslProtocol = sslProtocol;
+ if (sslProtocol == null || sslProtocol.length() == 0)
+ throw new FtpServerConfigurationException("SslProcotol must not be null or zero length");
+ this.sslProtocol = sslProtocol;
}
/**
@@ -182,13 +182,13 @@ public class SslConfigurationFactory {
* The desired authentication level
*/
public void setClientAuthentication(String clientAuthReqd) {
- if ("true".equalsIgnoreCase(clientAuthReqd) || "yes".equalsIgnoreCase(clientAuthReqd) || "need".equalsIgnoreCase(clientAuthReqd)) {
- this.clientAuth = ClientAuth.NEED;
- } else if ("want".equalsIgnoreCase(clientAuthReqd)) {
- this.clientAuth = ClientAuth.WANT;
- } else {
- this.clientAuth = ClientAuth.NONE;
- }
+ if ("true".equalsIgnoreCase(clientAuthReqd) || "yes".equalsIgnoreCase(clientAuthReqd) || "need".equalsIgnoreCase(clientAuthReqd)) {
+ this.clientAuth = ClientAuth.NEED;
+ } else if ("want".equalsIgnoreCase(clientAuthReqd)) {
+ this.clientAuth = ClientAuth.WANT;
+ } else {
+ this.clientAuth = ClientAuth.NONE;
+ }
}
/**
@@ -197,7 +197,7 @@ public class SslConfigurationFactory {
* @return The password
*/
public String getKeyPassword() {
- return keyPass;
+ return keyPass;
}
/**
@@ -207,7 +207,7 @@ public class SslConfigurationFactory {
* The password
*/
public void setKeyPassword(String keyPass) {
- this.keyPass = keyPass;
+ this.keyPass = keyPass;
}
/**
@@ -216,7 +216,7 @@ public class SslConfigurationFactory {
* @return The {@link File} containing the truststore
*/
public File getTruststoreFile() {
- return trustStoreFile;
+ return trustStoreFile;
}
/**
@@ -226,7 +226,7 @@ public class SslConfigurationFactory {
* The password
*/
public void setTruststoreFile(File trustStoreFile) {
- this.trustStoreFile = trustStoreFile;
+ this.trustStoreFile = trustStoreFile;
}
/**
@@ -235,7 +235,7 @@ public class SslConfigurationFactory {
* @return The password
*/
public String getTruststorePassword() {
- return trustStorePass;
+ return trustStorePass;
}
/**
@@ -245,7 +245,7 @@ public class SslConfigurationFactory {
* The password
*/
public void setTruststorePassword(String trustStorePass) {
- this.trustStorePass = trustStorePass;
+ this.trustStorePass = trustStorePass;
}
/**
@@ -254,7 +254,7 @@ public class SslConfigurationFactory {
* @return The trust store type
*/
public String getTruststoreType() {
- return trustStoreType;
+ return trustStoreType;
}
/**
@@ -264,7 +264,7 @@ public class SslConfigurationFactory {
* The trust store type
*/
public void setTruststoreType(String trustStoreType) {
- this.trustStoreType = trustStoreType;
+ this.trustStoreType = trustStoreType;
}
/**
@@ -273,7 +273,7 @@ public class SslConfigurationFactory {
* @return The trust store algorithm
*/
public String getTruststoreAlgorithm() {
- return trustStoreAlgorithm;
+ return trustStoreAlgorithm;
}
/**
@@ -283,32 +283,32 @@ public class SslConfigurationFactory {
* The trust store algorithm
*/
public void setTruststoreAlgorithm(String trustStoreAlgorithm) {
- this.trustStoreAlgorithm = trustStoreAlgorithm;
+ this.trustStoreAlgorithm = trustStoreAlgorithm;
}
private KeyStore loadStore(File storeFile, String storeType, String storePass) throws IOException, GeneralSecurityException {
- InputStream fin = null;
- try {
- if (storeFile.exists()) {
- LOG.debug("Trying to load store from file");
- fin = new FileInputStream(storeFile);
- } else {
- LOG.debug("Trying to load store from classpath");
- fin = getClass().getClassLoader().getResourceAsStream(storeFile.getPath());
-
- if (fin == null) {
- throw new FtpServerConfigurationException("Key store could not be loaded from " + storeFile.getPath());
- }
- }
-
- KeyStore store = KeyStore.getInstance(storeType);
- store.load(fin, storePass.toCharArray());
-
- return store;
- } finally {
- IoUtils.close(fin);
- }
+ InputStream fin = null;
+ try {
+ if (storeFile.exists()) {
+ LOG.debug("Trying to load store from file");
+ fin = new FileInputStream(storeFile);
+ } else {
+ LOG.debug("Trying to load store from classpath");
+ fin = getClass().getClassLoader().getResourceAsStream(storeFile.getPath());
+
+ if (fin == null) {
+ throw new FtpServerConfigurationException("Key store could not be loaded from " + storeFile.getPath());
+ }
+ }
+
+ KeyStore store = KeyStore.getInstance(storeType);
+ store.load(fin, storePass.toCharArray());
+
+ return store;
+ } finally {
+ IoUtils.close(fin);
+ }
}
/**
@@ -318,38 +318,38 @@ public class SslConfigurationFactory {
*/
public SslConfiguration createSslConfiguration() {
- try {
- // initialize keystore
- LOG.debug("Loading key store from \"{}\", using the key store type \"{}\"", keystoreFile.getAbsolutePath(), keystoreType);
- KeyStore keyStore = loadStore(keystoreFile, keystoreType, keystorePass);
-
- KeyStore trustStore;
- if (trustStoreFile != null) {
- LOG.debug("Loading trust store from \"{}\", using the key store type \"{}\"", trustStoreFile.getAbsolutePath(), trustStoreType);
- trustStore = loadStore(trustStoreFile, trustStoreType, trustStorePass);
- } else {
- trustStore = keyStore;
- }
-
- String keyPassToUse;
- if (keyPass == null) {
- keyPassToUse = keystorePass;
- } else {
- keyPassToUse = keyPass;
- }
- // initialize key manager factory
- KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(keystoreAlgorithm);
- keyManagerFactory.init(keyStore, keyPassToUse.toCharArray());
-
- // initialize trust manager factory
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
- trustManagerFactory.init(trustStore);
-
- return new DefaultSslConfiguration(keyManagerFactory, trustManagerFactory, clientAuth, sslProtocol, enabledCipherSuites, keyAlias);
- } catch (Exception ex) {
- LOG.error("DefaultSsl.configure()", ex);
- throw new FtpServerConfigurationException("DefaultSsl.configure()", ex);
- }
+ try {
+ // initialize keystore
+ LOG.debug("Loading key store from \"{}\", using the key store type \"{}\"", keystoreFile.getAbsolutePath(), keystoreType);
+ KeyStore keyStore = loadStore(keystoreFile, keystoreType, keystorePass);
+
+ KeyStore trustStore;
+ if (trustStoreFile != null) {
+ LOG.debug("Loading trust store from \"{}\", using the key store type \"{}\"", trustStoreFile.getAbsolutePath(), trustStoreType);
+ trustStore = loadStore(trustStoreFile, trustStoreType, trustStorePass);
+ } else {
+ trustStore = keyStore;
+ }
+
+ String keyPassToUse;
+ if (keyPass == null) {
+ keyPassToUse = keystorePass;
+ } else {
+ keyPassToUse = keyPass;
+ }
+ // initialize key manager factory
+ KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(keystoreAlgorithm);
+ keyManagerFactory.init(keyStore, keyPassToUse.toCharArray());
+
+ // initialize trust manager factory
+ TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
+ trustManagerFactory.init(trustStore);
+
+ return new DefaultSslConfiguration(keyManagerFactory, trustManagerFactory, clientAuth, sslProtocol, enabledCipherSuites, keyAlias);
+ } catch (Exception ex) {
+ LOG.error("DefaultSsl.configure()", ex);
+ throw new FtpServerConfigurationException("DefaultSsl.configure()", ex);
+ }
}
/**
@@ -359,7 +359,7 @@ public class SslConfigurationFactory {
* authentication is wanted or {@link ClientAuth#NONE} if no client authentication is the be performed
*/
public ClientAuth getClientAuth() {
- return clientAuth;
+ return clientAuth;
}
/**
@@ -369,11 +369,11 @@ public class SslConfigurationFactory {
* @return An array of cipher suites, or null.
*/
public String[] getEnabledCipherSuites() {
- if (enabledCipherSuites != null) {
- return enabledCipherSuites.clone();
- } else {
- return null;
- }
+ if (enabledCipherSuites != null) {
+ return enabledCipherSuites.clone();
+ } else {
+ return null;
+ }
}
/**
@@ -383,11 +383,11 @@ public class SslConfigurationFactory {
* @param enabledCipherSuites
*/
public void setEnabledCipherSuites(String[] enabledCipherSuites) {
- if (enabledCipherSuites != null) {
- this.enabledCipherSuites = enabledCipherSuites.clone();
- } else {
- this.enabledCipherSuites = null;
- }
+ if (enabledCipherSuites != null) {
+ this.enabledCipherSuites = enabledCipherSuites.clone();
+ } else {
+ this.enabledCipherSuites = null;
+ }
}
/**
@@ -396,7 +396,7 @@ public class SslConfigurationFactory {
* @return The alias, or null if none is set
*/
public String getKeyAlias() {
- return keyAlias;
+ return keyAlias;
}
/**
@@ -407,6 +407,6 @@ public class SslConfigurationFactory {
* The alias to use, or null if JSSE should be allowed to choose the key.
*/
public void setKeyAlias(String keyAlias) {
- this.keyAlias = keyAlias;
+ this.keyAlias = keyAlias;
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java b/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
index 15866bc..df960ef 100644
--- a/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
+++ b/core/src/main/java/org/apache/ftpserver/ssl/impl/DefaultSslConfiguration.java
@@ -66,77 +66,77 @@ public class DefaultSslConfiguration implements SslConfiguration {
* @throws GeneralSecurityException
*/
public DefaultSslConfiguration(KeyManagerFactory keyManagerFactory, TrustManagerFactory trustManagerFactory, ClientAuth clientAuthReqd, String sslProtocol, String[] enabledCipherSuites, String keyAlias) throws GeneralSecurityException {
- super();
- this.clientAuth = clientAuthReqd;
- this.enabledCipherSuites = enabledCipherSuites;
- this.keyAlias = keyAlias;
- this.keyManagerFactory = keyManagerFactory;
- this.enabledProtocol = sslProtocol;
- this.trustManagerFactory = trustManagerFactory;
- this.sslContext = initContext();
- this.socketFactory = sslContext.getSocketFactory();
+ super();
+ this.clientAuth = clientAuthReqd;
+ this.enabledCipherSuites = enabledCipherSuites;
+ this.keyAlias = keyAlias;
+ this.keyManagerFactory = keyManagerFactory;
+ this.enabledProtocol = sslProtocol;
+ this.trustManagerFactory = trustManagerFactory;
+ this.sslContext = initContext();
+ this.socketFactory = sslContext.getSocketFactory();
}
public SSLSocketFactory getSocketFactory() throws GeneralSecurityException {
- return socketFactory;
+ return socketFactory;
}
/**
* @see SslConfiguration#getSSLContext(String)
*/
public SSLContext getSSLContext(String protocol) throws GeneralSecurityException {
- return sslContext;
+ return sslContext;
}
/**
* @see SslConfiguration#getEnabledProtocol()
*/
public String getEnabledProtocol() {
- return enabledProtocol;
+ return enabledProtocol;
}
/**
* @see SslConfiguration#getClientAuth()
*/
public ClientAuth getClientAuth() {
- return clientAuth;
+ return clientAuth;
}
/**
* @see SslConfiguration#getSSLContext()
*/
public SSLContext getSSLContext() throws GeneralSecurityException {
- return getSSLContext(enabledProtocol);
+ return getSSLContext(enabledProtocol);
}
/**
* @see SslConfiguration#getEnabledCipherSuites()
*/
public String[] getEnabledCipherSuites() {
- if (enabledCipherSuites != null) {
- return enabledCipherSuites.clone();
- } else {
- return null;
- }
+ if (enabledCipherSuites != null) {
+ return enabledCipherSuites.clone();
+ } else {
+ return null;
+ }
}
private SSLContext initContext() throws GeneralSecurityException {
- KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
-
- // wrap key managers to allow us to control their behavior
- // (FTPSERVER-93)
- for (int i = 0; i < keyManagers.length; i++) {
- if (ClassUtils.extendsClass(keyManagers[i].getClass(), "javax.net.ssl.X509ExtendedKeyManager")) {
- keyManagers[i] = new ExtendedAliasKeyManager(keyManagers[i], keyAlias);
- } else if (keyManagers[i] instanceof X509KeyManager) {
- keyManagers[i] = new AliasKeyManager(keyManagers[i], keyAlias);
- }
- }
-
- // create and initialize the SSLContext
- SSLContext ctx = SSLContext.getInstance(enabledProtocol);
- ctx.init(keyManagers, trustManagerFactory.getTrustManagers(), null);
- // Create the socket factory
- return ctx;
+ KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
+
+ // wrap key managers to allow us to control their behavior
+ // (FTPSERVER-93)
+ for (int i = 0; i < keyManagers.length; i++) {
+ if (ClassUtils.extendsClass(keyManagers[i].getClass(), "javax.net.ssl.X509ExtendedKeyManager")) {
+ keyManagers[i] = new ExtendedAliasKeyManager(keyManagers[i], keyAlias);
+ } else if (keyManagers[i] instanceof X509KeyManager) {
+ keyManagers[i] = new AliasKeyManager(keyManagers[i], keyAlias);
+ }
+ }
+
+ // create and initialize the SSLContext
+ SSLContext ctx = SSLContext.getInstance(enabledProtocol);
+ ctx.init(keyManagers, trustManagerFactory.getTrustManagers(), null);
+ // Create the socket factory
+ return ctx;
}
}
diff --git a/core/src/main/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptor.java b/core/src/main/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptor.java
index a19d6f1..22c9a00 100644
--- a/core/src/main/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptor.java
+++ b/core/src/main/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptor.java
@@ -30,24 +30,24 @@ import org.apache.ftpserver.util.PasswordUtil;
*/
public class Md5PasswordEncryptor implements PasswordEncryptor {
- /**
- * Hashes the password using MD5
- */
- public String encrypt(String password) {
- return EncryptUtils.encryptMD5(password);
- }
+ /**
+ * Hashes the password using MD5
+ */
+ public String encrypt(String password) {
+ return EncryptUtils.encryptMD5(password);
+ }
- /**
- * {@inheritDoc}
- */
- public boolean matches(String passwordToCheck, String storedPassword) {
- if (storedPassword == null) {
- throw new NullPointerException("storedPassword can not be null");
- }
- if (passwordToCheck == null) {
- throw new NullPointerException("passwordToCheck can not be null");
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches(String passwordToCheck, String storedPassword) {
+ if (storedPassword == null) {
+ throw new NullPointerException("storedPassword can not be null");
+ }
+ if (passwordToCheck == null) {
+ throw new NullPointerException("passwordToCheck can not be null");
+ }
- return PasswordUtil.secureCompareFast(encrypt(passwordToCheck).toLowerCase(), storedPassword.toLowerCase());
- }
+ return PasswordUtil.secureCompareFast(encrypt(passwordToCheck).toLowerCase(), storedPassword.toLowerCase());
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptor.java b/core/src/main/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptor.java
index 15d13ac..fe941ca 100644
--- a/core/src/main/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptor.java
+++ b/core/src/main/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptor.java
@@ -36,51 +36,51 @@ import org.apache.ftpserver.util.PasswordUtil;
*/
public class SaltedPasswordEncryptor implements PasswordEncryptor {
- private SecureRandom rnd = new SecureRandom();
+ private SecureRandom rnd = new SecureRandom();
- private static final int MAX_SEED = 99999999;
- private static final int HASH_ITERATIONS = 1000;
+ private static final int MAX_SEED = 99999999;
+ private static final int HASH_ITERATIONS = 1000;
- private String encrypt(String password, String salt) {
- String hash = salt + password;
- for (int i = 0; i < HASH_ITERATIONS; i++) {
- hash = EncryptUtils.encryptMD5(hash);
- }
- return salt + ":" + hash;
- }
+ private String encrypt(String password, String salt) {
+ String hash = salt + password;
+ for (int i = 0; i < HASH_ITERATIONS; i++) {
+ hash = EncryptUtils.encryptMD5(hash);
+ }
+ return salt + ":" + hash;
+ }
- /**
- * Encrypts the password using a salt concatenated with the password and a
- * series of MD5 steps.
- */
- public String encrypt(String password) {
- String seed = Integer.toString(rnd.nextInt(MAX_SEED));
+ /**
+ * Encrypts the password using a salt concatenated with the password and a
+ * series of MD5 steps.
+ */
+ public String encrypt(String password) {
+ String seed = Integer.toString(rnd.nextInt(MAX_SEED));
- return encrypt(password, seed);
- }
+ return encrypt(password, seed);
+ }
- /**
- * {@inheritDoc}
- */
- public boolean matches(String passwordToCheck, String storedPassword) {
- if (storedPassword == null) {
- throw new NullPointerException("storedPassword can not be null");
- }
- if (passwordToCheck == null) {
- throw new NullPointerException("passwordToCheck can not be null");
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches(String passwordToCheck, String storedPassword) {
+ if (storedPassword == null) {
+ throw new NullPointerException("storedPassword can not be null");
+ }
+ if (passwordToCheck == null) {
+ throw new NullPointerException("passwordToCheck can not be null");
+ }
- // look for divider for hash
- int divider = storedPassword.indexOf(':');
+ // look for divider for hash
+ int divider = storedPassword.indexOf(':');
- if (divider < 1) {
- throw new IllegalArgumentException("stored password does not contain salt");
- }
+ if (divider < 1) {
+ throw new IllegalArgumentException("stored password does not contain salt");
+ }
- String storedSalt = storedPassword.substring(0, divider);
+ String storedSalt = storedPassword.substring(0, divider);
- return PasswordUtil.secureCompareFast(encrypt(passwordToCheck, storedSalt).toLowerCase(),
- storedPassword.toLowerCase());
- }
+ return PasswordUtil.secureCompareFast(encrypt(passwordToCheck, storedSalt).toLowerCase(),
+ storedPassword.toLowerCase());
+ }
}
diff --git a/core/src/main/java/org/apache/ftpserver/usermanager/UserFactory.java b/core/src/main/java/org/apache/ftpserver/usermanager/UserFactory.java
index 89b1a3f..79dc08a 100644
--- a/core/src/main/java/org/apache/ftpserver/usermanager/UserFactory.java
+++ b/core/src/main/java/org/apache/ftpserver/usermanager/UserFactory.java
@@ -50,110 +50,110 @@ public class UserFactory {
* @return The created user
*/
public User createUser() {
- BaseUser user = new BaseUser();
- user.setName(name);
- user.setPassword(password);
- user.setHomeDirectory(homeDir);
- user.setEnabled(isEnabled);
- user.setAuthorities(authorities);
- user.setMaxIdleTime(maxIdleTimeSec);
-
- return user;
+ BaseUser user = new BaseUser();
+ user.setName(name);
+ user.setPassword(password);
+ user.setHomeDirectory(homeDir);
+ user.setEnabled(isEnabled);
+ user.setAuthorities(authorities);
+ user.setMaxIdleTime(maxIdleTimeSec);
+
+ return user;
}
/**
* Get the user name for users created by this factory
* @return The user name
*/
- public String getName() {
- return name;
- }
-
- /**
- * Set the user name for users created by this factory
- * @param name The user name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Get the password for users created by this factory
- * @return The password
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Set the user name for users created by this factory
- * @param password The password
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * Get the max idle time for users created by this factory
- * @return The max idle time in seconds
- */
- public int getMaxIdleTime() {
- return maxIdleTimeSec;
- }
-
- /**
- * Set the user name for users created by this factory
- * @param maxIdleTimeSec The max idle time in seconds
- */
- public void setMaxIdleTime(int maxIdleTimeSec) {
- this.maxIdleTimeSec = maxIdleTimeSec;
- }
-
- /**
- * Get the home directory for users created by this factory
- * @return The home directory path
- */
- public String getHomeDirectory() {
- return homeDir;
- }
-
- /**
- * Set the user name for users created by this factory
- * @param homeDir The home directory path
- */
- public void setHomeDirectory(String homeDir) {
- this.homeDir = homeDir;
- }
-
- /**
- * Get the enabled status for users created by this factory
- * @return true if the user is enabled (allowed to log in)
- */
- public boolean isEnabled() {
- return isEnabled;
- }
-
- /**
- * Get the enabled status for users created by this factory
- * @param isEnabled true if the user should be enabled (allowed to log in)
- */
- public void setEnabled(boolean isEnabled) {
- this.isEnabled = isEnabled;
- }
-
- /**
- * Get the authorities for users created by this factory
- * @return The authorities
- */
- public List<? extends Authority> getAuthorities() {
- return authorities;
- }
-
- /**
- * Set the authorities for users created by this factory
- * @param authorities The authorities
- */
- public void setAuthorities(List<Authority> authorities) {
- this.authorities = authorities;
- }
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set the user name for users created by this factory
+ * @param name The user name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the password for users created by this factory
+ * @return The password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Set the user name for users created by this factory
+ * @param password The password
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * Get the max idle time for users created by this factory
+ * @return The max idle time in seconds
+ */
+ public int getMaxIdleTime() {
+ return maxIdleTimeSec;
+ }
+
+ /**
+ * Set the user name for users created by this factory
+ * @param maxIdleTimeSec The max idle time in seconds
+ */
+ public void setMaxIdleTime(int maxIdleTimeSec) {
+ this.maxIdleTimeSec = maxIdleTimeSec;
+ }
+
+ /**
+ * Get the home directory for users created by this factory
+ * @return The home directory path
+ */
+ public String getHomeDirectory() {
+ return homeDir;
+ }
+
+ /**
+ * Set the user name for users created by this factory
+ * @param homeDir The home directory path
+ */
+ public void setHomeDirectory(String homeDir) {
+ this.homeDir = homeDir;
+ }
+
+ /**
+ * Get the enabled status for users created by this factory
+ * @return true if the user is enabled (allowed to log in)
+ */
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ /**
+ * Get the enabled status for users created by this factory
+ * @param isEnabled true if the user should be enabled (allowed to log in)
+ */
+ public void setEnabled(boolean isEnabled) {
+ this.isEnabled = isEnabled;
+ }
+
+ /**
+ * Get the authorities for users created by this factory
+ * @return The authorities
+ */
+ public List<? extends Authority> getAuthorities() {
+ return authorities;
+ }
+
+ /**
+ * Set the authorities for users created by this factory
+ * @param authorities The authorities
+ */
+ public void setAuthorities(List<Authority> authorities) {
+ this.authorities = authorities;
+ }
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/ftpserver/usermanager/impl/DbUserManager.java b/core/src/main/java/org/apache/ftpserver/usermanager/impl/DbUserManager.java
index 45a3aa6..7379945 100644
--- a/core/src/main/java/org/apache/ftpserver/usermanager/impl/DbUserManager.java
+++ b/core/src/main/java/org/apache/ftpserver/usermanager/impl/DbUserManager.java
@@ -436,17 +436,17 @@ public class DbUserManager extends AbstractUserManager {
private void closeQuitely(Statement stmt) {
if(stmt != null) {
- Connection con = null;
- try {
- con = stmt.getConnection();
- } catch (Exception e) {
- }
- try {
+ Connection con = null;
+ try {
+ con = stmt.getConnection();
+ } catch (Exception e) {
+ }
+ try {
stmt.close();
} catch (SQLException e) {
// ignore
}
- closeQuitely(con);
+ closeQuitely(con);
}
}
@@ -461,13 +461,13 @@ public class DbUserManager extends AbstractUserManager {
}
protected void closeQuitely(Connection con) {
- if (con != null) {
- try {
- con.close();
- } catch (SQLException e) {
- // ignore
- }
- }
+ if (con != null) {
+ try {
+ con.close();
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
}
private BaseUser selectUserByName(String name) throws SQLException {
diff --git a/core/src/main/java/org/apache/ftpserver/util/PasswordUtil.java b/core/src/main/java/org/apache/ftpserver/util/PasswordUtil.java
index 62fdc75..cf65046 100644
--- a/core/src/main/java/org/apache/ftpserver/util/PasswordUtil.java
+++ b/core/src/main/java/org/apache/ftpserver/util/PasswordUtil.java
@@ -20,84 +20,84 @@
package org.apache.ftpserver.util;
public class PasswordUtil {
- /**
- * Securely compares two strings up to a maximum number of characters in a way
- * that obscures the password length from timing attacks
- *
- * @param input
- * user input
- * @param password
- * correct password
- * @param loops
- * number of characters to compare; must be larger than password
- * length; 1024 is a good number
- *
- * @throws IllegalArgumentException
- * when the limit is less than the password length
- *
- * @return true if the passwords match
- */
- public static boolean secureCompare(String input, String password, int loops) {
- if (loops < password.length()) {
- throw new IllegalArgumentException("loops must be equal or greater than the password length");
- }
- /*
- * Set the default result based on the string lengths; if the lengths do not
- * match then we know that this comparison should always fail.
- */
- int result = (input.length() ^ password.length());
- /*
- * Cycle through all of the characters up to the limit value
- *
- * Important to note that this loop may return a false positive comparison if
- * the target string is a repeating set of characters in direct multiples of the
- * input string. This design fallacy is corrected by the original length
- * comparison above. The use of modulo this way is intended to prevent compiler
- * and memory optimizations for retrieving the same char position in sequence.
- */
- for (int i = 0; i < loops; i++) {
- result |= (input.charAt(i % input.length()) ^ password.charAt(i % password.length()));
- }
+ /**
+ * Securely compares two strings up to a maximum number of characters in a way
+ * that obscures the password length from timing attacks
+ *
+ * @param input
+ * user input
+ * @param password
+ * correct password
+ * @param loops
+ * number of characters to compare; must be larger than password
+ * length; 1024 is a good number
+ *
+ * @throws IllegalArgumentException
+ * when the limit is less than the password length
+ *
+ * @return true if the passwords match
+ */
+ public static boolean secureCompare(String input, String password, int loops) {
+ if (loops < password.length()) {
+ throw new IllegalArgumentException("loops must be equal or greater than the password length");
+ }
+ /*
+ * Set the default result based on the string lengths; if the lengths do not
+ * match then we know that this comparison should always fail.
+ */
+ int result = (input.length() ^ password.length());
+ /*
+ * Cycle through all of the characters up to the limit value
+ *
+ * Important to note that this loop may return a false positive comparison if
+ * the target string is a repeating set of characters in direct multiples of the
+ * input string. This design fallacy is corrected by the original length
+ * comparison above. The use of modulo this way is intended to prevent compiler
+ * and memory optimizations for retrieving the same char position in sequence.
+ */
+ for (int i = 0; i < loops; i++) {
+ result |= (input.charAt(i % input.length()) ^ password.charAt(i % password.length()));
+ }
- return (result == 0);
- }
-
- /**
- * Securely compares two strings forcing the number of loops equal to password length
- * thereby obscuring the password length based on user input
- *
- * @param input
- * user input
- * @param password
- * correct password
- * @throws IllegalArgumentException
- * when the limit is less than the password length
- *
- * @return true if the passwords match
- */
- public static boolean secureCompareFast(String input, String password) {
- /*
- * the number of compare loops
- */
- int loops = password.length();
- /*
- * Set the default result based on the string lengths; if the lengths do not
- * match then we know that this comparison should always fail.
- */
- int result = (input.length() ^ password.length());
- /*
- * Cycle through all of the characters up to the limit value
- *
- * Important to note that this loop may return a false positive comparison if
- * the target string is a repeating set of characters in direct multiples of the
- * input string. This design fallacy is corrected by the original length
- * comparison above. The use of modulo this way is intended to prevent compiler
- * and memory optimizations for retrieving the same char position in sequence.
- */
- for (int i = 0; i < loops; i++) {
- result |= (input.charAt(i % input.length()) ^ password.charAt(i % password.length()));
- }
+ return (result == 0);
+ }
+
+ /**
+ * Securely compares two strings forcing the number of loops equal to password length
+ * thereby obscuring the password length based on user input
+ *
+ * @param input
+ * user input
+ * @param password
+ * correct password
+ * @throws IllegalArgumentException
+ * when the limit is less than the password length
+ *
+ * @return true if the passwords match
+ */
+ public static boolean secureCompareFast(String input, String password) {
+ /*
+ * the number of compare loops
+ */
+ int loops = password.length();
+ /*
+ * Set the default result based on the string lengths; if the lengths do not
+ * match then we know that this comparison should always fail.
+ */
+ int result = (input.length() ^ password.length());
+ /*
+ * Cycle through all of the characters up to the limit value
+ *
+ * Important to note that this loop may return a false positive comparison if
+ * the target string is a repeating set of characters in direct multiples of the
+ * input string. This design fallacy is corrected by the original length
+ * comparison above. The use of modulo this way is intended to prevent compiler
+ * and memory optimizations for retrieving the same char position in sequence.
+ */
+ for (int i = 0; i < loops; i++) {
+ result |= (input.charAt(i % input.length()) ^ password.charAt(i % password.length()));
+ }
- return (result == 0);
- }
+ return (result == 0);
+ }
}
diff --git a/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd b/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd
index 530916c..b73159f 100644
--- a/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd
+++ b/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd
@@ -1,221 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" targetNamespace="http://mina.apache.org/ftpserver/spring/v1"
- xmlns="http://mina.apache.org/ftpserver/spring/v1" xmlns:beans="http://www.springframework.org/schema/beans">
+ elementFormDefault="qualified" targetNamespace="http://mina.apache.org/ftpserver/spring/v1"
+ xmlns="http://mina.apache.org/ftpserver/spring/v1" xmlns:beans="http://www.springframework.org/schema/beans">
- <!-- Import the Spring beans XML schema -->
- <xs:import namespace="http://www.springframework.org/schema/beans"
- schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
+ <!-- Import the Spring beans XML schema -->
+ <xs:import namespace="http://www.springframework.org/schema/beans"
+ schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
- <!-- The main entry point, used for setting up an entire FTP server -->
- <xs:element name="server">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="listeners">
- <xs:complexType>
- <xs:choice minOccurs="1" maxOccurs="unbounded">
- <xs:element ref="nio-listener" />
- <xs:element ref="listener" />
- </xs:choice>
- </xs:complexType>
- </xs:element>
- <xs:element minOccurs="0" ref="ftplets" />
- <xs:choice minOccurs="0" maxOccurs="1">
- <xs:element minOccurs="0" ref="file-user-manager" />
- <xs:element minOccurs="0" ref="db-user-manager" />
- <xs:element minOccurs="0" ref="user-manager" />
- </xs:choice>
- <xs:choice minOccurs="0" maxOccurs="1">
- <xs:element minOccurs="0" ref="native-filesystem" />
- <xs:element minOccurs="0" ref="filesystem" />
- </xs:choice>
- <xs:element minOccurs="0" ref="commands" />
- <xs:element minOccurs="0" ref="messages" />
- </xs:sequence>
- <xs:attribute name="id" type="xs:ID" />
- <xs:attribute name="max-logins" type="xs:int" />
- <xs:attribute name="max-anon-logins" type="xs:int" />
- <xs:attribute name="anon-enabled" type="xs:boolean" />
- <xs:attribute name="max-login-failures" type="xs:int" />
- <xs:attribute name="login-failure-delay" type="xs:int" />
- <xs:attribute name="max-threads" type="xs:int" />
- </xs:complexType>
- </xs:element>
+ <!-- The main entry point, used for setting up an entire FTP server -->
+ <xs:element name="server">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="listeners">
+ <xs:complexType>
+ <xs:choice minOccurs="1" maxOccurs="unbounded">
+ <xs:element ref="nio-listener" />
+ <xs:element ref="listener" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+ <xs:element minOccurs="0" ref="ftplets" />
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element minOccurs="0" ref="file-user-manager" />
+ <xs:element minOccurs="0" ref="db-user-manager" />
+ <xs:element minOccurs="0" ref="user-manager" />
+ </xs:choice>
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element minOccurs="0" ref="native-filesystem" />
+ <xs:element minOccurs="0" ref="filesystem" />
+ </xs:choice>
+ <xs:element minOccurs="0" ref="commands" />
+ <xs:element minOccurs="0" ref="messages" />
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:ID" />
+ <xs:attribute name="max-logins" type="xs:int" />
+ <xs:attribute name="max-anon-logins" type="xs:int" />
+ <xs:attribute name="anon-enabled" type="xs:boolean" />
+ <xs:attribute name="max-login-failures" type="xs:int" />
+ <xs:attribute name="login-failure-delay" type="xs:int" />
+ <xs:attribute name="max-threads" type="xs:int" />
+ </xs:complexType>
+ </xs:element>
- <!-- Reusable element for defining SSL properties -->
- <xs:element name="ssl">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="keystore">
- <xs:complexType>
- <xs:attribute name="file" use="required" />
- <xs:attribute name="password" use="required" />
- <xs:attribute name="type" />
- <xs:attribute name="algorithm" />
- <xs:attribute name="key-alias" />
- <xs:attribute name="key-password" />
- </xs:complexType>
- </xs:element>
- <xs:element minOccurs="0" name="truststore">
- <xs:complexType>
- <xs:attribute name="file" use="required" />
- <xs:attribute name="password" />
- <xs:attribute name="type" />
- <xs:attribute name="algorithm" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="client-authentication">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="NEED" />
- <xs:enumeration value="WANT" />
- <xs:enumeration value="NONE" />
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="enabled-ciphersuites" type="xs:string" />
- <xs:attribute name="protocol">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="SSL" />
- <xs:enumeration value="TLS" />
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
+ <!-- Reusable element for defining SSL properties -->
+ <xs:element name="ssl">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="keystore">
+ <xs:complexType>
+ <xs:attribute name="file" use="required" />
+ <xs:attribute name="password" use="required" />
+ <xs:attribute name="type" />
+ <xs:attribute name="algorithm" />
+ <xs:attribute name="key-alias" />
+ <xs:attribute name="key-password" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element minOccurs="0" name="truststore">
+ <xs:complexType>
+ <xs:attribute name="file" use="required" />
+ <xs:attribute name="password" />
+ <xs:attribute name="type" />
+ <xs:attribute name="algorithm" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="client-authentication">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="NEED" />
+ <xs:enumeration value="WANT" />
+ <xs:enumeration value="NONE" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="enabled-ciphersuites" type="xs:string" />
+ <xs:attribute name="protocol">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="SSL" />
+ <xs:enumeration value="TLS" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
- <!-- Element used to configure the remote IP Filtering -->
- <xs:element name="remote-ip-filter">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="type">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="allow" />
- <xs:enumeration value="deny" />
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
+ <!-- Element used to configure the remote IP Filtering -->
+ <xs:element name="remote-ip-filter">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="type">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="allow" />
+ <xs:enumeration value="deny" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
- <!-- Element used to define the default, NIO based listener -->
- <xs:element name="nio-listener">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" ref="ssl" />
- <xs:element minOccurs="0" name="data-connection">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" ref="ssl" />
- <xs:element minOccurs="0" name="active">
- <xs:complexType>
- <xs:attribute name="enabled" type="xs:boolean" />
- <xs:attribute name="local-address" />
- <xs:attribute name="local-port" type="xs:int" />
- <xs:attribute name="ip-check" type="xs:boolean" />
- </xs:complexType>
- </xs:element>
- <xs:element minOccurs="0" name="passive">
- <xs:complexType>
- <xs:attribute name="address" />
- <xs:attribute name="external-address" />
- <xs:attribute name="ip-check" type="xs:boolean" />
- <xs:attribute name="ports" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="idle-timeout" type="xs:int" />
+ <!-- Element used to define the default, NIO based listener -->
+ <xs:element name="nio-listener">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="ssl" />
+ <xs:element minOccurs="0" name="data-connection">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="ssl" />
+ <xs:element minOccurs="0" name="active">
+ <xs:complexType>
+ <xs:attribute name="enabled" type="xs:boolean" />
+ <xs:attribute name="local-address" />
+ <xs:attribute name="local-port" type="xs:int" />
+ <xs:attribute name="ip-check" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element minOccurs="0" name="passive">
+ <xs:complexType>
+ <xs:attribute name="address" />
+ <xs:attribute name="external-address" />
+ <xs:attribute name="ip-check" type="xs:boolean" />
+ <xs:attribute name="ports" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="idle-timeout" type="xs:int" />
<xs:attribute name="implicit-ssl" type="xs:boolean" />
- </xs:complexType>
- </xs:element>
- <xs:element minOccurs="0" name="blacklist" type="xs:string" />
- <xs:element ref="remote-ip-filter" minOccurs="0" maxOccurs="1" />
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:string" />
- <xs:attribute name="local-address" />
- <xs:attribute name="port" type="xs:int" />
- <xs:attribute name="idle-timeout" type="xs:int" />
- <xs:attribute name="implicit-ssl" type="xs:boolean" />
- </xs:complexType>
- </xs:element>
-
- <!-- Extension element used for defining a custom listener -->
- <xs:element name="listener" type="spring-bean-or-ref-with-name" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element minOccurs="0" name="blacklist" type="xs:string" />
+ <xs:element ref="remote-ip-filter" minOccurs="0" maxOccurs="1" />
+ </xs:sequence>
+ <xs:attribute name="name" use="required" type="xs:string" />
+ <xs:attribute name="local-address" />
+ <xs:attribute name="port" type="xs:int" />
+ <xs:attribute name="idle-timeout" type="xs:int" />
+ <xs:attribute name="implicit-ssl" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Extension element used for defining a custom listener -->
+ <xs:element name="listener" type="spring-bean-or-ref-with-name" />
- <!-- Element used to configure Ftplets for used with the server -->
- <xs:element name="ftplets">
- <xs:complexType>
- <xs:choice>
- <xs:element name="ftplet" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:choice>
- <xs:element ref="beans:bean" />
- <xs:element ref="beans:ref" />
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element ref="beans:map" />
- </xs:choice>
- </xs:complexType>
- </xs:element>
+ <!-- Element used to configure Ftplets for used with the server -->
+ <xs:element name="ftplets">
+ <xs:complexType>
+ <xs:choice>
+ <xs:element name="ftplet" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice>
+ <xs:element ref="beans:bean" />
+ <xs:element ref="beans:ref" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element ref="beans:map" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
- <!-- Element used to configure a file based user manager -->
- <xs:element name="file-user-manager">
- <xs:complexType>
- <xs:attribute name="file" type="xs:string" />
- <xs:attribute name="url" type="xs:string" />
- <xs:attribute name="encrypt-passwords">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:enumeration value="clear"></xs:enumeration>
- <!-- Deprecated, use "clear" -->
- <xs:enumeration value="false"></xs:enumeration>
- <xs:enumeration value="md5"></xs:enumeration>
- <!-- Deprecated, use "md5" -->
- <xs:enumeration value="true"></xs:enumeration>
- <xs:enumeration value="salted"></xs:enumeration>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
-
- <!-- Element used to configure a database based user manager -->
- <xs:element name="db-user-manager">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="data-source" type="spring-bean-or-ref" />
- <xs:element name="insert-user" type="xs:string" />
- <xs:element name="update-user" type="xs:string" />
- <xs:element name="delete-user" type="xs:string" />
- <xs:element name="select-user" type="xs:string" />
- <xs:element name="select-all-users" type="xs:string" />
- <xs:element name="is-admin" type="xs:string" />
- <xs:element name="authenticate" type="xs:string" />
- </xs:sequence>
+ <!-- Element used to configure a file based user manager -->
+ <xs:element name="file-user-manager">
+ <xs:complexType>
+ <xs:attribute name="file" type="xs:string" />
+ <xs:attribute name="url" type="xs:string" />
+ <xs:attribute name="encrypt-passwords">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="clear"></xs:enumeration>
+ <!-- Deprecated, use "clear" -->
+ <xs:enumeration value="false"></xs:enumeration>
+ <xs:enumeration value="md5"></xs:enumeration>
+ <!-- Deprecated, use "md5" -->
+ <xs:enumeration value="true"></xs:enumeration>
+ <xs:enumeration value="salted"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Element used to configure a database based user manager -->
+ <xs:element name="db-user-manager">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="data-source" type="spring-bean-or-ref" />
+ <xs:element name="insert-user" type="xs:string" />
+ <xs:element name="update-user" type="xs:string" />
+ <xs:element name="delete-user" type="xs:string" />
+ <xs:element name="select-user" type="xs:string" />
+ <xs:element name="select-all-users" type="xs:string" />
+ <xs:element name="is-admin" type="xs:string" />
+ <xs:element name="authenticate" type="xs:string" />
+ </xs:sequence>
<xs:attribute name="encrypt-passwords">
<xs:simpleType>
<xs:restriction base="xs:string">
@@ -225,67 +225,67 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
- </xs:complexType>
- </xs:element>
+ </xs:complexType>
+ </xs:element>
- <!-- Extension element used for defining a custom user manager -->
- <xs:element name="user-manager" type="spring-bean-or-ref" />
+ <!-- Extension element used for defining a custom user manager -->
+ <xs:element name="user-manager" type="spring-bean-or-ref" />
- <!-- Element used to configure the default file system -->
- <xs:element name="native-filesystem">
- <xs:complexType>
- <xs:attribute name="case-insensitive" type="xs:boolean" />
- <xs:attribute name="create-home" type="xs:boolean" />
- </xs:complexType>
- </xs:element>
+ <!-- Element used to configure the default file system -->
+ <xs:element name="native-filesystem">
+ <xs:complexType>
+ <xs:attribute name="case-insensitive" type="xs:boolean" />
+ <xs:attribute name="create-home" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
- <!-- Extension element used for defining a custom file system -->
- <xs:element name="filesystem" type="spring-bean-or-ref" />
+ <!-- Extension element used for defining a custom file system -->
+ <xs:element name="filesystem" type="spring-bean-or-ref" />
- <!-- Element used to provide custom command implementations -->
- <xs:element name="commands">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="command" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:choice maxOccurs="unbounded">
- <xs:element ref="beans:bean" />
- <xs:element ref="beans:ref" />
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="name" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="use-default" type="xs:boolean" />
- </xs:complexType>
- </xs:element>
-
- <!-- Element used to configure and localize messages -->
- <xs:element name="messages">
- <xs:complexType>
- <xs:attribute name="languages" />
- <xs:attribute name="directory" />
- </xs:complexType>
- </xs:element>
+ <!-- Element used to provide custom command implementations -->
+ <xs:element name="commands">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="command" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice maxOccurs="unbounded">
+ <xs:element ref="beans:bean" />
+ <xs:element ref="beans:ref" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="use-default" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Element used to configure and localize messages -->
+ <xs:element name="messages">
+ <xs:complexType>
+ <xs:attribute name="languages" />
+ <xs:attribute name="directory" />
+ </xs:complexType>
+ </xs:element>
- <!-- Reusable type used for extension elements -->
- <xs:complexType name="spring-bean-or-ref">
- <xs:choice>
- <xs:element ref="beans:bean" />
- <xs:element ref="beans:ref" />
- </xs:choice>
- </xs:complexType>
-
- <!-- Reusable type used for named extension elements -->
- <xs:complexType name="spring-bean-or-ref-with-name">
- <xs:sequence>
- <xs:choice>
- <xs:element ref="beans:bean" />
- <xs:element ref="beans:ref" />
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:string" />
- </xs:complexType>
+ <!-- Reusable type used for extension elements -->
+ <xs:complexType name="spring-bean-or-ref">
+ <xs:choice>
+ <xs:element ref="beans:bean" />
+ <xs:element ref="beans:ref" />
+ </xs:choice>
+ </xs:complexType>
+
+ <!-- Reusable type used for named extension elements -->
+ <xs:complexType name="spring-bean-or-ref-with-name">
+ <xs:sequence>
+ <xs:choice>
+ <xs:element ref="beans:bean" />
+ <xs:element ref="beans:ref" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" type="xs:string" />
+ </xs:complexType>
</xs:schema>
\ No newline at end of file
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/ClientTestTemplate.java b/core/src/test/java/org/apache/ftpserver/clienttests/ClientTestTemplate.java
index aad9d52..568cd6b 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/ClientTestTemplate.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/ClientTestTemplate.java
@@ -227,12 +227,12 @@ public abstract class ClientTestTemplate extends TestCase {
}
if (server != null) {
- try {
- server.stop();
- } catch(NullPointerException e) {
- // a bug in the IBM JVM might cause Thread.interrupt() to throw an NPE
- // see http://www-01.ibm.com/support/docview.wss?uid=swg1IZ52037&wv=1
- }
+ try {
+ server.stop();
+ } catch(NullPointerException e) {
+ // a bug in the IBM JVM might cause Thread.interrupt() to throw an NPE
+ // see http://www-01.ibm.com/support/docview.wss?uid=swg1IZ52037&wv=1
+ }
}
cleanTmpDirs();
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/FtpMd5Test.java b/core/src/test/java/org/apache/ftpserver/clienttests/FtpMd5Test.java
index 5349f69..2221dd1 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/FtpMd5Test.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/FtpMd5Test.java
@@ -200,7 +200,7 @@ public class FtpMd5Test extends ClientTestTemplate {
String fileName = token.substring(0, hashStart).trim();
if(fileName.startsWith("\"") && fileName.endsWith("\"")) {
- fileName = fileName.substring(1, fileName.length() - 1);
+ fileName = fileName.substring(1, fileName.length() - 1);
}
String hash = token.substring(hashStart).trim();
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/IpFilterTest.java b/core/src/test/java/org/apache/ftpserver/clienttests/IpFilterTest.java
index 4e27e94..fe4392a 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/IpFilterTest.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/IpFilterTest.java
@@ -55,8 +55,8 @@ public class IpFilterTest extends ClientTestTemplate {
}
public void testDenyBlackList() throws Exception {
- filter.clear();
- filter.setType(IpFilterType.DENY);
+ filter.clear();
+ filter.setType(IpFilterType.DENY);
filter.add(new Subnet(InetAddress.getByName("localhost"), 32));
try {
client.connect("localhost", getListenerPort());
@@ -67,8 +67,8 @@ public class IpFilterTest extends ClientTestTemplate {
}
public void testDenyEmptyWhiteList() throws Exception {
- filter.clear();
- filter.setType(IpFilterType.ALLOW);
+ filter.clear();
+ filter.setType(IpFilterType.ALLOW);
try {
client.connect("localhost", getListenerPort());
fail("Must throw");
@@ -78,8 +78,8 @@ public class IpFilterTest extends ClientTestTemplate {
}
public void testWhiteList() throws Exception {
- filter.clear();
- filter.setType(IpFilterType.ALLOW);
+ filter.clear();
+ filter.setType(IpFilterType.ALLOW);
filter.add(new Subnet(InetAddress.getByName("localhost"), 32));
client.connect("localhost", getListenerPort());
}
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/LoginTest.java b/core/src/test/java/org/apache/ftpserver/clienttests/LoginTest.java
index 38e36d1..272733b 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/LoginTest.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/LoginTest.java
@@ -124,13 +124,13 @@ public class LoginTest extends ClientTestTemplate {
}
public void testLoginCount() throws Exception {
- FtpStatistics stats = server.getServerContext().getFtpStatistics();
- assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));
- int n =stats.getCurrentLoginNumber();
- assertEquals(1,n );
- client.rein();
- client.logout();
- assertEquals(0, stats.getCurrentLoginNumber());
+ FtpStatistics stats = server.getServerContext().getFtpStatistics();
+ assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));
+ int n =stats.getCurrentLoginNumber();
+ assertEquals(1,n );
+ client.rein();
+ client.logout();
+ assertEquals(0, stats.getCurrentLoginNumber());
}
/*
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/PasvPortUnavailableTest.java b/core/src/test/java/org/apache/ftpserver/clienttests/PasvPortUnavailableTest.java
index 32d2dfa..30227c7 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/PasvPortUnavailableTest.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/PasvPortUnavailableTest.java
@@ -57,23 +57,23 @@ public class PasvPortUnavailableTest extends ClientTestTemplate {
}
public void testPasvPortUnavailable() throws Exception {
- FTPClient[] clients = new FTPClient[3];
- for(int i = 0; i < 3; i ++) {
- clients[i] = createFTPClient();
- clients[i] .connect("localhost", getListenerPort());
- clients[i].login(ADMIN_USERNAME, ADMIN_PASSWORD);
- clients[i].pasv();
- if(i < 1) {
- assertTrue(clients[i].getReplyString(), clients[i].getReplyString().trim().startsWith("227"));
- }
- else {
- assertTrue(clients[i].getReplyString(), clients[i].getReplyString().trim().startsWith("425"));
- }
- }
- for(int i = 0; i < 3; i ++) {
- if(clients[i] != null) {
- clients[i].disconnect();
- }
- }
+ FTPClient[] clients = new FTPClient[3];
+ for(int i = 0; i < 3; i ++) {
+ clients[i] = createFTPClient();
+ clients[i] .connect("localhost", getListenerPort());
+ clients[i].login(ADMIN_USERNAME, ADMIN_PASSWORD);
+ clients[i].pasv();
+ if(i < 1) {
+ assertTrue(clients[i].getReplyString(), clients[i].getReplyString().trim().startsWith("227"));
+ }
+ else {
+ assertTrue(clients[i].getReplyString(), clients[i].getReplyString().trim().startsWith("425"));
+ }
+ }
+ for(int i = 0; i < 3; i ++) {
+ if(clients[i] != null) {
+ clients[i].disconnect();
+ }
+ }
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/PortTest.java b/core/src/test/java/org/apache/ftpserver/clienttests/PortTest.java
index 425278f..93459db 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/PortTest.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/PortTest.java
@@ -36,7 +36,7 @@ public class PortTest extends ClientTestTemplate {
}
public void testInvalidIpAndPort() throws Exception {
- assertEquals(501, client.port(InetAddress.getByName("0.0.0.0"), 0));
+ assertEquals(501, client.port(InetAddress.getByName("0.0.0.0"), 0));
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/LISTFileFormaterTest.java b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/LISTFileFormaterTest.java
index 28a07ca..8b71866 100644
--- a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/LISTFileFormaterTest.java
+++ b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/LISTFileFormaterTest.java
@@ -134,7 +134,7 @@ public class LISTFileFormaterTest extends TestCase {
}
public Object getPhysicalFile() {
- return "/short";
+ return "/short";
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/MLSTFileFormaterTest.java b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/MLSTFileFormaterTest.java
index 724c8e3..0f35bb5 100644
--- a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/MLSTFileFormaterTest.java
+++ b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/MLSTFileFormaterTest.java
@@ -135,7 +135,7 @@ public class MLSTFileFormaterTest extends TestCase {
}
public Object getPhysicalFile() {
- return "/short";
+ return "/short";
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/NLSTFileFormaterTest.java b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/NLSTFileFormaterTest.java
index c76b543..7c01c4e 100644
--- a/core/src/test/java/org/apache/ftpserver/commands/impl/listing/NLSTFileFormaterTest.java
+++ b/core/src/test/java/org/apache/ftpserver/commands/impl/listing/NLSTFileFormaterTest.java
@@ -127,7 +127,7 @@ public class NLSTFileFormaterTest extends TestCase {
}
public Object getPhysicalFile() {
- return "/short";
+ return "/short";
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/config/spring/FtpletsConfigTest.java b/core/src/test/java/org/apache/ftpserver/config/spring/FtpletsConfigTest.java
index e8115f6..946eed2 100644
--- a/core/src/test/java/org/apache/ftpserver/config/spring/FtpletsConfigTest.java
+++ b/core/src/test/java/org/apache/ftpserver/config/spring/FtpletsConfigTest.java
@@ -41,7 +41,7 @@ public class FtpletsConfigTest extends SpringConfigTestTemplate {
public void testFtplet() throws Throwable {
Map<String, Ftplet> ftplets = createFtplets("<ftplet name=\"foo\">" +
- "<beans:bean class=\"" + TestFtplet.class.getName() + "\">" +
+ "<beans:bean class=\"" + TestFtplet.class.getName() + "\">" +
"<beans:property name=\"foo\" value=\"123\" />" +
"</beans:bean></ftplet>");
diff --git a/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java b/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java
index 5ef03ea..8e405e4 100644
--- a/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java
+++ b/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java
@@ -75,7 +75,7 @@ public class SpringConfigTest extends TestCase {
.getDataConnectionConfiguration().isImplicitSsl());
assertEquals(InetAddress.getByName("1.2.3.4"), InetAddress.getByName(((NioListener) listener)
- .getDataConnectionConfiguration().getActiveLocalAddress()) );
+ .getDataConnectionConfiguration().getActiveLocalAddress()) );
assertEquals("123-125", ((NioListener) listener)
.getDataConnectionConfiguration().getPassivePorts());
assertEquals(false, ((NioListener) listener)
diff --git a/core/src/test/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFileTest.java b/core/src/test/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFileTest.java
index cce3047..6e603d9 100644
--- a/core/src/test/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFileTest.java
+++ b/core/src/test/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFileTest.java
@@ -86,20 +86,20 @@ public class NativeFtpFileTest extends FtpFileTestTemplate {
}
}
public void testDeleteReadOnlyFiles(){
-
- NativeFtpFile fileObj=(NativeFtpFile)createFileObject(FILE2_PATH, USER);
- File physicalFile=fileObj.getPhysicalFile();
- // First check
- assertTrue(fileObj.isRemovable());
-
- // Now file is read only.
- if (!physicalFile.setReadOnly() ){
- fail("Test cannot be setup properly");
- }
+
+ NativeFtpFile fileObj=(NativeFtpFile)createFileObject(FILE2_PATH, USER);
+ File physicalFile=fileObj.getPhysicalFile();
+ // First check
+ assertTrue(fileObj.isRemovable());
+
+ // Now file is read only.
+ if (!physicalFile.setReadOnly() ){
+ fail("Test cannot be setup properly");
+ }
- assertTrue(fileObj.isRemovable());
- //can we actually delete this file?
- assertTrue(physicalFile.delete());
+ assertTrue(fileObj.isRemovable());
+ //can we actually delete this file?
+ assertTrue(physicalFile.delete());
}
@Override
diff --git a/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetReturnDefaultTest.java b/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetReturnDefaultTest.java
index 16591cf..3c9f3cb 100644
--- a/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetReturnDefaultTest.java
+++ b/core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetReturnDefaultTest.java
@@ -86,8 +86,8 @@ public class FtpLetReturnDefaultTest extends ClientTestTemplate {
}
public void testLogin() throws Exception {
- final LinkedBlockingQueue<User> loggedInUser = new LinkedBlockingQueue<User>();
-
+ final LinkedBlockingQueue<User> loggedInUser = new LinkedBlockingQueue<User>();
+
MockFtplet.callback = new MockFtpletCallback() {
public FtpletResult onLogin(FtpSession session, FtpRequest request)
throws FtpException, IOException {
diff --git a/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java b/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java
index 3c48944..8b75d70 100644
--- a/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java
+++ b/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java
@@ -83,13 +83,13 @@ public class PassivePortsTest extends TestCase {
}
private void assertReserveAll(String portString, int... validPorts) {
- PassivePorts ports = new PassivePorts(portString, false);
-
+ PassivePorts ports = new PassivePorts(portString, false);
+
List<Integer> valid = valid(validPorts);
int len = valid.size();
for(int i = 0; i<len; i++) {
- assertContains(valid, ports.reserveNextPort());
+ assertContains(valid, ports.reserveNextPort());
}
assertEquals(-1, ports.reserveNextPort());
assertTrue(valid.isEmpty());
@@ -99,7 +99,7 @@ public class PassivePortsTest extends TestCase {
private List<Integer> valid(int... ints) {
List<Integer> valid = new ArrayList<Integer>();
for(int i : ints) {
- valid.add(i);
+ valid.add(i);
}
return valid;
}
@@ -149,8 +149,8 @@ public class PassivePortsTest extends TestCase {
}
public void testReserveNextPortBound() throws IOException {
- ServerSocket ss = new ServerSocket(0);
-
+ ServerSocket ss = new ServerSocket(0);
+
PassivePorts ports = new PassivePorts(Integer.toString(ss.getLocalPort()), true);
assertEquals(-1, ports.reserveNextPort());
diff --git a/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java b/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java
index 780d56f..69b5f8c 100644
--- a/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java
+++ b/core/src/test/java/org/apache/ftpserver/ssl/MinaCipherSuitesTest.java
@@ -32,31 +32,31 @@ public class MinaCipherSuitesTest extends SSLTestTemplate {
@Override
protected String getAuthValue() {
- return "TLSv1.2";
+ return "TLSv1.2";
}
@Override
protected boolean useImplicit() {
- return true;
+ return true;
}
@Override
protected SslConfigurationFactory createSslConfiguration() {
- SslConfigurationFactory sslConfigFactory = super.createSslConfiguration();
+ SslConfigurationFactory sslConfigFactory = super.createSslConfiguration();
- sslConfigFactory.setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
+ sslConfigFactory.setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
- return sslConfigFactory;
+ return sslConfigFactory;
}
@Override
protected FTPSClient createFTPClient() throws Exception {
- return new FTPSClient(true);
+ return new FTPSClient(true);
}
@Override
protected boolean isConnectClient() {
- return false;
+ return false;
}
/*
@@ -65,19 +65,19 @@ public class MinaCipherSuitesTest extends SSLTestTemplate {
*/
public void testEnabled() throws Exception {
- ((FTPSClient) client).setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
+ ((FTPSClient) client).setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" });
- connectClient();
+ connectClient();
}
public void testDisabled() throws Exception {
- ((FTPSClient) client).setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" });
-
- try {
- doConnect();
- fail("Must throw SSLHandshakeException");
- } catch (SSLHandshakeException e) {
- // OK
- }
+ ((FTPSClient) client).setEnabledCipherSuites(new String[] { "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" });
+
+ try {
+ doConnect();
+ fail("Must throw SSLHandshakeException");
+ } catch (SSLHandshakeException e) {
+ // OK
+ }
}
}
diff --git a/core/src/test/java/org/apache/ftpserver/usermanager/impl/PropertiesUserManagerTest.java b/core/src/test/java/org/apache/ftpserver/usermanager/impl/PropertiesUserManagerTest.java
index 7852762..e7c04d6 100644
--- a/core/src/test/java/org/apache/ftpserver/usermanager/impl/PropertiesUserManagerTest.java
+++ b/core/src/test/java/org/apache/ftpserver/usermanager/impl/PropertiesUserManagerTest.java
@@ -95,24 +95,24 @@ public class PropertiesUserManagerTest extends UserManagerTestTemplate {
}
public void testRefresh() throws FileNotFoundException, IOException {
- Properties users = new Properties();
- users.load(new FileInputStream(USERS_FILE));
- String originalSetting = users.getProperty("ftpserver.user.user1.homedirectory");
- users.setProperty("ftpserver.user.user1.homedirectory", "refresh_test");
- users.store(new FileOutputStream(USERS_FILE), null);
-
- PropertiesUserManager pum = (PropertiesUserManager) userManager;
- pum.refresh();
- User modifiedUser = pum.getUserByName("user1");
- assertEquals("Home directory should have been \"refresh_test\" after call to refresh().","refresh_test",modifiedUser.getHomeDirectory());
- // set everything back again
- users.load(new FileInputStream(USERS_FILE));
- users.setProperty("ftpserver.user.user1.homedirectory", originalSetting);
- users.store(new FileOutputStream(USERS_FILE), null);
-
- pum.refresh();
- //check everything is back again
- modifiedUser = pum.getUserByName("user1");
- assertEquals("Home directory should have reset back to \""+originalSetting+"\" after second call to refresh().",originalSetting,modifiedUser.getHomeDirectory());
+ Properties users = new Properties();
+ users.load(new FileInputStream(USERS_FILE));
+ String originalSetting = users.getProperty("ftpserver.user.user1.homedirectory");
+ users.setProperty("ftpserver.user.user1.homedirectory", "refresh_test");
+ users.store(new FileOutputStream(USERS_FILE), null);
+
+ PropertiesUserManager pum = (PropertiesUserManager) userManager;
+ pum.refresh();
+ User modifiedUser = pum.getUserByName("user1");
+ assertEquals("Home directory should have been \"refresh_test\" after call to refresh().","refresh_test",modifiedUser.getHomeDirectory());
+ // set everything back again
+ users.load(new FileInputStream(USERS_FILE));
+ users.setProperty("ftpserver.user.user1.homedirectory", originalSetting);
+ users.store(new FileOutputStream(USERS_FILE), null);
+
+ pum.refresh();
+ //check everything is back again
+ modifiedUser = pum.getUserByName("user1");
+ assertEquals("Home directory should have reset back to \""+originalSetting+"\" after second call to refresh().",originalSetting,modifiedUser.getHomeDirectory());
}
}
diff --git a/core/src/test/resources/spring-config/config-property-placeholder.xml b/core/src/test/resources/spring-config/config-property-placeholder.xml
index 579e508..49ee22d 100644
--- a/core/src/test/resources/spring-config/config-property-placeholder.xml
+++ b/core/src/test/resources/spring-config/config-property-placeholder.xml
@@ -26,20 +26,21 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
">
- <context:property-placeholder location="src/test/resources/spring-config/placeholder.properties"/>
+ <context:property-placeholder location="src/test/resources/spring-config/placeholder.properties"/>
- <server id="server">
- <listeners>
- <listener name="listener0">
- <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
- <beans:property name="port" value="${port1}"/>
- </beans:bean>
- </listener>
- <listener name="listener1">
- <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
- <beans:property name="port" value="${port2}"/>
- </beans:bean>
- </listener>
- </listeners>
- </server>
+ <server id="server">
+ <listeners>
+ <listener name="listener0">
+ <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
+ <beans:property name="port" value="${port1}"/>
+ </beans:bean>
+ </listener>
+
+ <listener name="listener1">
+ <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
+ <beans:property name="port" value="${port2}"/>
+ </beans:bean>
+ </listener>
+ </listeners>
+ </server>
</beans:beans>
diff --git a/core/src/test/resources/spring-config/config-spring-1.xml b/core/src/test/resources/spring-config/config-spring-1.xml
index dbce3cb..b836cf6 100644
--- a/core/src/test/resources/spring-config/config-spring-1.xml
+++ b/core/src/test/resources/spring-config/config-spring-1.xml
@@ -18,69 +18,73 @@
under the License. -->
<server id="server" xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- "
- max-logins="500"
- anon-enabled="false"
- max-anon-logins="123"
- max-login-failures="124"
- login-failure-delay="125"
- >
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ max-logins="500"
+ anon-enabled="false"
+ max-anon-logins="123"
+ max-login-failures="124"
+ login-failure-delay="125"
+ >
- <listeners>
- <nio-listener name="listener0" port="2222" local-address="1.2.3.4">
- <ssl>
- <keystore file="src/test/resources/ftpserver.jks" password="password"/>
- </ssl>
+ <listeners>
+ <nio-listener name="listener0" port="2222" local-address="1.2.3.4">
+ <ssl>
+ <keystore file="src/test/resources/ftpserver.jks" password="password"/>
+ </ssl>
- <data-connection idle-timeout="100" implicit-ssl="true">
- <active enabled="true" local-address="1.2.3.4"/>
- <passive ports="123-125"/>
- </data-connection>
- <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
- </nio-listener>
- <listener name="listener1">
- <beans:bean id="listener1" class="org.apache.ftpserver.config.spring.MyCustomListener">
+ <data-connection idle-timeout="100" implicit-ssl="true">
+ <active enabled="true" local-address="1.2.3.4"/>
+ <passive ports="123-125"/>
+ </data-connection>
+ <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
+ </nio-listener>
+ <listener name="listener1">
+ <beans:bean id="listener1" class="org.apache.ftpserver.config.spring.MyCustomListener">
<beans:property name="port" value="2223"/>
- </beans:bean>
+ </beans:bean>
+ </listener>
+
+ <listener name="listener2">
+ <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
+ <beans:property name="port" value="2224"/>
+ </beans:bean>
+ </listener>
+ </listeners>
- </listener>
- <listener name="listener2">
- <beans:bean class="org.apache.ftpserver.config.spring.MyCustomListener">
- <beans:property name="port" value="2224"/>
- </beans:bean>
- </listener>
- </listeners>
- <ftplets>
- <ftplet name="ftplet1">
- <beans:bean class="org.apache.ftpserver.config.spring.TestFtplet">
- <beans:property name="foo" value="123"/>
- </beans:bean>
- </ftplet>
- <ftplet name="ftplet2">
- <beans:bean class="org.apache.ftpserver.config.spring.TestFtplet">
- <beans:property name="foo" value="223"/>
- </beans:bean>
- </ftplet>
- </ftplets>
- <!--<file-user-manager file="src/test/resources/users.properties" encrypt-passwords="true" />-->
- <user-manager>
- <beans:bean class="org.apache.ftpserver.config.spring.MockUserManager"/>
- </user-manager>
- <native-filesystem case-insensitive="true" create-home="true" />
- <commands use-default="false">
- <command name="FOO">
- <beans:bean class="org.apache.ftpserver.command.impl.HELP" />
- </command>
- <command name="FOO2">
- <beans:bean class="org.apache.ftpserver.command.impl.STAT" />
- </command>
- </commands>
- <messages languages="en zh-tw" />
- </server>
+ <ftplets>
+ <ftplet name="ftplet1">
+ <beans:bean class="org.apache.ftpserver.config.spring.TestFtplet">
+ <beans:property name="foo" value="123"/>
+ </beans:bean>
+ </ftplet>
+
+ <ftplet name="ftplet2">
+ <beans:bean class="org.apache.ftpserver.config.spring.TestFtplet">
+ <beans:property name="foo" value="223"/>
+ </beans:bean>
+ </ftplet>
+ </ftplets>
+
+ <!--<file-user-manager file="src/test/resources/users.properties" encrypt-passwords="true" />-->
+ <user-manager>
+ <beans:bean class="org.apache.ftpserver.config.spring.MockUserManager"/>
+ </user-manager>
+ <native-filesystem case-insensitive="true" create-home="true" />
+ <commands use-default="false">
+ <command name="FOO">
+ <beans:bean class="org.apache.ftpserver.command.impl.HELP" />
+ </command>
+
+ <command name="FOO2">
+ <beans:bean class="org.apache.ftpserver.command.impl.STAT" />
+ </command>
+ </commands>
+ <messages languages="en zh-tw" />
+</server>
diff --git a/distribution/res/conf/ftpd-full.xml b/distribution/res/conf/ftpd-full.xml
index f31722a..747ee14 100644
--- a/distribution/res/conf/ftpd-full.xml
+++ b/distribution/res/conf/ftpd-full.xml
@@ -1,103 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- "
- id="myServer">
- <!--
- Use this section to define custom listeners, or to redefine the
- default listener, aptly named "default"
- -->
- <listeners>
- <nio-listener name="default" port="2222" implicit-ssl="true"
- idle-timeout="60" local-address="1.2.3.4">
- <ssl>
- <keystore file="mykeystore.jks" password="secret"
- key-password="otherSecret" />
- <truststore file="mytruststore.jks" password="secret" />
- </ssl>
- <data-connection idle-timeout="60">
- <active enabled="true" local-address="1.2.3.4" local-port="2323"
- ip-check="true" />
- <passive ports="123-125" address="1.2.3.4" external-address="1.2.3.4" />
- </data-connection>
- <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
- </nio-listener>
- </listeners>
- <!--
- Use this section to define your Ftplets, they are configured like
- regular Spring beans
- -->
- <ftplets>
- <ftplet name="ftplet1">
- <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
- <beans:property name="foo" value="123" />
- </beans:bean>
- </ftplet>
- </ftplets>
- <!-- The user manager, choose one -->
- <file-user-manager file="users.properties"
- encrypt-passwords="true" />
- <!--<db-user-manager>
- <data-source>
- <beans:bean class="some.datasoure.class" />
- </data-source>
- <insert-user>INSERT INTO FTP_USER (userid, userpassword,
- homedirectory, enableflag, writepermission, idletime, uploadrate,
- downloadrate) VALUES ('{userid}', '{userpassword}',
- '{homedirectory}',
- {enableflag}, {writepermission}, {idletime},
- {uploadrate},
- {downloadrate})
- </insert-user>
- <update-user>UPDATE FTP_USER SET
- userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate}
- WHERE userid='{userid}'
- </update-user>
- <delete-user>DELETE FROM FTP_USER WHERE userid = '{userid}'
- </delete-user>
- <select-user>SELECT userid, userpassword, homedirectory,
- enableflag, writepermission, idletime, uploadrate, downloadrate,
- maxloginnumber, maxloginperip FROM
- FTP_USER WHERE userid = '{userid}'
- </select-user>
- <select-all-users>SELECT userid FROM FTP_USER ORDER BY userid
- </select-all-users>
- <is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}'
- AND
- userid='admin'
- </is-admin>
- <authenticate>SELECT userpassword from FTP_USER WHERE
- userid='{userid}'</authenticate>
- </db-user-manager> -->
- <!-- The file system -->
- <native-filesystem case-insensitive="false"
- create-home="true" />
- <!--
- Use this section to define custom commands. Custom commands can also
- override already existing commands
- -->
- <commands use-default="false">
- <command name="MYHELP">
- <beans:bean class="org.apache.ftpserver.examples.MYHELP" />
- </command>
- </commands>
- <!-- Define the available languages -->
- <messages languages="se, no ,da" />
+ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ id="myServer">
+ <!--
+ Use this section to define custom listeners, or to redefine the
+ default listener, aptly named "default"
+ -->
+ <listeners>
+ <nio-listener name="default" port="2222" implicit-ssl="true"
+ idle-timeout="60" local-address="1.2.3.4">
+ <ssl>
+ <keystore file="mykeystore.jks" password="secret"
+ key-password="otherSecret" />
+ <truststore file="mytruststore.jks" password="secret" />
+ </ssl>
+ <data-connection idle-timeout="60">
+ <active enabled="true" local-address="1.2.3.4" local-port="2323"
+ ip-check="true" />
+ <passive ports="123-125" address="1.2.3.4" external-address="1.2.3.4" />
+ </data-connection>
+ <blacklist>1.2.3.0/16, 1.2.4.0/16, 1.2.3.4</blacklist>
+ </nio-listener>
+ </listeners>
+ <!--
+ Use this section to define your Ftplets, they are configured like
+ regular Spring beans
+ -->
+ <ftplets>
+ <ftplet name="ftplet1">
+ <beans:bean class="org.apache.ftpserver.examples.MyFtplet">
+ <beans:property name="foo" value="123" />
+ </beans:bean>
+ </ftplet>
+ </ftplets>
+ <!-- The user manager, choose one -->
+ <file-user-manager file="users.properties"
+ encrypt-passwords="true" />
+ <!--<db-user-manager>
+ <data-source>
+ <beans:bean class="some.datasoure.class" />
+ </data-source>
+ <insert-user>INSERT INTO FTP_USER (userid, userpassword,
+ homedirectory, enableflag, writepermission, idletime, uploadrate,
+ downloadrate) VALUES ('{userid}', '{userpassword}',
+ '{homedirectory}',
+ {enableflag}, {writepermission}, {idletime},
+ {uploadrate},
+ {downloadrate})
+ </insert-user>
+ <update-user>UPDATE FTP_USER SET
+ userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate}
+ WHERE userid='{userid}'
+ </update-user>
+ <delete-user>DELETE FROM FTP_USER WHERE userid = '{userid}'
+ </delete-user>
+ <select-user>SELECT userid, userpassword, homedirectory,
+ enableflag, writepermission, idletime, uploadrate, downloadrate,
+ maxloginnumber, maxloginperip FROM
+ FTP_USER WHERE userid = '{userid}'
+ </select-user>
+ <select-all-users>SELECT userid FROM FTP_USER ORDER BY userid
+ </select-all-users>
+ <is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}'
+ AND
+ userid='admin'
+ </is-admin>
+ <authenticate>SELECT userpassword from FTP_USER WHERE
+ userid='{userid}'</authenticate>
+ </db-user-manager> -->
+ <!-- The file system -->
+ <native-filesystem case-insensitive="false"
+ create-home="true" />
+ <!--
+ Use this section to define custom commands. Custom commands can also
+ override already existing commands
+ -->
+ <commands use-default="false">
+ <command name="MYHELP">
+ <beans:bean class="org.apache.ftpserver.examples.MYHELP" />
+ </command>
+ </commands>
+ <!-- Define the available languages -->
+ <messages languages="se, no ,da" />
</server>
\ No newline at end of file
diff --git a/distribution/res/conf/ftpd-typical.xml b/distribution/res/conf/ftpd-typical.xml
index a2600aa..ead6fe9 100644
--- a/distribution/res/conf/ftpd-typical.xml
+++ b/distribution/res/conf/ftpd-typical.xml
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
- "
- id="myServer">
- <listeners>
- <nio-listener name="default" port="2121">
- <ssl>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ id="myServer">
+ <listeners>
+ <nio-listener name="default" port="2121">
+ <ssl>
<keystore file="./res/ftpserver.jks" password="password" />
</ssl>
- </nio-listener>
- </listeners>
- <file-user-manager file="./res/conf/users.properties" />
+ </nio-listener>
+ </listeners>
+ <file-user-manager file="./res/conf/users.properties" />
</server>
\ No newline at end of file
diff --git a/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml b/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml
index 112f26b..b5d6014 100644
--- a/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml
+++ b/examples/ftpserver-osgi-spring-service/src/main/resources/META-INF/spring/bundle-context.xml
@@ -1,51 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
- xmlns:ftp="http://mina.apache.org/ftpserver/spring/v1"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xmlns:ftp="http://mina.apache.org/ftpserver/spring/v1"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://mina.apache.org/ftpserver/spring/v1
http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
">
- <ftp:server id="server">
- <ftp:listeners>
- <ftp:nio-listener name="default" port="2222" />
- </ftp:listeners>
- <ftp:ftplets>
- <ftp:ftplet name="ftplet1">
- <ref bean="ftplet" />
- </ftp:ftplet>
- </ftp:ftplets>
- <ftp:file-user-manager
- url="org/apache/ftpserver/example/osgiservice/users.properties" />
- </ftp:server>
-
- <osgi:service interface="org.apache.ftpserver.FtpServer"
- ref="server">
- </osgi:service>
+ <ftp:server id="server">
+ <ftp:listeners>
+ <ftp:nio-listener name="default" port="2222" />
+ </ftp:listeners>
+ <ftp:ftplets>
+ <ftp:ftplet name="ftplet1">
+ <ref bean="ftplet" />
+ </ftp:ftplet>
+ </ftp:ftplets>
+ <ftp:file-user-manager
+ url="org/apache/ftpserver/example/osgiservice/users.properties" />
+ </ftp:server>
+
+ <osgi:service interface="org.apache.ftpserver.FtpServer"
+ ref="server">
+ </osgi:service>
- <osgi:reference id="ftplet" interface="org.apache.ftpserver.ftplet.Ftplet" />
-
- <!-- Starts and stops the bean as the context is started and stopped -->
- <bean class="org.apache.ftpserver.example.osgiservice.impl.FtpServerLifecycle"
- init-method="init" destroy-method="destroy"
- >
- <property name="server" ref="server" />
- </bean>
+ <osgi:reference id="ftplet" interface="org.apache.ftpserver.ftplet.Ftplet" />
+
+ <!-- Starts and stops the bean as the context is started and stopped -->
+ <bean class="org.apache.ftpserver.example.osgiservice.impl.FtpServerLifecycle"
+ init-method="init" destroy-method="destroy"
+ >
+ <property name="server" ref="server" />
+ </bean>
</beans>
\ No newline at end of file
diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataTransferFtpReply.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataTransferFtpReply.java
index 2eaff15..f486a99 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataTransferFtpReply.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataTransferFtpReply.java
@@ -29,12 +29,10 @@ package org.apache.ftpserver.ftplet;
*/
public interface DataTransferFtpReply extends FileActionFtpReply {
-
- /**
- * Returns the number of bytes transferred.
- *
- * @return the number of bytes transferred.
- */
- long getBytesTransferred();
-
+ /**
+ * Returns the number of bytes transferred.
+ *
+ * @return the number of bytes transferred.
+ */
+ long getBytesTransferred();
}
diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java
index e90b05e..a6a9183 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java
@@ -81,15 +81,15 @@ public class DefaultFtpReply implements FtpReply {
}
public long getSentTime() {
- return sentTime;
+ return sentTime;
}
public boolean isPositive() {
- return code < 400;
+ return code < 400;
}
private boolean isDigit(char c) {
- return c >= 48 && c <= 57;
+ return c >= 48 && c <= 57;
}
/*
@@ -139,13 +139,13 @@ public class DefaultFtpReply implements FtpReply {
// "If an intermediary line begins with a 3-digit number, the Server
// must pad the front to avoid confusion.
if(i > 0
- && i + 1 < lines.length
- && line.length() > 2
- && isDigit(line.charAt(0))
- && isDigit(line.charAt(1))
- && isDigit(line.charAt(2))
- ) {
- sb.append(" ");
+ && i + 1 < lines.length
+ && line.length() > 2
+ && isDigit(line.charAt(0))
+ && isDigit(line.charAt(1))
+ && isDigit(line.charAt(2))
+ ) {
+ sb.append(" ");
}
sb.append(line);
sb.append(CRLF);
diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileActionFtpReply.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileActionFtpReply.java
index 7130e8f..fd81753 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileActionFtpReply.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileActionFtpReply.java
@@ -29,12 +29,12 @@ package org.apache.ftpserver.ftplet;
public interface FileActionFtpReply extends FtpReply {
- /**
- * Returns the file (or directory) on which the action was taken
- * (e.g. uploaded, created, listed)
- *
- * @return the file on which the action was taken. May return
- * <code>null</code>, if the file information is not available.
- */
- public FtpFile getFile();
+ /**
+ * Returns the file (or directory) on which the action was taken
+ * (e.g. uploaded, created, listed)
+ *
+ * @return the file on which the action was taken. May return
+ * <code>null</code>, if the file information is not available.
+ */
+ public FtpFile getFile();
}
diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Ftplet.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Ftplet.java
index 828ffac..605ae38 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Ftplet.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Ftplet.java
@@ -97,31 +97,31 @@ public interface Ftplet {
throws FtpException, IOException;
/**
- * Called by the ftplet container after a command has been executed by the
- * server. The implementation should return based on the desired action to
- * be taken by the server:
- * <ul>
- * <li>{@link FtpletResult#DEFAULT}: The server continues as normal</li>
- * <li>{@link FtpletResult#NO_FTPLET}: The server does not call any more
- * Ftplets before this command but continues as normal</li>
- * <li>{@link FtpletResult#SKIP}: Same as {@link FtpletResult#DEFAULT}</li>
- * <li>{@link FtpletResult#DISCONNECT}: The server will immediately
- * disconnect the client.</li>
- * <li>Ftplet throws exception: Same as {@link FtpletResult#DISCONNECT}</li>
- * </ul>
- *
- * @param session
- * The current session
- * @param request
- * The current request
- * @param reply
- * the reply that was sent for this command. Implementations can
- * use this to check the reply code and thus determine if the
- * command was successfully processed or not.
- * @return The desired action to be performed by the server
- * @throws FtpException
- * @throws IOException
- */
+ * Called by the ftplet container after a command has been executed by the
+ * server. The implementation should return based on the desired action to
+ * be taken by the server:
+ * <ul>
+ * <li>{@link FtpletResult#DEFAULT}: The server continues as normal</li>
+ * <li>{@link FtpletResult#NO_FTPLET}: The server does not call any more
+ * Ftplets before this command but continues as normal</li>
+ * <li>{@link FtpletResult#SKIP}: Same as {@link FtpletResult#DEFAULT}</li>
+ * <li>{@link FtpletResult#DISCONNECT}: The server will immediately
+ * disconnect the client.</li>
+ * <li>Ftplet throws exception: Same as {@link FtpletResult#DISCONNECT}</li>
+ * </ul>
+ *
+ * @param session
+ * The current session
+ * @param request
+ * The current request
+ * @param reply
+ * the reply that was sent for this command. Implementations can
+ * use this to check the reply code and thus determine if the
+ * command was successfully processed or not.
+ * @return The desired action to be performed by the server
+ * @throws FtpException
+ * @throws IOException
+ */
FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply)
throws FtpException, IOException;
diff --git a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/RenameFtpReply.java b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/RenameFtpReply.java
index 9d88af3..84b3d3d 100644
--- a/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/RenameFtpReply.java
+++ b/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/RenameFtpReply.java
@@ -29,20 +29,20 @@ package org.apache.ftpserver.ftplet;
public interface RenameFtpReply extends FtpReply {
- /**
- * Returns the file before the rename.
- *
- * @return the file before the rename. May return <code>null</code>, if
- * the file information is not available.
- */
- public FtpFile getFrom();
+ /**
+ * Returns the file before the rename.
+ *
+ * @return the file before the rename. May return <code>null</code>, if
+ * the file information is not available.
+ */
+ public FtpFile getFrom();
- /**
- * Returns the file after the rename.
- *
- * @return the file after the rename. May return <code>null</code>, if
- * the file information is not available.
- */
- public FtpFile getTo();
+ /**
+ * Returns the file after the rename.
+ *
+ * @return the file after the rename. May return <code>null</code>, if
+ * the file information is not available.
+ */
+ public FtpFile getTo();
}