├── .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 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /checkstyle.properties: -------------------------------------------------------------------------------- 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 | checkstyle.maxlinelen = 160 17 | checkstyle.lcurly.type = nl 18 | checkstyle.lcurly.method = nl 19 | checkstyle.lcurly.other = nl 20 | checkstyle.rcurly = alone 21 | checkstyle.paren.pad = ignore 22 | checkstyle.ignore.whitespace.cast = true 23 | checkstyle.javadoc.scope = package 24 | checkstyle.require.packagehtml = true 25 | -------------------------------------------------------------------------------- /core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java: -------------------------------------------------------------------------------- 1 | package org.apache.ftpserver.examples; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.io.File; 23 | 24 | import org.apache.ftpserver.ftplet.User; 25 | import org.apache.ftpserver.ftplet.UserManager; 26 | import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory; 27 | import org.apache.ftpserver.usermanager.SaltedPasswordEncryptor; 28 | import org.apache.ftpserver.usermanager.UserFactory; 29 | 30 | /** 31 | * @author Apache MINA Project* 32 | */ 33 | public class ManagingUsers { 34 | 35 | public static void main(String[] args) throws Exception { 36 | PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory(); 37 | userManagerFactory.setFile(new File("myusers.properties")); 38 | userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor()); 39 | UserManager um = userManagerFactory.createUserManager(); 40 | 41 | UserFactory userFact = new UserFactory(); 42 | userFact.setName("myNewUser"); 43 | userFact.setPassword("secret"); 44 | userFact.setHomeDirectory("ftproot"); 45 | User user = userFact.createUser(); 46 | um.save(user); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/examples/resources/ftpserver.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/core/src/examples/resources/ftpserver.jks -------------------------------------------------------------------------------- /core/src/examples/resources/spring-config/config-ftplets.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /core/src/examples/resources/spring-config/config-minimal.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 26 | -------------------------------------------------------------------------------- /core/src/examples/resources/spring-config/config-typical.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/FtpServer.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 org.apache.ftpserver.ftplet.FtpException; 23 | 24 | 25 | /** 26 | * This is the starting point of all the servers. It invokes a new listener 27 | * thread. 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 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |

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 | Map getFtplets(); 52 | } -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/ftpletcontainer/impl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |

Ftplet 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 of LocalizedFtpReply. 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 | List getAvailableLanguages(); 37 | 38 | /** 39 | * Get the message for the corresponding code and sub id. If not found it 40 | * will return null. 41 | * @param code The reply code 42 | * @param subId The sub ID 43 | * @param language The language 44 | * @return The message matching the provided inputs, or null if not found 45 | */ 46 | String getMessage(int code, String subId, String language); 47 | 48 | /** 49 | * Get all the messages. 50 | * @param language The language 51 | * @return All messages for the provided language 52 | */ 53 | Map getMessages(String language); 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/ftpserver/message/impl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | Internal classes, do not use directly! 23 |

Message 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(Map ftplets) { 36 | return new DefaultFtpletContainer(ftplets); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetThrowFtpExceptionTest.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.io.IOException; 23 | 24 | import org.apache.ftpserver.ftplet.FtpException; 25 | 26 | /** 27 | * 28 | * @author Apache MINA Project 29 | * 30 | */ 31 | public class FtpLetThrowFtpExceptionTest extends FtpLetReturnDisconnectTest { 32 | 33 | @Override 34 | protected void throwException() throws FtpException, IOException { 35 | throw new FtpException(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetThrowIOExceptionTest.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.io.IOException; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class FtpLetThrowIOExceptionTest extends FtpLetThrowFtpExceptionTest { 30 | @Override 31 | protected void throwException() throws IOException { 32 | throw new IOException(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ftpletcontainer/FtpLetThrowRuntimeExceptionTest.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.io.IOException; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class FtpLetThrowRuntimeExceptionTest extends 30 | FtpLetThrowFtpExceptionTest { 31 | @Override 32 | protected void throwException() throws IOException { 33 | throw new IOException(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/impl/FtpStatisticsImplTest.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 | 23 | /** 24 | * 25 | * @author Apache MINA Project 26 | * 27 | */ 28 | public class FtpStatisticsImplTest extends ServerFtpStatisticsTestTemplate { 29 | 30 | @Override 31 | protected DefaultFtpStatistics createStatistics() { 32 | return new DefaultFtpStatistics(); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/ImplicitSecurityTestTemplate.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.ssl; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public abstract class ImplicitSecurityTestTemplate extends 28 | ExplicitSecurityTestTemplate { 29 | 30 | @Override 31 | protected boolean useImplicit() { 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitSSLTest.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.ssl; 21 | 22 | import org.junit.Ignore; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | @Ignore( "SSL V3 not supported anymore" ) 30 | public class MinaExplicitSSLTest extends ExplicitSecurityTestTemplate { 31 | 32 | @Override 33 | protected String getAuthValue() { 34 | return "SSL"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/MinaExplicitTLSTest.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.ssl; 21 | 22 | import org.junit.Ignore; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | @Ignore( "SSL V3 not supported anymore" ) 30 | public class MinaExplicitTLSTest extends ExplicitSecurityTestTemplate { 31 | 32 | @Override 33 | protected String getAuthValue() { 34 | return "TLSv1.2"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitClientAuthTest.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.ssl; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class MinaImplicitClientAuthTest extends MinaClientAuthTest { 28 | 29 | @Override 30 | protected boolean useImplicit() { 31 | return true; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitSSLTest.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.ssl; 21 | 22 | import org.junit.Ignore; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | @Ignore( "SSL V3 not supported anymore" ) 30 | 31 | public class MinaImplicitSSLTest extends ImplicitSecurityTestTemplate { 32 | 33 | @Override 34 | protected String getAuthValue() { 35 | return "SSL"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/ssl/MinaImplicitTLSTest.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.ssl; 21 | 22 | /** 23 | * 24 | * @author Apache MINA Project 25 | * 26 | */ 27 | public class MinaImplicitTLSTest extends ImplicitSecurityTestTemplate { 28 | 29 | @Override 30 | protected String getAuthValue() { 31 | return "TLSv1.2"; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthenticationTest.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 junit.framework.TestCase; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class UsernamePasswordAuthenticationTest extends TestCase { 30 | 31 | public void testConstructor() { 32 | UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication( 33 | "user", "pass"); 34 | 35 | assertEquals("user", auth.getUsername()); 36 | assertEquals("pass", auth.getPassword()); 37 | } 38 | 39 | public void testConstructorNullUsername() { 40 | UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication( 41 | null, "pass"); 42 | 43 | assertNull(auth.getUsername()); 44 | assertEquals("pass", auth.getPassword()); 45 | } 46 | 47 | public void testConstructorNullPassword() { 48 | UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication( 49 | "user", null); 50 | 51 | assertEquals("user", auth.getUsername()); 52 | assertNull(auth.getPassword()); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/usermanager/impl/ClearTextDbUserManagerTest.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 java.io.File; 23 | 24 | import org.apache.ftpserver.ftplet.FtpException; 25 | import org.apache.ftpserver.test.TestUtil; 26 | import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor; 27 | import org.apache.ftpserver.usermanager.DbUserManagerFactory; 28 | import org.apache.ftpserver.usermanager.UserManagerFactory; 29 | 30 | /** 31 | * 32 | * @author Apache MINA Project 33 | * 34 | */ 35 | public class ClearTextDbUserManagerTest extends DbUserManagerTest { 36 | 37 | @Override 38 | protected File getInitSqlScript() { 39 | return new File(TestUtil.getBaseDir(), 40 | "src/test/resources/dbusermanagertest-cleartext-hsql.sql"); 41 | } 42 | 43 | 44 | @Override 45 | protected UserManagerFactory createUserManagerFactory() throws FtpException { 46 | DbUserManagerFactory manager = (DbUserManagerFactory) super.createUserManagerFactory(); 47 | manager.setPasswordEncryptor(new ClearTextPasswordEncryptor()); 48 | return manager; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/usermanager/impl/Md5PasswordEncryptorTest.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.usermanager.Md5PasswordEncryptor; 23 | import org.apache.ftpserver.usermanager.PasswordEncryptor; 24 | 25 | 26 | /** 27 | * 28 | * @author Apache MINA Project 29 | * 30 | */ 31 | public class Md5PasswordEncryptorTest extends ClearTextPasswordEncryptorTest { 32 | 33 | @Override 34 | protected PasswordEncryptor createPasswordEncryptor() { 35 | return new Md5PasswordEncryptor(); 36 | } 37 | 38 | @Override 39 | public void testMatches() { 40 | PasswordEncryptor encryptor = createPasswordEncryptor(); 41 | 42 | assertTrue(encryptor.matches("foo", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8")); 43 | 44 | // check lower case 45 | assertTrue(encryptor.matches("foo", "acbd18DB4CC2F85CEDEF654FCCC4A4D8")); 46 | 47 | assertFalse(encryptor.matches("foo", "bar")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/usermanager/impl/SaltedPasswordEncryptorTest.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.usermanager.PasswordEncryptor; 23 | import org.apache.ftpserver.usermanager.SaltedPasswordEncryptor; 24 | 25 | 26 | /** 27 | * 28 | * @author Apache MINA Project 29 | * 30 | */ 31 | public class SaltedPasswordEncryptorTest extends ClearTextPasswordEncryptorTest { 32 | 33 | @Override 34 | protected PasswordEncryptor createPasswordEncryptor() { 35 | return new SaltedPasswordEncryptor(); 36 | } 37 | 38 | @Override 39 | public void testMatches() { 40 | PasswordEncryptor encryptor = createPasswordEncryptor(); 41 | 42 | assertTrue(encryptor.matches("foo", "71288966:F7B097C7BB2D02B8C2ACCE8A17284715")); 43 | 44 | // check lower case 45 | assertTrue(encryptor.matches("foo", "71288966:f7b097C7BB2D02B8C2ACCE8A17284715")); 46 | 47 | assertFalse(encryptor.matches("foo", "bar:bar")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/usermanager/impl/WritePermissionTest.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 junit.framework.TestCase; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class WritePermissionTest extends TestCase { 30 | 31 | public void testRootDir() throws Exception { 32 | WritePermission permission = new WritePermission("/"); 33 | 34 | assertNotNull(permission.authorize(new WriteRequest("/"))); 35 | } 36 | 37 | public void testDirs() throws Exception { 38 | WritePermission permission = new WritePermission("/bar"); 39 | 40 | assertNull(permission.authorize(new WriteRequest("/foo"))); 41 | assertNull(permission.authorize(new WriteRequest("/foo/bar"))); 42 | assertNotNull(permission.authorize(new WriteRequest("/bar"))); 43 | assertNotNull(permission.authorize(new WriteRequest("/bar/foo"))); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/ftpserver/util/EncryptUtilsTest.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 | import junit.framework.TestCase; 23 | 24 | /** 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | public class EncryptUtilsTest extends TestCase { 30 | 31 | public void testEncryptMd5() { 32 | assertEquals("21232F297A57A5A743894A0E4A801FC3", EncryptUtils 33 | .encryptMD5("admin")); 34 | } 35 | 36 | public void testEncryptSha() { 37 | assertEquals("D033E22AE348AEB5660FC2140AEC35850C4DA997", EncryptUtils 38 | .encryptSHA("admin")); 39 | } 40 | } -------------------------------------------------------------------------------- /core/src/test/resources/dbusermanagertest-cleartext-hsql.sql: -------------------------------------------------------------------------------- 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 | CREATE TABLE FTP_USER ( 19 | userid VARCHAR(64) NOT NULL PRIMARY KEY, 20 | userpassword VARCHAR(64), 21 | homedirectory VARCHAR(128) NOT NULL, 22 | enableflag BOOLEAN DEFAULT TRUE, 23 | writepermission BOOLEAN DEFAULT FALSE, 24 | idletime INT DEFAULT 0, 25 | uploadrate INT DEFAULT 0, 26 | downloadrate INT DEFAULT 0, 27 | maxloginnumber INT DEFAULT 0, 28 | maxloginperip INT DEFAULT 0 29 | ); 30 | 31 | -- password="pw1" 32 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user1', 'pw1', 'home'); 33 | 34 | -- password="pw2" 35 | INSERT INTO FTP_USER VALUES ('user2', 'pw2', 'home', false, true, 2, 5, 1, 3, 4); 36 | 37 | -- password="" 38 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user3', '', 'home'); 39 | 40 | -- password="admin" 41 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('admin', 'admin', 'home'); 42 | 43 | -------------------------------------------------------------------------------- /core/src/test/resources/dbusermanagertest-hsql.sql: -------------------------------------------------------------------------------- 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 | CREATE TABLE FTP_USER ( 19 | userid VARCHAR(64) NOT NULL PRIMARY KEY, 20 | userpassword VARCHAR(64), 21 | homedirectory VARCHAR(128) NOT NULL, 22 | enableflag BOOLEAN DEFAULT TRUE, 23 | writepermission BOOLEAN DEFAULT FALSE, 24 | idletime INT DEFAULT 0, 25 | uploadrate INT DEFAULT 0, 26 | downloadrate INT DEFAULT 0, 27 | maxloginnumber INT DEFAULT 0, 28 | maxloginperip INT DEFAULT 0 29 | ); 30 | 31 | -- password="pw1" 32 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user1', '6E6FDF956D04289354DCF1619E28FE77', 'home'); 33 | 34 | -- password="pw2" 35 | INSERT INTO FTP_USER VALUES ('user2', '6D5779B9B85BD4F11E44C9772E0DE602', 'home', false, true, 2, 5, 1, 3, 4); 36 | 37 | -- password="" 38 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user3', 'D41D8CD98F00B204E9800998ECF8427E', 'home'); 39 | 40 | -- password="admin" 41 | INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('admin', '21232F297A57A5A743894A0E4A801FC3', 'home'); 42 | 43 | -------------------------------------------------------------------------------- /core/src/test/resources/ftpclient.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/core/src/test/resources/ftpclient.jks -------------------------------------------------------------------------------- /core/src/test/resources/ftpserver.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/core/src/test/resources/ftpserver.jks -------------------------------------------------------------------------------- /core/src/test/resources/keymanager-test.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/core/src/test/resources/keymanager-test.jks -------------------------------------------------------------------------------- /core/src/test/resources/log4j.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 | log4j.rootLogger=ERROR, C 19 | log4j.appender.C=org.apache.log4j.ConsoleAppender 20 | log4j.appender.C.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.C.layout.ConversionPattern=[%X{userName}] [%X{remoteIp}] [%X{session}] %m%n 22 | 23 | -------------------------------------------------------------------------------- /core/src/test/resources/org/apache/ftpserver/ftpserver.properties: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # 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, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | ############################################################################# 17 | # This is a placeholder for unit testing, 18 | # will in most cases be overriden by the real file provided by the Maven build 19 | ftpserver.version=1.2.3 20 | -------------------------------------------------------------------------------- /core/src/test/resources/spring-config/placeholder.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 | port1=2222 -------------------------------------------------------------------------------- /distribution/LICENSE.slf4j.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2007 QOS.ch 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, and/or sell copies of the Software, and to permit persons 9 | to whom the Software is furnished to do so, provided that the above 10 | copyright notice(s) and this permission notice appear in all copies of 11 | the Software and that both the above copyright notice(s) and this 12 | permission notice appear in supporting documentation. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 17 | OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 19 | SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 20 | RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 21 | CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 22 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | Except as contained in this notice, the name of a copyright holder 25 | shall not be used in advertising or otherwise to promote the sale, use 26 | or other dealings in this Software without prior written authorization 27 | of the copyright holder. 28 | 29 | -------------------------------------------------------------------------------- /distribution/bin/appendcp.bat: -------------------------------------------------------------------------------- 1 | REM Licensed to the Apache Software Foundation (ASF) under one 2 | REM or more contributor license agreements. See the NOTICE file 3 | REM distributed with this work for additional information 4 | REM regarding copyright ownership. The ASF licenses this file 5 | REM to you under the Apache License, Version 2.0 (the 6 | REM "License"); you may not use this file except in compliance 7 | REM with the License. You may obtain a copy of the License at 8 | REM 9 | REM http://www.apache.org/licenses/LICENSE-2.0 10 | REM 11 | REM Unless required by applicable law or agreed to in writing, 12 | REM software distributed under the License is distributed on an 13 | REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | REM KIND, either express or implied. See the License for the 15 | REM specific language governing permissions and limitations 16 | REM under the License. 17 | 18 | If %OS%'==Windows_NT' Set NTSwitch=/F "Tokens=*" 19 | If %OS%'==WINNT' Set NTSwitch=/F "Tokens=*" 20 | For %NTSwitch% %%V In (%1) Do set FTPD_CLASSPATH=%FTPD_CLASSPATH%;%%V 21 | 22 | 23 | -------------------------------------------------------------------------------- /distribution/bin/ftpd.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/distribution/bin/ftpd.exe -------------------------------------------------------------------------------- /distribution/bin/ftpdw.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/distribution/bin/ftpdw.exe -------------------------------------------------------------------------------- /distribution/common/classes/log4j.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 | log4j.rootLogger=INFO, R 19 | log4j.appender.R=org.apache.log4j.RollingFileAppender 20 | log4j.appender.R.File=./res/log/ftpd.log 21 | log4j.appender.R.MaxFileSize=10MB 22 | log4j.appender.R.MaxBackupIndex=10 23 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 24 | log4j.appender.R.layout.ConversionPattern=[%5p] %d [%X{userName}] [%X{remoteIp}] %m%n 25 | 26 | -------------------------------------------------------------------------------- /distribution/common/lib/.cvsignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | -------------------------------------------------------------------------------- /distribution/common/lib/README.txt: -------------------------------------------------------------------------------- 1 | Binary Distribution 2 | -------------------- 3 | You can keep your other jar files here. All the jar files in this directory 4 | will be available to the FTP server. 5 | -------------------------------------------------------------------------------- /distribution/res/conf/README.txt: -------------------------------------------------------------------------------- 1 | You can find two sample configuration files here. One is a typical 2 | configuration file containing the common settings. The other is a full-fledged 3 | configuration file showing all available parameters. -------------------------------------------------------------------------------- /distribution/res/conf/ftpd-typical.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /distribution/res/conf/users.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 | # Password is "admin" 19 | ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3 20 | ftpserver.user.admin.homedirectory=./res/home 21 | ftpserver.user.admin.enableflag=true 22 | ftpserver.user.admin.writepermission=true 23 | ftpserver.user.admin.maxloginnumber=0 24 | ftpserver.user.admin.maxloginperip=0 25 | ftpserver.user.admin.idletime=0 26 | ftpserver.user.admin.uploadrate=0 27 | ftpserver.user.admin.downloadrate=0 28 | 29 | ftpserver.user.anonymous.userpassword= 30 | ftpserver.user.anonymous.homedirectory=./res/home 31 | ftpserver.user.anonymous.enableflag=true 32 | ftpserver.user.anonymous.writepermission=false 33 | ftpserver.user.anonymous.maxloginnumber=20 34 | ftpserver.user.anonymous.maxloginperip=2 35 | ftpserver.user.anonymous.idletime=300 36 | ftpserver.user.anonymous.uploadrate=4800 37 | ftpserver.user.anonymous.downloadrate=4800 38 | -------------------------------------------------------------------------------- /distribution/res/ftp-db.sql: -------------------------------------------------------------------------------- 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 | CREATE TABLE FTP_USER ( 19 | userid VARCHAR(64) NOT NULL PRIMARY KEY, 20 | userpassword VARCHAR(64), 21 | homedirectory VARCHAR(128) NOT NULL, 22 | enableflag BOOLEAN DEFAULT TRUE, 23 | writepermission BOOLEAN DEFAULT FALSE, 24 | idletime INT DEFAULT 0, 25 | uploadrate INT DEFAULT 0, 26 | downloadrate INT DEFAULT 0, 27 | maxloginnumber INT DEFAULT 0, 28 | maxloginperip INT DEFAULT 0 29 | ); 30 | -------------------------------------------------------------------------------- /distribution/res/ftpserver.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/distribution/res/ftpserver.jks -------------------------------------------------------------------------------- /distribution/res/home/README.txt: -------------------------------------------------------------------------------- 1 | Default user root directory. -------------------------------------------------------------------------------- /distribution/res/log/README.txt: -------------------------------------------------------------------------------- 1 | All the log files are stored here. -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/java/org/apache/ftpserver/example/springwar/package-info.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 | * @author Apache MINA Project 21 | */ 22 | package org.apache.ftpserver.example.springwar; 23 | -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/resources/ftpserver.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/mina-ftpserver/3865deb64cf487baa81c86d3a380d3a5bd7f9a30/examples/ftpserver-example-spring-war/src/main/resources/ftpserver.jks -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/resources/log4j.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 | log4j.rootLogger=DEBUG, C 19 | log4j.appender.C=org.apache.log4j.ConsoleAppender 20 | log4j.appender.C.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.C.layout.ConversionPattern=[%5p] %d [%X{userName}] [%X{remoteIp}] %m%n 22 | 23 | -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/resources/users.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 | # Password is "admin" 19 | ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3 20 | ftpserver.user.admin.homedirectory=/tmp 21 | ftpserver.user.admin.enableflag=true 22 | ftpserver.user.admin.writepermission=true 23 | ftpserver.user.admin.maxloginnumber=0 24 | ftpserver.user.admin.maxloginperip=0 25 | ftpserver.user.admin.idletime=0 26 | ftpserver.user.admin.uploadrate=0 27 | ftpserver.user.admin.downloadrate=0 28 | 29 | ftpserver.user.anonymous.userpassword= 30 | ftpserver.user.anonymous.homedirectory=/tmp 31 | ftpserver.user.anonymous.enableflag=true 32 | ftpserver.user.anonymous.writepermission=false 33 | ftpserver.user.anonymous.maxloginnumber=20 34 | ftpserver.user.anonymous.maxloginperip=2 35 | ftpserver.user.anonymous.idletime=300 36 | ftpserver.user.anonymous.uploadrate=4800 37 | ftpserver.user.anonymous.downloadrate=4800 38 | -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/ftpserver-example-spring-war/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | ftpserver-example-spring-war 18 | 19 | index.jsp 20 | 21 | 22 | contextConfigLocation 23 | /WEB-INF/applicationContext.xml 24 | 25 | 26 | org.springframework.web.context.ContextLoaderListener 27 | 28 | 29 | org.apache.ftpserver.example.springwar.FtpServerListener 30 | 31 | 32 | status 33 | org.apache.ftpserver.example.springwar.FtpServerServlet 34 | 35 | 36 | status 37 | / 38 | 39 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/MyFtplet.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 | 21 | package org.apache.ftpserver.example.ftpletservice; 22 | 23 | import java.io.IOException; 24 | 25 | import org.apache.ftpserver.ftplet.DefaultFtplet; 26 | import org.apache.ftpserver.ftplet.FtpException; 27 | import org.apache.ftpserver.ftplet.FtpSession; 28 | import org.apache.ftpserver.ftplet.FtpletResult; 29 | 30 | /* 31 | * @author Apache MINA Project 32 | */ 33 | public class MyFtplet extends DefaultFtplet { 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | public FtpletResult onConnect(FtpSession session) throws FtpException, 39 | IOException { 40 | System.out.println("User connected to FtpServer"); 41 | 42 | return super.onConnect(session); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public FtpletResult onDisconnect(FtpSession session) throws FtpException, 50 | IOException { 51 | System.out.println("User connected to FtpServer"); 52 | 53 | return super.onDisconnect(session); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/Activator.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.example.ftpletservice.impl; 21 | 22 | import java.util.Dictionary; 23 | import java.util.Hashtable; 24 | 25 | import org.apache.ftpserver.example.ftpletservice.MyFtplet; 26 | import org.apache.ftpserver.ftplet.Ftplet; 27 | import org.osgi.framework.BundleActivator; 28 | import org.osgi.framework.BundleContext; 29 | 30 | /* 31 | * @author Apache MINA Project 32 | */ 33 | public class Activator implements BundleActivator { 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | public void start(BundleContext context) throws Exception { 38 | Dictionary properties = new Hashtable(); 39 | properties.put("name", "myftplet"); 40 | 41 | context.registerService(Ftplet.class.getName(), 42 | new MyFtplet(), properties); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | public void stop(BundleContext context) throws Exception { 49 | // do nothing 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/impl/package-info.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 | * @author Apache MINA Project 21 | */ 22 | package org.apache.ftpserver.example.ftpletservice.impl; 23 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-ftplet-service/src/main/java/org/apache/ftpserver/example/ftpletservice/package-info.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 | * @author Apache MINA Project 21 | */ 22 | package org.apache.ftpserver.example.ftpletservice; 23 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-spring-service/src/main/java/org/apache/ftpserver/example/osgiservice/impl/FtpServerLifecycle.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 | 21 | package org.apache.ftpserver.example.osgiservice.impl; 22 | 23 | import org.apache.ftpserver.FtpServer; 24 | 25 | /* 26 | * @author Apache MINA Project 27 | */ 28 | public class FtpServerLifecycle { 29 | 30 | private FtpServer server; 31 | 32 | public FtpServer getServer() { 33 | return server; 34 | } 35 | 36 | public void setServer(FtpServer server) { 37 | this.server = server; 38 | } 39 | 40 | public void init() throws Exception { 41 | server.start(); 42 | System.out.println("Server started"); 43 | } 44 | 45 | public void destroy() throws Exception { 46 | server.stop(); 47 | System.out.println("Server stopped"); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /examples/ftpserver-osgi-spring-service/src/main/resources/org/apache/ftpserver/example/osgiservice/users.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 | # Password is "admin" 19 | ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3 20 | ftpserver.user.admin.homedirectory=/tmp 21 | ftpserver.user.admin.enableflag=true 22 | ftpserver.user.admin.writepermission=true 23 | ftpserver.user.admin.maxloginnumber=0 24 | ftpserver.user.admin.maxloginperip=0 25 | ftpserver.user.admin.idletime=0 26 | ftpserver.user.admin.uploadrate=0 27 | ftpserver.user.admin.downloadrate=0 28 | 29 | ftpserver.user.anonymous.userpassword= 30 | ftpserver.user.anonymous.homedirectory=/tmp 31 | ftpserver.user.anonymous.enableflag=true 32 | ftpserver.user.anonymous.writepermission=false 33 | ftpserver.user.anonymous.maxloginnumber=20 34 | ftpserver.user.anonymous.maxloginperip=2 35 | ftpserver.user.anonymous.idletime=300 36 | ftpserver.user.anonymous.uploadrate=4800 37 | ftpserver.user.anonymous.downloadrate=4800 38 | -------------------------------------------------------------------------------- /examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | ftpserver-parent 23 | org.apache.ftpserver 24 | 1.1.4-SNAPSHOT 25 | 26 | 4.0.0 27 | org.apache.ftpserver 28 | ftpserver-examples 29 | pom 30 | Apache FtpServer Examples 31 | 1.1.4-SNAPSHOT 32 | 33 | ftpserver-example-spring-war 34 | ftpserver-osgi-ftplet-service 35 | ftpserver-osgi-spring-service 36 | 37 | 38 | 39 | .. 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authentication.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 | * Represents a type of authentication request, typically anonymous or a 24 | * username and password combination 25 | * 26 | * @author Apache MINA Project 27 | */ 28 | public interface Authentication { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authority.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 | * Interface for an authority granted to the user, typical example is write 24 | * access or the number of concurrent logins 25 | * 26 | * @author Apache MINA Project 27 | */ 28 | public interface Authority { 29 | 30 | /** 31 | * Indicates weather this Authority can authorize a certain request 32 | * 33 | * @param request 34 | * The request to authorize 35 | * @return True if the request can be authorized by this Authority 36 | */ 37 | boolean canAuthorize(AuthorizationRequest request); 38 | 39 | /** 40 | * Authorize an {@link AuthorizationRequest}. 41 | * 42 | * @param request 43 | * The {@link AuthorizationRequest} 44 | * @return Returns a populated AuthorizationRequest as long as If 45 | * {@link #canAuthorize(AuthorizationRequest)} returns true for the 46 | * AuthorizationRequest, otherwise returns null. 47 | * {@link #canAuthorize(AuthorizationRequest)} should always be checked before 48 | * calling this method. 49 | */ 50 | AuthorizationRequest authorize(AuthorizationRequest request); 51 | } 52 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthorizationRequest.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 request for authorization for a specific task, for example write access. 24 | * 25 | * @author Apache MINA Project 26 | */ 27 | public interface AuthorizationRequest { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnectionFactory.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 | * 24 | * @author Apache MINA Project 25 | */ 26 | public interface DataConnectionFactory { 27 | 28 | /** 29 | * Open an active data connection 30 | * 31 | * @return The open data connection 32 | * @throws Exception 33 | */ 34 | DataConnection openConnection() throws Exception; 35 | 36 | /** 37 | * Indicates whether the data socket created by this factory will be secure 38 | * that is, running over SSL/TLS. 39 | * 40 | * @return true if the data socket will be secured 41 | */ 42 | 43 | boolean isSecure(); 44 | 45 | /** 46 | * Close data socket. If no open data connection exists, 47 | * this will silently ignore the call. 48 | */ 49 | void closeDataConnection(); 50 | 51 | } -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataTransferFtpReply.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 FTP reply that is sent by the commands that transfer 24 | * data over the data connection. These commands include LIST, RETR, STOR, STOU 25 | * etc. 26 | * 27 | * @author Apache MINA Project 28 | * 29 | */ 30 | 31 | public interface DataTransferFtpReply extends FileActionFtpReply { 32 | /** 33 | * Returns the number of bytes transferred. 34 | * 35 | * @return the number of bytes transferred. 36 | */ 37 | long getBytesTransferred(); 38 | } 39 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.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 data type 24 | * 25 | * @author Apache MINA Project 26 | */ 27 | public enum DataType { 28 | 29 | /** 30 | * Binary data type 31 | */ 32 | BINARY, 33 | 34 | /** 35 | * ASCII data type 36 | */ 37 | ASCII; 38 | 39 | /** 40 | * Parses the argument value from the TYPE command into the type safe class 41 | * 42 | * @param argument 43 | * The argument value from the TYPE command. Not case sensitive 44 | * @return The appropriate data type 45 | * @throws IllegalArgumentException 46 | * If the data type is unknown 47 | */ 48 | public static DataType parseArgument(char argument) { 49 | switch (argument) { 50 | case 'A': 51 | case 'a': 52 | return ASCII; 53 | case 'I': 54 | case 'i': 55 | return BINARY; 56 | default: 57 | throw new IllegalArgumentException("Unknown data type: " + argument); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ftplet-api/src/main/java/org/apache/ftpserver/ftplet/FileActionFtpReply.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 FtpReply that is sent for commands that act on a 24 | * single file or directory such as MKD, DELE, RMD etc. 25 | * 26 | * @author Apache MINA Project 27 | * 28 | */ 29 | 30 | public interface FileActionFtpReply extends FtpReply { 31 | 32 | /** 33 | * Returns the file (or directory) on which the action was taken 34 | * (e.g. uploaded, created, listed) 35 | * 36 | * @return the file on which the action was taken. May return 37 | * null, 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 | --------------------------------------------------------------------------------