├── .github
├── dependabot.yml
└── workflows
│ └── maven.yml
├── .gitignore
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── checkstyle-suppressions.xml
├── checkstyle.properties
├── checkstyle.xml
├── core
├── pom.xml
└── src
│ ├── examples
│ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── ftpserver
│ │ │ └── examples
│ │ │ ├── EmbeddingFtpServer.java
│ │ │ └── ManagingUsers.java
│ └── resources
│ │ ├── ftpserver.jks
│ │ └── spring-config
│ │ ├── config-ftplets.xml
│ │ ├── config-full.xml
│ │ ├── config-minimal.xml
│ │ └── config-typical.xml
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── ftpserver
│ │ │ ├── ConnectionConfig.java
│ │ │ ├── ConnectionConfigFactory.java
│ │ │ ├── DataConnectionConfiguration.java
│ │ │ ├── DataConnectionConfigurationFactory.java
│ │ │ ├── DataConnectionException.java
│ │ │ ├── FtpServer.java
│ │ │ ├── FtpServerConfigurationException.java
│ │ │ ├── FtpServerFactory.java
│ │ │ ├── Version.java
│ │ │ ├── command
│ │ │ ├── AbstractCommand.java
│ │ │ ├── Command.java
│ │ │ ├── CommandFactory.java
│ │ │ ├── CommandFactoryFactory.java
│ │ │ ├── NotSupportedCommand.java
│ │ │ └── impl
│ │ │ │ ├── ABOR.java
│ │ │ │ ├── ACCT.java
│ │ │ │ ├── APPE.java
│ │ │ │ ├── AUTH.java
│ │ │ │ ├── CDUP.java
│ │ │ │ ├── CWD.java
│ │ │ │ ├── DELE.java
│ │ │ │ ├── DefaultCommandFactory.java
│ │ │ │ ├── EPRT.java
│ │ │ │ ├── EPSV.java
│ │ │ │ ├── FEAT.java
│ │ │ │ ├── HELP.java
│ │ │ │ ├── LANG.java
│ │ │ │ ├── LIST.java
│ │ │ │ ├── MD5.java
│ │ │ │ ├── MDTM.java
│ │ │ │ ├── MFMT.java
│ │ │ │ ├── MKD.java
│ │ │ │ ├── MLSD.java
│ │ │ │ ├── MLST.java
│ │ │ │ ├── MODE.java
│ │ │ │ ├── NLST.java
│ │ │ │ ├── NOOP.java
│ │ │ │ ├── OPTS.java
│ │ │ │ ├── OPTS_MLST.java
│ │ │ │ ├── OPTS_UTF8.java
│ │ │ │ ├── PASS.java
│ │ │ │ ├── PASV.java
│ │ │ │ ├── PBSZ.java
│ │ │ │ ├── PORT.java
│ │ │ │ ├── PROT.java
│ │ │ │ ├── PWD.java
│ │ │ │ ├── QUIT.java
│ │ │ │ ├── REIN.java
│ │ │ │ ├── REST.java
│ │ │ │ ├── RETR.java
│ │ │ │ ├── RMD.java
│ │ │ │ ├── RNFR.java
│ │ │ │ ├── RNTO.java
│ │ │ │ ├── SITE.java
│ │ │ │ ├── SITE_DESCUSER.java
│ │ │ │ ├── SITE_HELP.java
│ │ │ │ ├── SITE_STAT.java
│ │ │ │ ├── SITE_WHO.java
│ │ │ │ ├── SITE_ZONE.java
│ │ │ │ ├── SIZE.java
│ │ │ │ ├── STAT.java
│ │ │ │ ├── STOR.java
│ │ │ │ ├── STOU.java
│ │ │ │ ├── STRU.java
│ │ │ │ ├── SYST.java
│ │ │ │ ├── TYPE.java
│ │ │ │ ├── USER.java
│ │ │ │ ├── listing
│ │ │ │ ├── DirectoryLister.java
│ │ │ │ ├── FileFilter.java
│ │ │ │ ├── FileFormater.java
│ │ │ │ ├── LISTFileFormater.java
│ │ │ │ ├── ListArgument.java
│ │ │ │ ├── ListArgumentParser.java
│ │ │ │ ├── MLSTFileFormater.java
│ │ │ │ ├── NLSTFileFormater.java
│ │ │ │ ├── RegexFileFilter.java
│ │ │ │ ├── VisibleFileFilter.java
│ │ │ │ └── package.html
│ │ │ │ └── package.html
│ │ │ ├── config
│ │ │ └── spring
│ │ │ │ ├── CommandFactoryBeanDefinitionParser.java
│ │ │ │ ├── FileSystemBeanDefinitionParser.java
│ │ │ │ ├── FtpServerNamespaceHandler.java
│ │ │ │ ├── ListenerBeanDefinitionParser.java
│ │ │ │ ├── ServerBeanDefinitionParser.java
│ │ │ │ ├── SpringUtil.java
│ │ │ │ ├── UserManagerBeanDefinitionParser.java
│ │ │ │ ├── factorybeans
│ │ │ │ ├── ConnectionConfigFactoryBean.java
│ │ │ │ ├── DataConnectionConfigurationFactoryBean.java
│ │ │ │ ├── FtpServerFactoryBean.java
│ │ │ │ ├── ListenerFactoryBean.java
│ │ │ │ └── SslConfigurationFactoryBean.java
│ │ │ │ └── package.html
│ │ │ ├── filesystem
│ │ │ └── nativefs
│ │ │ │ ├── NativeFileSystemFactory.java
│ │ │ │ └── impl
│ │ │ │ ├── NameEqualsFileFilter.java
│ │ │ │ ├── NativeFileSystemView.java
│ │ │ │ ├── NativeFtpFile.java
│ │ │ │ └── package.html
│ │ │ ├── ftpletcontainer
│ │ │ ├── FtpletContainer.java
│ │ │ └── impl
│ │ │ │ ├── DefaultFtpletContainer.java
│ │ │ │ └── package.html
│ │ │ ├── impl
│ │ │ ├── DefaultConnectionConfig.java
│ │ │ ├── DefaultDataConnectionConfiguration.java
│ │ │ ├── DefaultFtpHandler.java
│ │ │ ├── DefaultFtpRequest.java
│ │ │ ├── DefaultFtpServer.java
│ │ │ ├── DefaultFtpServerContext.java
│ │ │ ├── DefaultFtpSession.java
│ │ │ ├── DefaultFtpStatistics.java
│ │ │ ├── FileObserver.java
│ │ │ ├── FtpHandler.java
│ │ │ ├── FtpIoSession.java
│ │ │ ├── FtpReplyTranslator.java
│ │ │ ├── FtpServerContext.java
│ │ │ ├── IODataConnection.java
│ │ │ ├── IODataConnectionFactory.java
│ │ │ ├── LocalizedDataTransferFtpReply.java
│ │ │ ├── LocalizedFileActionFtpReply.java
│ │ │ ├── LocalizedFtpReply.java
│ │ │ ├── LocalizedRenameFtpReply.java
│ │ │ ├── PassivePorts.java
│ │ │ ├── ServerDataConnectionFactory.java
│ │ │ ├── ServerFtpStatistics.java
│ │ │ ├── StatisticsObserver.java
│ │ │ └── package.html
│ │ │ ├── ipfilter
│ │ │ ├── IpFilterType.java
│ │ │ ├── MinaSessionFilter.java
│ │ │ ├── RemoteIpFilter.java
│ │ │ └── SessionFilter.java
│ │ │ ├── listener
│ │ │ ├── Listener.java
│ │ │ ├── ListenerFactory.java
│ │ │ └── nio
│ │ │ │ ├── AbstractListener.java
│ │ │ │ ├── FtpHandlerAdapter.java
│ │ │ │ ├── FtpLoggingFilter.java
│ │ │ │ ├── FtpResponseEncoder.java
│ │ │ │ ├── FtpServerProtocolCodecFactory.java
│ │ │ │ ├── NioListener.java
│ │ │ │ └── package.html
│ │ │ ├── main
│ │ │ ├── AddUser.java
│ │ │ ├── CommandLine.java
│ │ │ └── Daemon.java
│ │ │ ├── message
│ │ │ ├── MessageResource.java
│ │ │ ├── MessageResourceFactory.java
│ │ │ └── impl
│ │ │ │ ├── DefaultMessageResource.java
│ │ │ │ └── package.html
│ │ │ ├── ssl
│ │ │ ├── ClientAuth.java
│ │ │ ├── SslConfiguration.java
│ │ │ ├── SslConfigurationFactory.java
│ │ │ └── impl
│ │ │ │ ├── AliasKeyManager.java
│ │ │ │ ├── DefaultSslConfiguration.java
│ │ │ │ ├── ExtendedAliasKeyManager.java
│ │ │ │ └── package.html
│ │ │ ├── usermanager
│ │ │ ├── AnonymousAuthentication.java
│ │ │ ├── ClearTextPasswordEncryptor.java
│ │ │ ├── DbUserManagerFactory.java
│ │ │ ├── Md5PasswordEncryptor.java
│ │ │ ├── PasswordEncryptor.java
│ │ │ ├── PropertiesUserManagerFactory.java
│ │ │ ├── SaltedPasswordEncryptor.java
│ │ │ ├── UserFactory.java
│ │ │ ├── UserManagerFactory.java
│ │ │ ├── UsernamePasswordAuthentication.java
│ │ │ └── impl
│ │ │ │ ├── AbstractUserManager.java
│ │ │ │ ├── BaseUser.java
│ │ │ │ ├── ConcurrentLoginPermission.java
│ │ │ │ ├── ConcurrentLoginRequest.java
│ │ │ │ ├── DbUserManager.java
│ │ │ │ ├── PropertiesUserManager.java
│ │ │ │ ├── TransferRatePermission.java
│ │ │ │ ├── TransferRateRequest.java
│ │ │ │ ├── UserMetadata.java
│ │ │ │ ├── WritePermission.java
│ │ │ │ └── WriteRequest.java
│ │ │ └── util
│ │ │ ├── BaseProperties.java
│ │ │ ├── ClassUtils.java
│ │ │ ├── DateUtils.java
│ │ │ ├── EncryptUtils.java
│ │ │ ├── FileRegularFilter.java
│ │ │ ├── IllegalInetAddressException.java
│ │ │ ├── IllegalPortException.java
│ │ │ ├── IoUtils.java
│ │ │ ├── OS.java
│ │ │ ├── PasswordUtil.java
│ │ │ ├── RegularExpr.java
│ │ │ ├── SocketAddressEncoder.java
│ │ │ └── StringUtils.java
│ └── resources
│ │ ├── META-INF
│ │ ├── spring.handlers
│ │ └── spring.schemas
│ │ └── org
│ │ └── apache
│ │ └── ftpserver
│ │ ├── config
│ │ └── spring
│ │ │ └── ftpserver-1.0.xsd
│ │ └── message
│ │ ├── FtpStatus.properties
│ │ ├── FtpStatus_en.properties
│ │ └── FtpStatus_zh-tw.properties
│ └── test
│ ├── java
│ └── org
│ │ └── apache
│ │ └── ftpserver
│ │ ├── VersionTest.java
│ │ ├── clienttests
│ │ ├── ActiveModeReplyTest.java
│ │ ├── BindExceptionSerialTest.java
│ │ ├── CdCaseInsensitiveTest.java
│ │ ├── CdTest.java
│ │ ├── ClientTestTemplate.java
│ │ ├── ConcatedCommandsTest.java
│ │ ├── ConnectPickPortTest.java
│ │ ├── ConnectTest.java
│ │ ├── CustomMaxLoginTest.java
│ │ ├── DataTransferTimeoutTest.java
│ │ ├── DecoderTest.java
│ │ ├── DefaultMaxLoginTest.java
│ │ ├── DeleteTest.java
│ │ ├── DirectoryTest.java
│ │ ├── FeatTest.java
│ │ ├── FtpMd5Test.java
│ │ ├── HelpTest.java
│ │ ├── I18NTest.java
│ │ ├── InetAddressBlacklistTest.java
│ │ ├── IpFilterTest.java
│ │ ├── LangTest.java
│ │ ├── ListPassiveTest.java
│ │ ├── ListTest.java
│ │ ├── LoginNoAnonTest.java
│ │ ├── LoginTest.java
│ │ ├── MDTMTest.java
│ │ ├── MFMTTest.java
│ │ ├── NLSTTest.java
│ │ ├── PasvAddressTest.java
│ │ ├── PasvAddressWithHostnameTest.java
│ │ ├── PasvAddressWithOverridenHostnameGetter.java
│ │ ├── PasvPortUnavailableTest.java
│ │ ├── PasvTest.java
│ │ ├── PasvUsedPortTest.java
│ │ ├── PortTest.java
│ │ ├── RenameTest.java
│ │ ├── RetrievePassiveTest.java
│ │ ├── RetrieveTest.java
│ │ ├── RmDirTest.java
│ │ ├── SiteTest.java
│ │ ├── SizeTest.java
│ │ ├── StatTest.java
│ │ ├── StorePassiveTest.java
│ │ ├── StoreTest.java
│ │ ├── SubnetBlacklistTest.java
│ │ ├── SuspendResumeTest.java
│ │ ├── SymbolicLinkTest.java
│ │ ├── SystTest.java
│ │ ├── TypeTest.java
│ │ └── UnlimitedMaxLoginTest.java
│ │ ├── commands
│ │ └── impl
│ │ │ ├── DefaultCommandFactoryTest.java
│ │ │ └── listing
│ │ │ ├── DirectoryListerTest.java
│ │ │ ├── LISTFileFormaterTest.java
│ │ │ ├── ListArgumentParserTest.java
│ │ │ ├── ListArgumentTest.java
│ │ │ ├── MLSTFileFormaterTest.java
│ │ │ └── NLSTFileFormaterTest.java
│ │ ├── config
│ │ └── spring
│ │ │ ├── DbUserManagerConfigTest.java
│ │ │ ├── FileUserManagerConfigTest.java
│ │ │ ├── FtpletsConfigTest.java
│ │ │ ├── MockUserManager.java
│ │ │ ├── MyCustomListener.java
│ │ │ ├── PropertyPlaceholderTest.java
│ │ │ ├── SpringConfigTest.java
│ │ │ ├── SpringConfigTestTemplate.java
│ │ │ └── TestFtplet.java
│ │ ├── filesystem
│ │ └── nativefs
│ │ │ └── impl
│ │ │ ├── FileSystemViewTemplate.java
│ │ │ ├── FtpFileTestTemplate.java
│ │ │ ├── NativeFileSystemViewTest.java
│ │ │ └── NativeFtpFileTest.java
│ │ ├── ftpletcontainer
│ │ ├── DefaultFtpLetContainerTest.java
│ │ ├── FtpLetContainerTestTemplate.java
│ │ ├── FtpLetOnConnectTest.java
│ │ ├── FtpLetReturnDefaultTest.java
│ │ ├── FtpLetReturnDisconnectTest.java
│ │ ├── FtpLetReturnSkipTest.java
│ │ ├── FtpLetThrowFtpExceptionTest.java
│ │ ├── FtpLetThrowIOExceptionTest.java
│ │ ├── FtpLetThrowRuntimeExceptionTest.java
│ │ ├── MockFtplet.java
│ │ └── MockFtpletCallback.java
│ │ ├── impl
│ │ ├── DefaultFtpServerTest.java
│ │ ├── FtpRequestImplTest.java
│ │ ├── FtpStatisticsImplTest.java
│ │ ├── PassivePortsTest.java
│ │ └── ServerFtpStatisticsTestTemplate.java
│ │ ├── ssl
│ │ ├── ExplicitSecurityTestTemplate.java
│ │ ├── ImplicitSecurityTestTemplate.java
│ │ ├── MinaCipherSuitesTest.java
│ │ ├── MinaClientAuthTest.java
│ │ ├── MinaExplicitSSLTest.java
│ │ ├── MinaExplicitTLSTest.java
│ │ ├── MinaImplicitClientAuthTest.java
│ │ ├── MinaImplicitDataChannelTest.java
│ │ ├── MinaImplicitSSLTest.java
│ │ ├── MinaImplicitTLSTest.java
│ │ ├── SSLTestTemplate.java
│ │ └── impl
│ │ │ ├── AliasKeymanagerTest.java
│ │ │ └── ExtendedAliasKeymanagerTest.java
│ │ ├── test
│ │ └── TestUtil.java
│ │ ├── usermanager
│ │ ├── UsernamePasswordAuthenticationTest.java
│ │ └── impl
│ │ │ ├── BaseUserTest.java
│ │ │ ├── ClearTextDbUserManagerTest.java
│ │ │ ├── ClearTextPasswordEncryptorTest.java
│ │ │ ├── ConcurrentLoginPermissionTest.java
│ │ │ ├── DbUserManagerTest.java
│ │ │ ├── Md5PasswordEncryptorTest.java
│ │ │ ├── PropertiesUserManagerTest.java
│ │ │ ├── SaltedPasswordEncryptorTest.java
│ │ │ ├── UserManagerTestTemplate.java
│ │ │ ├── VolatilePropertiesUserManagerTest.java
│ │ │ └── WritePermissionTest.java
│ │ └── util
│ │ ├── BasePropertiesTest.java
│ │ ├── EncryptUtilsTest.java
│ │ ├── RegularExprTest.java
│ │ └── SocketAddressEncoderTest.java
│ └── resources
│ ├── dbusermanagertest-cleartext-hsql.sql
│ ├── dbusermanagertest-hsql.sql
│ ├── ftpclient.jks
│ ├── ftpserver.jks
│ ├── keymanager-test.jks
│ ├── log4j.properties
│ ├── org
│ └── apache
│ │ └── ftpserver
│ │ └── ftpserver.properties
│ ├── spring-config
│ ├── config-property-placeholder.xml
│ ├── config-spring-1.xml
│ └── placeholder.properties
│ └── users.properties
├── distribution
├── LICENSE.slf4j.txt
├── LICENSE.springframework.txt
├── README.txt
├── bin
│ ├── appendcp.bat
│ ├── ftpd.bat
│ ├── ftpd.exe
│ ├── ftpd.sh
│ ├── ftpdw.exe
│ └── service.bat
├── common
│ ├── classes
│ │ └── log4j.properties
│ └── lib
│ │ ├── .cvsignore
│ │ └── README.txt
├── pom.xml
├── res
│ ├── conf
│ │ ├── README.txt
│ │ ├── ftpd-full.xml
│ │ ├── ftpd-typical.xml
│ │ └── users.properties
│ ├── ftp-db.sql
│ ├── ftpserver.jks
│ ├── home
│ │ └── README.txt
│ └── log
│ │ └── README.txt
└── src
│ └── main
│ └── assemblies
│ ├── bin.xml
│ └── src.xml
├── examples
├── ftpserver-example-spring-war
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── ftpserver
│ │ │ └── example
│ │ │ └── springwar
│ │ │ ├── FtpServerListener.java
│ │ │ ├── FtpServerServlet.java
│ │ │ └── package-info.java
│ │ ├── resources
│ │ ├── ftpserver.jks
│ │ ├── log4j.properties
│ │ └── users.properties
│ │ └── webapp
│ │ └── WEB-INF
│ │ ├── applicationContext.xml
│ │ └── web.xml
├── ftpserver-osgi-ftplet-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── ftpserver
│ │ └── example
│ │ └── ftpletservice
│ │ ├── MyFtplet.java
│ │ ├── impl
│ │ ├── Activator.java
│ │ └── package-info.java
│ │ └── package-info.java
├── ftpserver-osgi-spring-service
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── ftpserver
│ │ │ └── example
│ │ │ └── osgiservice
│ │ │ └── impl
│ │ │ └── FtpServerLifecycle.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── spring
│ │ │ └── bundle-context.xml
│ │ └── org
│ │ └── apache
│ │ └── ftpserver
│ │ └── example
│ │ └── osgiservice
│ │ └── users.properties
└── pom.xml
├── ftplet-api
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── apache
│ │ └── ftpserver
│ │ └── ftplet
│ │ ├── Authentication.java
│ │ ├── AuthenticationFailedException.java
│ │ ├── Authority.java
│ │ ├── AuthorizationRequest.java
│ │ ├── DataConnection.java
│ │ ├── DataConnectionFactory.java
│ │ ├── DataTransferFtpReply.java
│ │ ├── DataType.java
│ │ ├── DefaultFtpReply.java
│ │ ├── DefaultFtplet.java
│ │ ├── FileActionFtpReply.java
│ │ ├── FileSystemFactory.java
│ │ ├── FileSystemView.java
│ │ ├── FtpException.java
│ │ ├── FtpFile.java
│ │ ├── FtpReply.java
│ │ ├── FtpRequest.java
│ │ ├── FtpSession.java
│ │ ├── FtpStatistics.java
│ │ ├── Ftplet.java
│ │ ├── FtpletContext.java
│ │ ├── FtpletResult.java
│ │ ├── RenameFtpReply.java
│ │ ├── Structure.java
│ │ ├── User.java
│ │ └── UserManager.java
│ └── test
│ └── java
│ └── org
│ └── apache
│ └── ftpserver
│ └── ftplet
│ ├── DataTypeTest.java
│ ├── DefaultFtpReplyTest.java
│ ├── ExampleFtplet.java
│ └── StructureTest.java
└── pom.xml
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | version: 2
17 | updates:
18 | - package-ecosystem: "maven"
19 | target-branch: 1.2.X
20 | directory: "/"
21 | schedule:
22 | interval: "weekly"
23 | day: "friday"
24 | - package-ecosystem: "github-actions"
25 | target-branch: 1.2.X
26 | directory: "/"
27 | schedule:
28 | interval: "weekly"
29 | day: "friday"
30 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | name: Java CI
17 |
18 | on: [push, pull_request]
19 |
20 | jobs:
21 | build:
22 |
23 | runs-on: ubuntu-latest
24 | continue-on-error: ${{ matrix.experimental }}
25 | strategy:
26 | matrix:
27 | java: [ 8, 11, 17 ]
28 | experimental: [false]
29 | # include:
30 | # - java: 19-ea
31 | # experimental: true
32 | steps:
33 | - uses: actions/checkout@v3
34 | - uses: actions/cache@v2.1.7
35 | with:
36 | path: ~/.m2/repository
37 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
38 | restore-keys: |
39 | ${{ runner.os }}-maven-
40 | - name: Set up JDK ${{ matrix.java }}
41 | uses: actions/setup-java@v2
42 | with:
43 | distribution: 'temurin'
44 | java-version: ${{ matrix.java }}
45 | - name: Build with Maven
46 | run: mvn -V -Ddoclint=all --file pom.xml --no-transfer-progress -P enforce.activate
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .project
3 | .settings
4 | .classpath
5 | .idea
6 | bin/
7 |
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | Apache FtpServer
2 | Copyright 2003-2008 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
17 | # mina-ftpserver
18 | The active branches are:
19 | - 1.1.x
20 | - 1.2.x
21 |
22 | We do not use the branch `master`.
23 |
24 |
--------------------------------------------------------------------------------
/checkstyle-suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 | Server
implementation is used to create the server
28 | * socket and handle client connection.
29 | *
30 | * @author Apache MINA Project
31 | */
32 | public interface FtpServer {
33 |
34 | /**
35 | * Start the server. Open a new listener thread.
36 | * @throws FtpException
37 | */
38 | void start() throws FtpException;
39 |
40 | /**
41 | * Stop the server. Stop the listener thread.
42 | */
43 | void stop();
44 |
45 | /**
46 | * Get the server status.
47 | * @return true if the server is stopped
48 | */
49 | boolean isStopped();
50 |
51 | /**
52 | * Suspend further requests
53 | */
54 | void suspend();
55 |
56 | /**
57 | * Resume the server handler
58 | */
59 | void resume();
60 |
61 | /**
62 | * Is the server suspended
63 | * @return true if the server is suspended
64 | */
65 | boolean isSuspended();
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/FtpServerConfigurationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver;
21 |
22 | /**
23 | * Exception used during startup to indicate that the configuration is not
24 | * correct.
25 | *
26 | * @author Apache MINA Project
27 | */
28 | public class FtpServerConfigurationException extends RuntimeException {
29 |
30 | private static final long serialVersionUID = -1328432839915898987L;
31 |
32 | /**
33 | * {@link RuntimeException#RuntimeException()}
34 | */
35 | public FtpServerConfigurationException() {
36 | super();
37 | }
38 |
39 | /**
40 | * {@link RuntimeException#RuntimeException(String, Throwable)}
41 | */
42 | public FtpServerConfigurationException(final String message,
43 | final Throwable cause) {
44 | super(message, cause);
45 | }
46 |
47 | /**
48 | * {@link RuntimeException#RuntimeException(String)}
49 | */
50 | public FtpServerConfigurationException(final String message) {
51 | super(message);
52 | }
53 |
54 | /**
55 | * {@link RuntimeException#RuntimeException(Throwable)}
56 | */
57 | public FtpServerConfigurationException(final Throwable cause) {
58 | super(cause);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/Version.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver;
21 |
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 | import java.io.UncheckedIOException;
25 | import java.util.Properties;
26 |
27 | import org.apache.ftpserver.util.IoUtils;
28 |
29 | /**
30 | * Provides the version of this release of FtpServer
31 | *
32 | * @author Apache MINA Project
33 | */
34 | public class Version {
35 |
36 | /**
37 | * Get the version of this FtpServer
38 | * @return The current version
39 | */
40 | public static String getVersion() {
41 | Properties props = new Properties();
42 | InputStream in = null;
43 |
44 | try {
45 | in = Version.class.getClassLoader().getResourceAsStream("org/apache/ftpserver/ftpserver.properties");
46 | props.load(in);
47 | return props.getProperty("ftpserver.version");
48 | } catch (IOException e) {
49 | throw new UncheckedIOException("Failed to read version", e);
50 | } finally {
51 | IoUtils.close(in);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/AbstractCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command;
21 |
22 |
23 | /**
24 | * Common base class recommended for {@link Command} implementations
25 | *
26 | * @author Apache MINA Project
27 | */
28 | public abstract class AbstractCommand implements Command {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/Command.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command;
21 |
22 | import java.io.IOException;
23 |
24 | import org.apache.ftpserver.ftplet.FtpException;
25 | import org.apache.ftpserver.ftplet.FtpRequest;
26 | import org.apache.ftpserver.impl.FtpIoSession;
27 | import org.apache.ftpserver.impl.FtpServerContext;
28 |
29 | /**
30 | * This interface encapsulates all the FTP commands.
31 | *
32 | * @author Apache MINA Project
33 | */
34 | public interface Command {
35 |
36 | /**
37 | * Execute command.
38 | *
39 | * @param session
40 | * The current {@link FtpIoSession}
41 | * @param context
42 | * The current {@link FtpServerContext}
43 | * @param request The current {@link FtpRequest}
44 | * @throws IOException
45 | * @throws FtpException
46 | */
47 | void execute(FtpIoSession session, FtpServerContext context,
48 | FtpRequest request) throws IOException, FtpException;
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/NotSupportedCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command;
21 |
22 | import java.io.IOException;
23 |
24 | import org.apache.ftpserver.ftplet.FtpReply;
25 | import org.apache.ftpserver.ftplet.FtpRequest;
26 | import org.apache.ftpserver.impl.FtpIoSession;
27 | import org.apache.ftpserver.impl.FtpServerContext;
28 | import org.apache.ftpserver.impl.LocalizedFtpReply;
29 |
30 | /**
31 | * A command used primarily for overriding already installed commands when one
32 | * wants to disable the command.
33 | *
34 | * @author Apache MINA Project
35 | */
36 | public class NotSupportedCommand extends AbstractCommand {
37 |
38 | /**
39 | * Execute command
40 | */
41 | public void execute(final FtpIoSession session,
42 | final FtpServerContext context, final FtpRequest request)
43 | throws IOException {
44 |
45 | // reset state variables
46 | session.resetState();
47 |
48 | // We do not support this command
49 | session.write(LocalizedFtpReply.translate(session, request, context,
50 | FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "Not supported",
51 | null));
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/PBSZ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command.impl;
21 |
22 | import java.io.IOException;
23 |
24 | import org.apache.ftpserver.command.AbstractCommand;
25 | import org.apache.ftpserver.ftplet.FtpException;
26 | import org.apache.ftpserver.ftplet.FtpReply;
27 | import org.apache.ftpserver.ftplet.FtpRequest;
28 | import org.apache.ftpserver.impl.FtpIoSession;
29 | import org.apache.ftpserver.impl.FtpServerContext;
30 | import org.apache.ftpserver.impl.LocalizedFtpReply;
31 |
32 | /**
33 | * Internal class, do not use directly.
34 | *
35 | * Protection buffer size.
36 | *
37 | * @author Apache MINA Project
38 | */
39 | public class PBSZ extends AbstractCommand {
40 |
41 | /**
42 | * Execute command.
43 | */
44 | public void execute(final FtpIoSession session,
45 | final FtpServerContext context, final FtpRequest request)
46 | throws IOException, FtpException {
47 |
48 | session.resetState();
49 | session.write(LocalizedFtpReply.translate(session, request, context,
50 | FtpReply.REPLY_200_COMMAND_OKAY, "PBSZ", null));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/REIN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command.impl;
21 |
22 | import java.io.IOException;
23 |
24 | import org.apache.ftpserver.command.AbstractCommand;
25 | import org.apache.ftpserver.ftplet.FtpReply;
26 | import org.apache.ftpserver.ftplet.FtpRequest;
27 | import org.apache.ftpserver.impl.FtpIoSession;
28 | import org.apache.ftpserver.impl.FtpServerContext;
29 | import org.apache.ftpserver.impl.LocalizedFtpReply;
30 |
31 | /**
32 | * Internal class, do not use directly.
33 | *
34 | * REIN <CRLF>
35 | *
36 | * This command flushes a USER, without affecting transfers in progress. The
37 | * server state should otherwise be as when the user first connects.
38 | *
39 | * @author Apache MINA Project
40 | */
41 | public class REIN extends AbstractCommand {
42 |
43 | /**
44 | * Execute command.
45 | */
46 | public void execute(final FtpIoSession session,
47 | final FtpServerContext context, final FtpRequest request)
48 | throws IOException {
49 |
50 | session.reinitialize();
51 | session.setLanguage(null);
52 | session.write(LocalizedFtpReply.translate(session, request, context,
53 | FtpReply.REPLY_220_SERVICE_READY, "REIN", null));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/SITE_HELP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.command.impl;
21 |
22 | import java.io.IOException;
23 |
24 | import org.apache.ftpserver.command.AbstractCommand;
25 | import org.apache.ftpserver.ftplet.FtpException;
26 | import org.apache.ftpserver.ftplet.FtpReply;
27 | import org.apache.ftpserver.ftplet.FtpRequest;
28 | import org.apache.ftpserver.impl.FtpIoSession;
29 | import org.apache.ftpserver.impl.FtpServerContext;
30 | import org.apache.ftpserver.impl.LocalizedFtpReply;
31 |
32 | /**
33 | * Internal class, do not use directly.
34 | *
35 | * Show SITE help message.
36 | *
37 | * @author Apache MINA Project
38 | */
39 | public class SITE_HELP extends AbstractCommand {
40 |
41 | /**
42 | * Execute command.
43 | */
44 | public void execute(final FtpIoSession session,
45 | final FtpServerContext context, final FtpRequest request)
46 | throws IOException, FtpException {
47 |
48 | // reset state variables
49 | session.resetState();
50 |
51 | // print help message
52 | session.write(LocalizedFtpReply.translate(session, request, context,
53 | FtpReply.REPLY_200_COMMAND_OKAY, "SITE.HELP", null));
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/listing/FileFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.ftpserver.command.impl.listing;
20 |
21 | import org.apache.ftpserver.ftplet.FtpFile;
22 |
23 | /**
24 | * Internal class, do not use directly.
25 | *
26 | * Interface for selecting files based on some critera.
27 | *
28 | * @see java.io.FileFilter
29 | *
30 | * @author Apache MINA Project
31 | */
32 | public interface FileFilter {
33 |
34 | /**
35 | * Decide if the {@link FtpFile} should be selected
36 | *
37 | * @param file
38 | * The {@link FtpFile}
39 | * @return true if the {@link FtpFile} was selected
40 | */
41 | boolean accept(FtpFile file);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/listing/FileFormater.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.ftpserver.command.impl.listing;
20 |
21 | import org.apache.ftpserver.ftplet.FtpFile;
22 |
23 | /**
24 | * Internal class, do not use directly.
25 | *
26 | * Interface for formating output based on a {@link FtpFile}
27 | *
28 | * @author Apache MINA Project
29 | */
30 | public interface FileFormater {
31 |
32 | /**
33 | * Format the file
34 | *
35 | * @param file
36 | * The {@link FtpFile}
37 | * @return The formated string based on the {@link FtpFile}
38 | */
39 | String format(FtpFile file);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/listing/NLSTFileFormater.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.ftpserver.command.impl.listing;
20 |
21 | import org.apache.ftpserver.ftplet.FtpFile;
22 |
23 | /**
24 | * Internal class, do not use directly.
25 | *
26 | * Formats files according to the NLST specification
27 | *
28 | * @author Apache MINA Project
29 | */
30 | public class NLSTFileFormater implements FileFormater {
31 |
32 | private final static char[] NEWLINE = { '\r', '\n' };
33 |
34 | /**
35 | * @see FileFormater#format(FtpFile)
36 | */
37 | public String format(FtpFile file) {
38 | StringBuilder sb = new StringBuilder();
39 | sb.append(file.getName());
40 | sb.append(NEWLINE);
41 |
42 | return sb.toString();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/listing/VisibleFileFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.ftpserver.command.impl.listing;
20 |
21 | import org.apache.ftpserver.ftplet.FtpFile;
22 |
23 | /**
24 | * Internal class, do not use directly.
25 | *
26 | * Selects files that are visible
27 | *
28 | * @author Apache MINA Project
29 | */
30 | public class VisibleFileFilter implements FileFilter {
31 |
32 | private final FileFilter wrappedFilter;
33 |
34 | /**
35 | * Default constructor
36 | */
37 | public VisibleFileFilter() {
38 | this(null);
39 | }
40 |
41 | /**
42 | * Constructor with a wrapped filter, allows for chaining filters
43 | *
44 | * @param wrappedFilter
45 | * The {@link FileFilter} to wrap
46 | */
47 | public VisibleFileFilter(FileFilter wrappedFilter) {
48 | this.wrappedFilter = wrappedFilter;
49 | }
50 |
51 | /**
52 | * @see FileFilter#accept(FtpFile)
53 | */
54 | public boolean accept(FtpFile file) {
55 | if (wrappedFilter != null && !wrappedFilter.accept(file)) {
56 | return false;
57 | }
58 |
59 | return !file.isHidden();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/command/impl/listing/package.html:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
File listing implementations used by various FTP commands
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/command/impl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |FTP command implementations
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/factorybeans/ConnectionConfigFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring.factorybeans; 21 | 22 | import org.apache.ftpserver.ConnectionConfig; 23 | import org.apache.ftpserver.ConnectionConfigFactory; 24 | import org.springframework.beans.factory.FactoryBean; 25 | 26 | /** 27 | * Spring {@link FactoryBean} which extends {@link ConnectionConfigFactory} 28 | * making it easier to use Spring's standard <bean> tag instead of 29 | * FtpServer's custom XML tags to configure things. 30 | * 31 | * @author Apache MINA Project 32 | * @see ConnectionConfigFactory 33 | */ 34 | public class ConnectionConfigFactoryBean extends ConnectionConfigFactory implements FactoryBean { 35 | 36 | public Object getObject() throws Exception { 37 | return createConnectionConfig(); 38 | } 39 | 40 | public Class> getObjectType() { 41 | return ConnectionConfig.class; 42 | } 43 | 44 | public boolean isSingleton() { 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/factorybeans/DataConnectionConfigurationFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring.factorybeans; 21 | 22 | import org.apache.ftpserver.DataConnectionConfiguration; 23 | import org.apache.ftpserver.DataConnectionConfigurationFactory; 24 | import org.springframework.beans.factory.FactoryBean; 25 | 26 | /** 27 | * Spring {@link FactoryBean} which extends {@link DataConnectionConfigurationFactory} 28 | * making it easier to use Spring's standard <bean> tag instead of 29 | * FtpServer's custom XML tags to configure things. 30 | * 31 | * @author Apache MINA Project 32 | * @see DataConnectionConfigurationFactory 33 | */ 34 | public class DataConnectionConfigurationFactoryBean extends DataConnectionConfigurationFactory implements FactoryBean { 35 | 36 | public Object getObject() throws Exception { 37 | return createDataConnectionConfiguration(); 38 | } 39 | 40 | public Class> getObjectType() { 41 | return DataConnectionConfiguration.class; 42 | } 43 | 44 | public boolean isSingleton() { 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/factorybeans/FtpServerFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring.factorybeans; 21 | 22 | import org.apache.ftpserver.FtpServer; 23 | import org.apache.ftpserver.FtpServerFactory; 24 | import org.springframework.beans.factory.FactoryBean; 25 | 26 | /** 27 | * Spring {@link FactoryBean} which extends {@link FtpServerFactory} 28 | * making it easier to use Spring's standard <bean> tag instead of 29 | * FtpServer's custom XML tags to configure things. 30 | * 31 | * @author Apache MINA Project 32 | * @see FtpServerFactory 33 | */ 34 | public class FtpServerFactoryBean extends FtpServerFactory implements FactoryBean { 35 | 36 | public Object getObject() throws Exception { 37 | return createServer(); 38 | } 39 | 40 | public Class> getObjectType() { 41 | return FtpServer.class; 42 | } 43 | 44 | public boolean isSingleton() { 45 | return false; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/factorybeans/ListenerFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring.factorybeans; 21 | 22 | import org.apache.ftpserver.listener.Listener; 23 | import org.apache.ftpserver.listener.ListenerFactory; 24 | import org.springframework.beans.factory.FactoryBean; 25 | 26 | /** 27 | * Spring {@link FactoryBean} which extends {@link ListenerFactory} 28 | * making it easier to use Spring's standard <bean> tag instead of 29 | * FtpServer's custom XML tags to configure things. 30 | * 31 | * @author Apache MINA Project 32 | * @see ListenerFactory 33 | */ 34 | public class ListenerFactoryBean extends ListenerFactory implements FactoryBean { 35 | 36 | public Object getObject() throws Exception { 37 | return createListener(); 38 | } 39 | 40 | public Class> getObjectType() { 41 | return Listener.class; 42 | } 43 | 44 | public boolean isSingleton() { 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/factorybeans/SslConfigurationFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring.factorybeans; 21 | 22 | import org.apache.ftpserver.ssl.SslConfiguration; 23 | import org.apache.ftpserver.ssl.SslConfigurationFactory; 24 | import org.springframework.beans.factory.FactoryBean; 25 | 26 | /** 27 | * Spring {@link FactoryBean} which extends {@link SslConfigurationFactory} 28 | * making it easier to use Spring's standard <bean> tag instead of 29 | * FtpServer's custom XML tags to configure things. 30 | * 31 | * @author Apache MINA Project 32 | * @see SslConfigurationFactory 33 | */ 34 | public class SslConfigurationFactoryBean extends SslConfigurationFactory implements FactoryBean { 35 | 36 | public Object getObject() throws Exception { 37 | return createSslConfiguration(); 38 | } 39 | 40 | public Class> getObjectType() { 41 | return SslConfiguration.class; 42 | } 43 | 44 | public boolean isSingleton() { 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/config/spring/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |Support classes for Spring based XML configuration
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NameEqualsFileFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.filesystem.nativefs.impl; 21 | 22 | import java.io.File; 23 | import java.io.FileFilter; 24 | 25 | /** 26 | * Internal class, do not use directly. 27 | * 28 | * FileFilter used for simple file name matching 29 | * 30 | * @author Apache MINA Project 31 | */ 32 | public class NameEqualsFileFilter implements FileFilter { 33 | 34 | private final String nameToMatch; 35 | 36 | private final boolean caseInsensitive; 37 | 38 | /** 39 | * Constructor 40 | * 41 | * @param nameToMatch 42 | * The exact file name to match 43 | * @param caseInsensitive 44 | * Wether that match should be case insensitive 45 | */ 46 | public NameEqualsFileFilter(final String nameToMatch, 47 | final boolean caseInsensitive) { 48 | this.nameToMatch = nameToMatch; 49 | this.caseInsensitive = caseInsensitive; 50 | } 51 | 52 | public boolean accept(final File file) { 53 | 54 | if (caseInsensitive) { 55 | return file.getName().equalsIgnoreCase(nameToMatch); 56 | } else { 57 | return file.getName().equals(nameToMatch); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |Native file system implementation
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/ftpletcontainer/FtpletContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.ftpletcontainer; 21 | 22 | import java.util.Map; 23 | 24 | import org.apache.ftpserver.ftplet.Ftplet; 25 | 26 | /** 27 | * Interface describing an Ftplet container. Ftplet containers extend the 28 | * {@link Ftplet} interface and forward any events to the Ftplets hosted by the 29 | * container. 30 | * 31 | * @author Apache MINA Project 32 | */ 33 | public interface FtpletContainer extends Ftplet { 34 | 35 | /** 36 | * Retrieve the {@link Ftplet} identified by the name (as provided in the 37 | * {@link #addFtplet(String, Ftplet)} method. 38 | * 39 | * @param name 40 | * The name of the Ftplet to retrive 41 | * @return The Ftplet if found, or null if the name is unknown to the 42 | * container. 43 | */ 44 | Ftplet getFtplet(String name); 45 | 46 | /** 47 | * Retrive all Ftplets registered with this container 48 | * 49 | * @return A map of all Ftplets with their name as the key 50 | */ 51 | MapFtplet container implementation
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/impl/FileObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.impl; 21 | 22 | import org.apache.ftpserver.ftplet.FtpFile; 23 | 24 | /** 25 | * Internal class, do not use directly. 26 | * 27 | * This is the file related activity observer. 28 | * 29 | * @author Apache MINA Project 30 | */ 31 | public interface FileObserver { 32 | 33 | /** 34 | * User file upload notification. 35 | */ 36 | void notifyUpload(FtpIoSession session, FtpFile file, long size); 37 | 38 | /** 39 | * User file download notification. 40 | */ 41 | void notifyDownload(FtpIoSession session, FtpFile file, long size); 42 | 43 | /** 44 | * User file delete notification. 45 | */ 46 | void notifyDelete(FtpIoSession session, FtpFile file); 47 | 48 | /** 49 | * User make directory notification. 50 | */ 51 | void notifyMkdir(FtpIoSession session, FtpFile file); 52 | 53 | /** 54 | * User remove directory notification. 55 | */ 56 | void notifyRmdir(FtpIoSession session, FtpFile file); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/impl/LocalizedFtpReply.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.impl; 21 | 22 | import org.apache.ftpserver.ftplet.DefaultFtpReply; 23 | import org.apache.ftpserver.ftplet.FtpRequest; 24 | 25 | /** 26 | * Internal class, do not use directly. 27 | * 28 | * FTP reply translator. 29 | * 30 | * @author Apache MINA Project 31 | */ 32 | public class LocalizedFtpReply extends DefaultFtpReply { 33 | 34 | public static LocalizedFtpReply translate(FtpIoSession session, FtpRequest request, 35 | FtpServerContext context, int code, String subId, String basicMsg) { 36 | String msg = FtpReplyTranslator.translateMessage(session, request, context, code, subId, 37 | basicMsg); 38 | 39 | return new LocalizedFtpReply(code, msg); 40 | } 41 | 42 | /** 43 | * Creates a new instance ofLocalizedFtpReply
.
44 | *
45 | * @param code
46 | * the reply code
47 | * @param message
48 | * the reply text
49 | */
50 | public LocalizedFtpReply(int code, String message) {
51 | super(code, message);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/impl/package.html:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 | Internal classes, do not use directly!
23 |
24 |
25 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/ipfilter/IpFilterType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ipfilter;
21 |
22 | /**
23 | * Defines various types of IP Filters.
24 | *
25 | * @author Apache MINA Project
26 | *
27 | */
28 | public enum IpFilterType {
29 |
30 | /**
31 | * filter type that allows a set of predefined IP addresses, also known as a
32 | * white list.
33 | */
34 | ALLOW,
35 |
36 | /**
37 | * filter type that blocks a set of predefined IP addresses, also known as a
38 | * black list.
39 | */
40 | DENY;
41 |
42 | /**
43 | * Parses the given string into its equivalent enum.
44 | *
45 | * @param value
46 | * the string value to parse.
47 | * @return the equivalent enum
48 | */
49 | public static IpFilterType parse(String value) {
50 | for (IpFilterType type : values()) {
51 | if (type.name().equalsIgnoreCase(value)) {
52 | return type;
53 | }
54 | }
55 | throw new IllegalArgumentException("Invalid IpFilterType: " + value);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/ipfilter/MinaSessionFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ipfilter;
21 |
22 | import org.apache.mina.core.filterchain.IoFilterAdapter;
23 | import org.apache.mina.core.session.IoSession;
24 |
25 | /**
26 | * A wrapper for SessionFilter
so it can be added to the MINA
27 | * filter chain.
28 | *
29 | * @author Apache MINA Project
30 | *
31 | */
32 |
33 | public class MinaSessionFilter extends IoFilterAdapter {
34 |
35 | /**
36 | * The actual (or wrapped) SessionFilter
used by this filter.
37 | */
38 | private final SessionFilter filter;
39 |
40 | /**
41 | * Creates a new instance of MinaSessionFilter
.
42 | *
43 | * @param filter
44 | * the filter
45 | */
46 | public MinaSessionFilter(SessionFilter filter) {
47 | this.filter = filter;
48 | }
49 |
50 | @Override
51 | public void sessionCreated(NextFilter nextFilter, IoSession session) {
52 | if (!filter.accept(session)) {
53 | session.close(true);
54 | } else {
55 | nextFilter.sessionCreated(session);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/ipfilter/SessionFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ipfilter;
21 |
22 | import org.apache.mina.core.session.IoSession;
23 |
24 | /**
25 | * The interface for filtering sessions based on various session attributes.
26 | *
27 | * @author Apache MINA Project
28 | *
29 | */
30 |
31 | public interface SessionFilter {
32 |
33 | /**
34 | * Tells whether or not the given session is accepted by this filter.
35 | *
36 | * @param session
37 | * the session to check
38 | * @return true
, if the given session is accepted by this
39 | * filter; false
, otherwise.
40 | */
41 | public boolean accept(IoSession session);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/listener/nio/FtpResponseEncoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | */
20 | package org.apache.ftpserver.listener.nio;
21 |
22 | import java.nio.charset.Charset;
23 | import java.nio.charset.CharsetEncoder;
24 |
25 | import org.apache.ftpserver.ftplet.FtpReply;
26 | import org.apache.mina.core.buffer.IoBuffer;
27 | import org.apache.mina.core.session.IoSession;
28 | import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
29 | import org.apache.mina.filter.codec.ProtocolEncoderOutput;
30 | import org.apache.mina.filter.codec.demux.MessageEncoder;
31 |
32 | /**
33 | * Internal class, do not use directly.
34 | *
35 | * A {@link MessageEncoder} that encodes {@link FtpReply}.
36 | *
37 | * @author Apache MINA Project
38 | */
39 | public class FtpResponseEncoder extends ProtocolEncoderAdapter {
40 | private static final CharsetEncoder ENCODER = Charset.forName("UTF-8")
41 | .newEncoder();
42 |
43 | public void encode(IoSession session, Object message,
44 | ProtocolEncoderOutput out) throws Exception {
45 | String value = message.toString();
46 |
47 | IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
48 |
49 | buf.putString(value, ENCODER);
50 |
51 | buf.flip();
52 | out.write(buf);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/listener/nio/FtpServerProtocolCodecFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | *
19 | */
20 | package org.apache.ftpserver.listener.nio;
21 |
22 | import java.nio.charset.Charset;
23 |
24 | import org.apache.mina.core.session.IoSession;
25 | import org.apache.mina.filter.codec.ProtocolCodecFactory;
26 | import org.apache.mina.filter.codec.ProtocolDecoder;
27 | import org.apache.mina.filter.codec.ProtocolEncoder;
28 | import org.apache.mina.filter.codec.textline.TextLineDecoder;
29 |
30 | /**
31 | * Internal class, do not use directly.
32 | *
33 | * Factory for creating decoders and encoders
34 | *
35 | * @author Apache MINA Project
36 | */
37 | public class FtpServerProtocolCodecFactory implements ProtocolCodecFactory {
38 | private final ProtocolDecoder decoder = new TextLineDecoder(Charset
39 | .forName("UTF-8"));
40 |
41 | private final ProtocolEncoder encoder = new FtpResponseEncoder();
42 |
43 | public ProtocolDecoder getDecoder(IoSession session) throws Exception {
44 | return decoder;
45 | }
46 |
47 | public ProtocolEncoder getEncoder(IoSession session) throws Exception {
48 | return encoder;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/org/apache/ftpserver/listener/nio/package.html:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 | Internal classes, do not use directly!
23 | NIO based listener
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/message/MessageResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.message; 21 | 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | /** 26 | * This is message resource interface. 27 | * 28 | * @author Apache MINA Project 29 | */ 30 | public interface MessageResource { 31 | 32 | /** 33 | * Get all the available languages. 34 | * @return A list of available languages 35 | */ 36 | ListMessage resource implementation
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/ssl/ClientAuth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2004 The Apache Software Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.apache.ftpserver.ssl; 18 | 19 | /** 20 | * Enumeration of possible levels of client authentication during an SSL 21 | * session. 22 | * 23 | * @author Apache MINA Project 24 | */ 25 | public enum ClientAuth { 26 | 27 | /** 28 | * Client authentication is required 29 | */ 30 | NEED, 31 | 32 | /** 33 | * Client authentication is requested but not required 34 | */ 35 | WANT, 36 | 37 | /** 38 | * Client authentication is not performed 39 | */ 40 | NONE 41 | } -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/ssl/impl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |SSL support implementation
24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/AnonymousAuthentication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager; 21 | 22 | import org.apache.ftpserver.ftplet.Authentication; 23 | import org.apache.ftpserver.usermanager.impl.UserMetadata; 24 | 25 | /** 26 | * Class representing an anonymous authentication attempt 27 | * 28 | * @author Apache MINA Project 29 | */ 30 | public class AnonymousAuthentication implements Authentication { 31 | 32 | private UserMetadata userMetadata; 33 | 34 | /** 35 | * Default constructor 36 | */ 37 | public AnonymousAuthentication() { 38 | // empty 39 | } 40 | 41 | /** 42 | * Constructor with an additional user metadata parameter 43 | * 44 | * @param userMetadata 45 | * User metadata 46 | */ 47 | public AnonymousAuthentication(UserMetadata userMetadata) { 48 | this.userMetadata = userMetadata; 49 | } 50 | 51 | /** 52 | * Retrive the user metadata 53 | * 54 | * @return The user metadata 55 | */ 56 | public UserMetadata getUserMetadata() { 57 | return userMetadata; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager; 21 | 22 | import org.apache.ftpserver.util.PasswordUtil; 23 | 24 | /** 25 | * Password encryptor that does no encryption, that is, keps the 26 | * password in clear text 27 | * 28 | * @author Apache MINA Project 29 | */ 30 | public class ClearTextPasswordEncryptor implements PasswordEncryptor { 31 | 32 | /** 33 | * Returns the clear text password 34 | */ 35 | public String encrypt(String password) { 36 | return password; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | public boolean matches(String passwordToCheck, String storedPassword) { 43 | if(storedPassword == null) { 44 | throw new NullPointerException("storedPassword can not be null"); 45 | } 46 | if(passwordToCheck == null) { 47 | throw new NullPointerException("passwordToCheck can not be null"); 48 | } 49 | 50 | return PasswordUtil.secureCompareFast(passwordToCheck, storedPassword); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager; 21 | 22 | import org.apache.ftpserver.util.EncryptUtils; 23 | import org.apache.ftpserver.util.PasswordUtil; 24 | 25 | /** 26 | * Password encryptor that hashes the password using MD5. Please note that this 27 | * form of encryption is sensitive to lookup attacks. 28 | * 29 | * @author Apache MINA Project 30 | */ 31 | public class Md5PasswordEncryptor implements PasswordEncryptor { 32 | 33 | /** 34 | * Hashes the password using MD5 35 | */ 36 | public String encrypt(String password) { 37 | return EncryptUtils.encryptMD5(password); 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | */ 43 | public boolean matches(String passwordToCheck, String storedPassword) { 44 | if (storedPassword == null) { 45 | throw new NullPointerException("storedPassword can not be null"); 46 | } 47 | if (passwordToCheck == null) { 48 | throw new NullPointerException("passwordToCheck can not be null"); 49 | } 50 | 51 | return PasswordUtil.secureCompareFast(encrypt(passwordToCheck).toLowerCase(), storedPassword.toLowerCase()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/PasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager; 21 | 22 | 23 | /** 24 | * Strategy used for encrypting and matching encrypted passwords. 25 | * The purpose is to make the password encryption possible to extend. 26 | * 27 | * @author Apache MINA Project 28 | */ 29 | public interface PasswordEncryptor { 30 | 31 | /** 32 | * Encrypts the password 33 | * @param password The clear text password 34 | * @return The encrypted password 35 | */ 36 | String encrypt(String password); 37 | 38 | /** 39 | * Matches an encrypted password with that stored 40 | * @param passwordToCheck The encrypted password to check 41 | * @param storedPassword The stored password 42 | * @return true if the password match 43 | */ 44 | boolean matches(String passwordToCheck, String storedPassword); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/UserManagerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager; 21 | 22 | import org.apache.ftpserver.ftplet.UserManager; 23 | 24 | /** 25 | * Interface for user manager factories 26 | * 27 | * @author Apache MINA Project 28 | */ 29 | public interface UserManagerFactory { 30 | 31 | /** 32 | * Create an {@link UserManager} instance based on the configuration on the factory 33 | * @return The {@link UserManager} 34 | */ 35 | UserManager createUserManager(); 36 | } -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/usermanager/impl/WriteRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.usermanager.impl; 21 | 22 | import org.apache.ftpserver.ftplet.AuthorizationRequest; 23 | 24 | /** 25 | * Internal class, do not use directly. 26 | * 27 | * Class representing a write request 28 | * 29 | * @author Apache MINA Project 30 | */ 31 | public class WriteRequest implements AuthorizationRequest { 32 | 33 | private String file; 34 | 35 | /** 36 | * Request write access to the user home directory (/) 37 | * 38 | */ 39 | public WriteRequest() { 40 | this("/"); 41 | } 42 | 43 | /** 44 | * Request write access to a file or directory relative to the user home 45 | * directory 46 | * 47 | * @param file 48 | */ 49 | public WriteRequest(final String file) { 50 | this.file = file; 51 | } 52 | 53 | /** 54 | * Get the file or directory to which write access is requested 55 | * 56 | * @return the file The file or directory 57 | */ 58 | public String getFile() { 59 | return file; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/util/ClassUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.util; 21 | 22 | /** 23 | * Internal class, do not use directly. 24 | * 25 | * @author Apache MINA Project 26 | * 27 | */ 28 | public class ClassUtils { 29 | 30 | /** 31 | * Checks if a class is a subclass of a class with the specified name. Used 32 | * as an instanceOf without having to load the class, useful when trying to 33 | * check for classes that might not be available in the runtime JRE. 34 | * 35 | * @param clazz 36 | * The class to check 37 | * @param className 38 | * The class name to look for in the super classes 39 | * @return true if the class extends a class by the specified name. 40 | */ 41 | public static boolean extendsClass(final Class> clazz, String className) { 42 | Class> superClass = clazz.getSuperclass(); 43 | 44 | while (superClass != null) { 45 | if (superClass.getName().equals(className)) { 46 | return true; 47 | } 48 | superClass = superClass.getSuperclass(); 49 | 50 | } 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/util/IllegalInetAddressException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.util; 21 | 22 | /** 23 | * Internal class, do not use directly. 24 | * 25 | * Thrown if the provided string representation does not match a valid IP 26 | * address 27 | * 28 | * @author Apache MINA Project 29 | */ 30 | public class IllegalInetAddressException extends IllegalArgumentException { 31 | 32 | private static final long serialVersionUID = -7771719692741419933L; 33 | 34 | public IllegalInetAddressException() { 35 | super(); 36 | } 37 | 38 | public IllegalInetAddressException(String s) { 39 | super(s); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/util/IllegalPortException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.util; 21 | 22 | /** 23 | * Internal class, do not use directly. 24 | * 25 | * Thrown if the provided string representation does not match a valid IP port 26 | * 27 | * @author Apache MINA Project 28 | */ 29 | public class IllegalPortException extends IllegalArgumentException { 30 | 31 | private static final long serialVersionUID = -7771719692741419931L; 32 | 33 | public IllegalPortException() { 34 | super(); 35 | } 36 | 37 | public IllegalPortException(String s) { 38 | super(s); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | 19 | http\://mina.apache.org/ftpserver/spring/v1=org.apache.ftpserver.config.spring.FtpServerNamespaceHandler -------------------------------------------------------------------------------- /core/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | http\://mina.apache.org/ftpserver/ftpserver-1.0.xsd=org/apache/ftpserver/config/spring/ftpserver-1.0.xsd -------------------------------------------------------------------------------- /core/src/main/resources/org/apache/ftpserver/message/FtpStatus_en.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | # English messages -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/VersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver; 21 | 22 | import junit.framework.TestCase; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class VersionTest extends TestCase { 30 | 31 | public void testGetVersion() { 32 | // testing only the start since the file from where 33 | // the value is read is replaced at build time by Maven 34 | // and therefore this value will change with the releases 35 | assertTrue(Version.getVersion().startsWith("1.")); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/CdCaseInsensitiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import org.apache.ftpserver.FtpServerFactory; 23 | import org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory; 24 | 25 | /** 26 | * 27 | * @author Apache MINA Project 28 | * 29 | */ 30 | public class CdCaseInsensitiveTest extends CdTest { 31 | @Override 32 | protected FtpServerFactory createServer() throws Exception { 33 | FtpServerFactory server = super.createServer(); 34 | 35 | NativeFileSystemFactory fs = (NativeFileSystemFactory) server 36 | .getFileSystem(); 37 | fs.setCaseInsensitive(true); 38 | 39 | return server; 40 | } 41 | 42 | public void testCWDCaseInsensitive() throws Exception { 43 | assertTrue(client.changeWorkingDirectory(TEST_DIR1.getName() 44 | .toUpperCase())); 45 | assertEquals("/dir1", client.printWorkingDirectory()); 46 | 47 | assertTrue(client.changeWorkingDirectory(TEST_DIR_IN_DIR1.getName() 48 | .toUpperCase())); 49 | assertEquals("/dir1/dir3", client.printWorkingDirectory()); 50 | 51 | assertTrue(client.changeWorkingDirectory("/DiR2")); 52 | assertEquals("/dir2", client.printWorkingDirectory()); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/ConcatedCommandsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import org.apache.commons.net.ftp.FTPReply; 23 | 24 | /** 25 | * Tests that commands sent simultaniously are handled correctly. 26 | * 27 | * @author Apache MINA Project 28 | * 29 | */ 30 | public class ConcatedCommandsTest extends ClientTestTemplate { 31 | 32 | public void testLogin() throws Exception { 33 | // send both commands, expect a 331 response 34 | assertEquals(331, client.sendCommand("USER admin\r\nPASS admin")); 35 | 36 | // make sure we wait for the 230 to come back 37 | client.completePendingCommand(); 38 | assertEquals(230, client.getReplyCode()); 39 | 40 | assertTrue(FTPReply.isPositiveCompletion(client.noop())); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/ConnectTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import org.apache.ftpserver.listener.nio.NioListener; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class ConnectTest extends ClientTestTemplate { 30 | 31 | @Override 32 | protected boolean isConnectClient() { 33 | return false; 34 | } 35 | 36 | @Override 37 | protected boolean isStartServer() { 38 | return false; 39 | } 40 | 41 | public void testPort() throws Exception { 42 | assertEquals(0, ((NioListener) server 43 | .getListener("default")).getPort()); 44 | 45 | server.start(); 46 | 47 | assertTrue(((NioListener) server 48 | .getListener("default")).getPort() > 0); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/DefaultMaxLoginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import java.net.SocketException; 23 | 24 | import org.apache.commons.net.ftp.FTPConnectionClosedException; 25 | 26 | /** 27 | * 28 | * @author Apache MINA Project 29 | * 30 | */ 31 | public class DefaultMaxLoginTest extends ClientTestTemplate { 32 | private static final String UNKNOWN_USERNAME = "foo"; 33 | 34 | private static final String UNKNOWN_PASSWORD = "bar"; 35 | 36 | public void testLogin() throws Exception { 37 | assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD)); 38 | assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD)); 39 | assertFalse(client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD)); 40 | 41 | try { 42 | client.login(UNKNOWN_USERNAME, UNKNOWN_PASSWORD); 43 | 44 | fail("Must be disconnected"); 45 | } catch (FTPConnectionClosedException e) { 46 | // OK 47 | } catch (SocketException e) { 48 | // OK 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class FeatTest extends ClientTestTemplate { 28 | 29 | public void test() throws Exception { 30 | client.login(ADMIN_USERNAME, ADMIN_PASSWORD); 31 | 32 | client.sendCommand("FEAT"); 33 | String[] featReplies = client.getReplyString().split("\r\n"); 34 | 35 | for (int i = 0; i < featReplies.length; i++) { 36 | if (i == 0) { 37 | // first must be 211-Extensions supported 38 | assertEquals("211-Extensions supported", featReplies[i]); 39 | } else if (i + 1 == featReplies.length) { 40 | // last must be 211 End 41 | assertEquals("211 End", featReplies[i]); 42 | } else { 43 | // must start with a single space 44 | assertEquals(' ', featReplies[i].charAt(0)); 45 | assertTrue(featReplies[i].charAt(1) != ' '); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/ListPassiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class ListPassiveTest extends ListTest { 28 | /* 29 | * (non-Javadoc) 30 | * 31 | * @see org.apache.ftpserver.clienttests.ClientTestTemplate#setUp() 32 | */ 33 | @Override 34 | protected void setUp() throws Exception { 35 | super.setUp(); 36 | 37 | client.setRemoteVerificationEnabled(false); 38 | client.enterLocalPassiveMode(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/LoginNoAnonTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import org.apache.ftpserver.ConnectionConfigFactory; 23 | import org.apache.ftpserver.FtpServerFactory; 24 | 25 | /** 26 | * 27 | * @author Apache MINA Project 28 | * 29 | */ 30 | public class LoginNoAnonTest extends ClientTestTemplate { 31 | 32 | /* 33 | * (non-Javadoc) 34 | * 35 | * @see org.apache.ftpserver.clienttests.ClientTestTemplate#createConfig() 36 | */ 37 | @Override 38 | protected FtpServerFactory createServer() throws Exception { 39 | FtpServerFactory server = super.createServer(); 40 | 41 | ConnectionConfigFactory ccFactory = new ConnectionConfigFactory(); 42 | 43 | ccFactory.setAnonymousLoginEnabled(false); 44 | 45 | server.setConnectionConfig(ccFactory.createConnectionConfig()); 46 | 47 | return server; 48 | } 49 | 50 | public void testLoginWithAnon() throws Exception { 51 | assertFalse(client.login(ANONYMOUS_USERNAME, ANONYMOUS_PASSWORD)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/PortTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import java.net.InetAddress; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class PortTest extends ClientTestTemplate { 30 | 31 | @Override 32 | protected void setUp() throws Exception { 33 | super.setUp(); 34 | 35 | client.login(ADMIN_USERNAME, ADMIN_PASSWORD); 36 | } 37 | 38 | public void testInvalidIpAndPort() throws Exception { 39 | assertEquals(501, client.port(InetAddress.getByName("0.0.0.0"), 0)); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/RetrievePassiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class RetrievePassiveTest extends RetrieveTest { 28 | 29 | /* 30 | * (non-Javadoc) 31 | * 32 | * @see org.apache.ftpserver.clienttests.ClientTestTemplate#setUp() 33 | */ 34 | @Override 35 | protected void setUp() throws Exception { 36 | super.setUp(); 37 | 38 | client.setRemoteVerificationEnabled(false); 39 | client.enterLocalPassiveMode(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/StorePassiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class StorePassiveTest extends StoreTest { 28 | /* 29 | * (non-Javadoc) 30 | * 31 | * @see org.apache.ftpserver.clienttests.ClientTestTemplate#setUp() 32 | */ 33 | @Override 34 | protected void setUp() throws Exception { 35 | super.setUp(); 36 | 37 | client.setRemoteVerificationEnabled(false); 38 | client.enterLocalPassiveMode(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/clienttests/SystTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.clienttests; 21 | 22 | import org.apache.commons.net.ftp.FTPReply; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class SystTest extends ClientTestTemplate { 30 | 31 | /* 32 | * (non-Javadoc) 33 | * 34 | * @see org.apache.ftpserver.clienttests.ClientTestTemplate#setUp() 35 | */ 36 | @Override 37 | protected void setUp() throws Exception { 38 | super.setUp(); 39 | 40 | client.login(ADMIN_USERNAME, ADMIN_PASSWORD); 41 | } 42 | 43 | public void testSyst() throws Exception { 44 | assertTrue(FTPReply.isPositiveCompletion(client.syst())); 45 | // hardcoded to Unix as that's the type of list etc we use 46 | assertEquals("215 UNIX Type: Apache FtpServer", client.getReplyString() 47 | .trim()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/config/spring/PropertyPlaceholderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring; 21 | 22 | import junit.framework.TestCase; 23 | 24 | import org.apache.ftpserver.impl.DefaultFtpServer; 25 | import org.springframework.context.support.FileSystemXmlApplicationContext; 26 | 27 | /** 28 | * 29 | * @author Apache MINA Project 30 | * 31 | */ 32 | public class PropertyPlaceholderTest extends TestCase { 33 | 34 | public void test() throws Throwable { 35 | System.setProperty("port2", "3333"); 36 | 37 | FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext( 38 | "src/test/resources/spring-config/config-property-placeholder.xml"); 39 | 40 | DefaultFtpServer server = (DefaultFtpServer) ctx.getBean("server"); 41 | 42 | assertEquals(2222, server.getListener("listener0").getPort()); 43 | assertEquals(3333, server.getListener("listener1").getPort()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/config/spring/TestFtplet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.config.spring; 21 | 22 | import org.apache.ftpserver.ftplet.DefaultFtplet; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class TestFtplet extends DefaultFtplet { 30 | 31 | private int foo; 32 | 33 | public int getFoo() { 34 | return foo; 35 | } 36 | 37 | public void setFoo(int foo) { 38 | this.foo = foo; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ftpletcontainer/DefaultFtpLetContainerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.ftpserver.ftpletcontainer; 21 | 22 | import java.util.Map; 23 | 24 | import org.apache.ftpserver.ftplet.Ftplet; 25 | import org.apache.ftpserver.ftpletcontainer.impl.DefaultFtpletContainer; 26 | 27 | /** 28 | * 29 | * @author Apache MINA Project 30 | * 31 | */ 32 | public class DefaultFtpLetContainerTest extends FtpLetContainerTestTemplate { 33 | 34 | @Override 35 | protected FtpletContainer createFtpletContainer(Mapnull
, if the file information is not available.
38 | */
39 | public FtpFile getFile();
40 | }
41 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileSystemFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * Factory for file system implementations - it returns the file system view for user.
24 | *
25 | * @author Apache MINA Project
26 | */
27 | public interface FileSystemFactory {
28 |
29 | /**
30 | * Create user specific file system view.
31 | * @param user The user for which the file system should be created
32 | * @return The current {@link FileSystemView} for the provided user
33 | * @throws FtpException
34 | */
35 | FileSystemView createFileSystemView(User user) throws FtpException;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FtpRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * One FtpRequest made by the client.
24 | *
25 | * @author Apache MINA Project
26 | */
27 | public interface FtpRequest {
28 |
29 | /**
30 | * Get the client request string.
31 | * @return The full request line, e.g. "MKDIR newdir"
32 | */
33 | String getRequestLine();
34 |
35 | /**
36 | * Returns the ftp request command.
37 | * @return The command part of the request line, e.g. "MKDIR"
38 | */
39 | String getCommand();
40 |
41 | /**
42 | * Get the ftp request argument.
43 | * @return The argument part of the request line, e.g. "newdir"
44 | */
45 | String getArgument();
46 |
47 | /**
48 | * Check if request contains an argument
49 | *
50 | * @return true if an argument is available
51 | */
52 | boolean hasArgument();
53 |
54 | /**
55 | * Returns the timestamp (milliseconds since the epoch time) when this
56 | * request was received.
57 | *
58 | * @return the timestamp (milliseconds since the epoch time) when this
59 | * request was received.
60 | */
61 | long getReceivedTime();
62 | }
63 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FtpletContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * A ftplet configuration object used by a ftplet container used to pass
24 | * information to a ftplet during initialization. The configuration information
25 | * contains initialization parameters.
26 | *
27 | * @author Apache MINA Project
28 | */
29 | public interface FtpletContext {
30 |
31 | /**
32 | * Get the user manager.
33 | * @return The {@link UserManager}
34 | */
35 | UserManager getUserManager();
36 |
37 | /**
38 | * Get file system manager
39 | * @return The {@link FileSystemFactory}
40 | */
41 | FileSystemFactory getFileSystemManager();
42 |
43 | /**
44 | * Get ftp statistics.
45 | * @return The {@link FtpStatistics}
46 | */
47 | FtpStatistics getFtpStatistics();
48 |
49 | /**
50 | * Get Ftplet.
51 | * @param name The name identifying the {@link Ftplet}
52 | * @return The {@link Ftplet} registred with the provided name, or null if none exists
53 | */
54 | Ftplet getFtplet(String name);
55 | }
56 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FtpletResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * This class encapsulates the return values of the ftplet methods.
24 | *
25 | * DEFAULT < NO_FTPLET < SKIP < DISCONNECT
26 | *
27 | * @author Apache MINA Project
28 | */
29 | public enum FtpletResult {
30 |
31 | /**
32 | * This return value indicates that the next ftplet method will be called.
33 | * If no other ftplet is available, the ftpserver will process the request.
34 | */
35 | DEFAULT,
36 |
37 | /**
38 | * This return value indicates that the other ftplet methods will not be
39 | * called but the ftpserver will continue processing this request.
40 | */
41 | NO_FTPLET,
42 |
43 | /**
44 | * It indicates that the ftpserver will skip everything. No further
45 | * processing (both ftplet and server) will be done for this request.
46 | */
47 | SKIP,
48 |
49 | /**
50 | * It indicates that the server will skip and disconnect the client. No
51 | * other request from the same client will be served.
52 | */
53 | DISCONNECT;
54 | }
55 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/RenameFtpReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * A more specific type of reply that is sent when a file is attempted to
24 | * rename. This reply is sent by the RNTO command.
25 | *
26 | * @author Apache MINA Project
27 | *
28 | */
29 |
30 | public interface RenameFtpReply extends FtpReply {
31 |
32 | /**
33 | * Returns the file before the rename.
34 | *
35 | * @return the file before the rename. May return null
, if
36 | * the file information is not available.
37 | */
38 | public FtpFile getFrom();
39 |
40 | /**
41 | * Returns the file after the rename.
42 | *
43 | * @return the file after the rename. May return null
, if
44 | * the file information is not available.
45 | */
46 | public FtpFile getTo();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Structure.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | /**
23 | * Type safe enum for describing the structure
24 | *
25 | * @author Apache MINA Project
26 | */
27 | public enum Structure {
28 |
29 | /**
30 | * File structure
31 | */
32 | FILE;
33 |
34 | /**
35 | * Parses the argument value from the STRU command into the type safe class
36 | *
37 | * @param argument
38 | * The argument value from the STRU command. Not case sensitive
39 | * @return The appropriate structure
40 | * @throws IllegalArgumentException
41 | * If the structure is unknown
42 | */
43 |
44 | public static Structure parseArgument(char argument) {
45 | switch (argument) {
46 | case 'F':
47 | case 'f':
48 | return FILE;
49 | default:
50 | throw new IllegalArgumentException("Unknown structure: " + argument);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/DataTypeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | import junit.framework.TestCase;
23 |
24 | /**
25 | *
26 | * @author Apache MINA Project
27 | */
28 | public class DataTypeTest extends TestCase {
29 |
30 | public void testParseA() {
31 | assertSame(DataType.ASCII, DataType.parseArgument('A'));
32 | assertSame(DataType.ASCII, DataType.parseArgument('a'));
33 | }
34 |
35 | public void testParseI() {
36 | assertSame(DataType.BINARY, DataType.parseArgument('I'));
37 | assertSame(DataType.BINARY, DataType.parseArgument('i'));
38 | }
39 |
40 | public void testParseUnknown() {
41 | try {
42 | DataType.parseArgument('x');
43 | fail("Exception must be thrown");
44 | } catch (IllegalArgumentException e) {
45 | // ignore
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/ExampleFtplet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | import java.io.IOException;
23 |
24 | /**
25 | *
26 | * @author Apache MINA Project
27 | */
28 | public class ExampleFtplet extends DefaultFtplet {
29 |
30 | @Override
31 | public FtpletResult onMkdirEnd(FtpSession session, FtpRequest request)
32 | throws FtpException, IOException {
33 | session.write(new DefaultFtpReply(550, "Error!"));
34 | return FtpletResult.SKIP;
35 | }
36 |
37 | @Override
38 | public FtpletResult onMkdirStart(FtpSession session, FtpRequest request)
39 | throws FtpException, IOException {
40 | if (session.isSecure() && session.getDataConnection().isSecure()) {
41 | // all is good
42 | }
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/ftplet-api/src/test/java/org/apache/ftpserver/ftplet/StructureTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.ftpserver.ftplet;
21 |
22 | import junit.framework.TestCase;
23 |
24 | /**
25 | *
26 | * @author Apache MINA Project
27 | */
28 | public class StructureTest extends TestCase {
29 | public void testParseF() {
30 | assertSame(Structure.FILE, Structure.parseArgument('F'));
31 | assertSame(Structure.FILE, Structure.parseArgument('f'));
32 | }
33 |
34 | public void testParseUnknown() {
35 | try {
36 | Structure.parseArgument('x');
37 | fail("Exception must be thrown");
38 | } catch (IllegalArgumentException e) {
39 | // ignore
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------