├── .classpath ├── .gitignore ├── .project ├── COPYRIGHT.txt ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── core ├── license │ └── LICENSE.netty.txt ├── pom.xml └── src │ └── assembly │ └── default.xml ├── doc.txt ├── filesystem ├── license │ ├── LICENSE.commons-io.txt │ └── LICENSE.netty.txt ├── pom.xml └── src │ └── assembly │ └── default.xml ├── license ├── LICENSE.dom4j.txt ├── LICENSE.jaxen.txt ├── LICENSE.logback.txt ├── LICENSE.netty.txt └── LICENSE.slf4j.txt ├── maven-version-rules.xml ├── pom.xml ├── simpleimpl ├── license │ ├── LICENSE.commons-io.txt │ ├── LICENSE.dom4j.txt │ ├── LICENSE.jaxen.txt │ └── LICENSE.netty.txt ├── pom.xml └── src │ └── assembly │ └── default.xml └── src ├── .gitignore ├── assembly └── default.xml ├── changes └── changes.xml ├── javadoc └── overview.html ├── main ├── config │ ├── authent.xml │ ├── config.xml │ └── sslconfig.xml └── java │ └── org │ └── waarp │ └── ftp │ ├── core │ ├── command │ │ ├── AbstractCommand.java │ │ ├── FtpArgumentCode.java │ │ ├── FtpCommandCode.java │ │ ├── access │ │ │ ├── ACCT.java │ │ │ ├── PASS.java │ │ │ ├── QUIT.java │ │ │ ├── REIN.java │ │ │ ├── USER.java │ │ │ └── package-info.java │ │ ├── directory │ │ │ ├── CDUP.java │ │ │ ├── CWD.java │ │ │ ├── SMNT.java │ │ │ └── package-info.java │ │ ├── extension │ │ │ ├── XCRC.java │ │ │ ├── XMD5.java │ │ │ ├── XSHA1.java │ │ │ └── package-info.java │ │ ├── info │ │ │ ├── HELP.java │ │ │ ├── NOOP.java │ │ │ ├── SITE.java │ │ │ ├── STAT.java │ │ │ ├── SYST.java │ │ │ └── package-info.java │ │ ├── internal │ │ │ ├── ConnectionCommand.java │ │ │ ├── INTERNALSHUTDOWN.java │ │ │ ├── IncorrectCommand.java │ │ │ ├── LIMITBANDWIDTH.java │ │ │ ├── UnimplementedCommand.java │ │ │ ├── UnknownCommand.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── parameter │ │ │ ├── MODE.java │ │ │ ├── PASV.java │ │ │ ├── PORT.java │ │ │ ├── STRU.java │ │ │ ├── TYPE.java │ │ │ └── package-info.java │ │ ├── rfc2389 │ │ │ ├── FEAT.java │ │ │ ├── OPTS.java │ │ │ └── package-info.java │ │ ├── rfc2428 │ │ │ ├── EPRT.java │ │ │ ├── EPSV.java │ │ │ └── package-info.java │ │ ├── rfc3659 │ │ │ ├── MDTM.java │ │ │ ├── MLSD.java │ │ │ ├── MLST.java │ │ │ ├── SIZE.java │ │ │ └── package-info.java │ │ ├── rfc4217 │ │ │ ├── AUTH.java │ │ │ ├── CCC.java │ │ │ ├── PBSZ.java │ │ │ ├── PROT.java │ │ │ └── package-info.java │ │ ├── rfc775 │ │ │ ├── XCUP.java │ │ │ ├── XCWD.java │ │ │ ├── XMKD.java │ │ │ ├── XPWD.java │ │ │ ├── XRMD.java │ │ │ └── package-info.java │ │ └── service │ │ │ ├── ABOR.java │ │ │ ├── ALLO.java │ │ │ ├── APPE.java │ │ │ ├── DELE.java │ │ │ ├── LIST.java │ │ │ ├── MKD.java │ │ │ ├── NLST.java │ │ │ ├── PWD.java │ │ │ ├── REST.java │ │ │ ├── RETR.java │ │ │ ├── RMD.java │ │ │ ├── RNFR.java │ │ │ ├── RNTO.java │ │ │ ├── STOR.java │ │ │ ├── STOU.java │ │ │ └── package-info.java │ ├── config │ │ ├── FtpChannelTrafficShapingHandler.java │ │ ├── FtpConfiguration.java │ │ ├── FtpGlobalTrafficShapingHandler.java │ │ ├── FtpInternalConfiguration.java │ │ └── package-info.java │ ├── control │ │ ├── BusinessHandler.java │ │ ├── FtpControlStringDecoder.java │ │ ├── FtpControlStringEncoder.java │ │ ├── FtpInitializer.java │ │ ├── NetworkHandler.java │ │ ├── ftps │ │ │ ├── FtpsInitializer.java │ │ │ ├── SslNetworkHandler.java │ │ │ └── package-info.java │ │ └── package-info.java │ ├── data │ │ ├── FtpDataAsyncConn.java │ │ ├── FtpTransfer.java │ │ ├── FtpTransferControl.java │ │ ├── FtpTransferExecutor.java │ │ ├── handler │ │ │ ├── DataBusinessHandler.java │ │ │ ├── DataNetworkHandler.java │ │ │ ├── FtpDataInitializer.java │ │ │ ├── FtpDataModeCodec.java │ │ │ ├── FtpDataStructureCodec.java │ │ │ ├── FtpDataTypeCodec.java │ │ │ ├── FtpSeekAheadData.java │ │ │ ├── ftps │ │ │ │ ├── FtpsDataInitializer.java │ │ │ │ ├── FtpsTemporaryFirstHandler.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ └── package-info.java │ ├── exception │ │ ├── FtpNoConnectionException.java │ │ ├── FtpNoFileException.java │ │ ├── FtpNoTransferException.java │ │ ├── FtpUnknownFieldException.java │ │ └── package-info.java │ ├── file │ │ ├── FtpAuth.java │ │ ├── FtpDir.java │ │ ├── FtpFile.java │ │ └── package-info.java │ ├── session │ │ ├── FtpSession.java │ │ ├── FtpSessionReference.java │ │ └── package-info.java │ └── utils │ │ ├── FtpChannelUtils.java │ │ ├── FtpShutdownHook.java │ │ ├── FtpTimerTask.java │ │ └── package-info.java │ ├── filesystembased │ ├── FilesystemBasedFtpAuth.java │ ├── FilesystemBasedFtpDir.java │ ├── FilesystemBasedFtpFile.java │ ├── FilesystemBasedFtpRestart.java │ └── package-info.java │ ├── package-info.java │ └── simpleimpl │ ├── SimpleGatewayFtpServer.java │ ├── SimpleGatewaySslFtpServer.java │ ├── config │ ├── CircularIntValue.java │ ├── FileBasedConfiguration.java │ ├── FileBasedSslConfiguration.java │ └── package-info.java │ ├── control │ ├── SimpleBusinessHandler.java │ └── package-info.java │ ├── data │ ├── FileSystemBasedDataBusinessHandler.java │ └── package-info.java │ ├── file │ ├── FileBasedAuth.java │ ├── FileBasedDir.java │ ├── FileBasedFile.java │ ├── SimpleAuth.java │ └── package-info.java │ └── package-info.java └── site ├── apt ├── configuration.apt └── index.apt ├── resources ├── html │ ├── core │ │ └── index.html │ ├── filesystem │ │ └── index.html │ └── simpleimpl │ │ └── index.html └── images │ ├── bench-100vu.png │ ├── bench-10K.png │ ├── bench-1K.png │ ├── connections.png │ ├── waarp.gif │ └── waarp.jpg └── site.xml /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | tmp/ 9 | target/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | .pmd 19 | 20 | # External tool builders 21 | .externalToolBuilders/ 22 | 23 | # Locally stored "Eclipse launch configurations" 24 | *.launch 25 | 26 | # CDT-specific 27 | .cproject 28 | 29 | # PDT-specific 30 | .buildpath 31 | 32 | ################# 33 | ## Java 34 | ################# 35 | *.class 36 | *.jardesc 37 | 38 | ################# 39 | ## Visual Studio 40 | ################# 41 | 42 | ## Ignore Visual Studio temporary files, build results, and 43 | ## files generated by popular Visual Studio add-ons. 44 | 45 | # User-specific files 46 | *.suo 47 | *.user 48 | *.sln.docstates 49 | 50 | # Build results 51 | [Dd]ebug/ 52 | [Rr]elease/ 53 | *_i.c 54 | *_p.c 55 | *.ilk 56 | *.meta 57 | *.obj 58 | *.pch 59 | *.pdb 60 | *.pgc 61 | *.pgd 62 | *.rsp 63 | *.sbr 64 | *.tlb 65 | *.tli 66 | *.tlh 67 | *.tmp 68 | *.vspscc 69 | .builds 70 | *.dotCover 71 | 72 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 73 | #packages/ 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper* 88 | 89 | # Installshield output folder 90 | [Ee]xpress 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish 104 | 105 | # Others 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | runtime.properties 135 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | WaarpFtp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | The Waarp Project - Copyright (C) 2009, Frederic Bregier, and individual 2 | contributors, and is licensed under the GNU GPL V (General Public License) 3 | as published by the Free Software Foundation; either version 3.0 of the License, 4 | or (at your option) any later version. 5 | 6 | A summary of the individual contributors is given below. Any omission should be 7 | sent to Frederic Bregier . 8 | 9 | SVN Login(s) Name 10 | ------------------------------------------------------------------------------- 11 | openlsd Frederic Bregier 12 | waarp1 Frederic Bregier 13 | fredericBregier Frederic Bregier 14 | openr66 Frederic Bregier 15 | ------------------------------------------------------------------------------- 16 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | 2 | The Waarp Project 3 | ================= 4 | 5 | Please visit the Waarp web site for more information: 6 | 7 | * http://waarp.github.com/Waarp/ 8 | 9 | Copyright (C) 2006 Frederic Bregier, and individual contributors 10 | by the @author tags. See the COPYRIGHT.txt in the distribution for a 11 | full listing of individual contributors. 12 | 13 | This program is free software: you can redistribute it and/or modify 14 | it under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | This program is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with this program. If not, see . 25 | 26 | Also, please refer to each LICENSE..txt file, which is located in 27 | the 'license' directory of the distribution file, for the license terms of the 28 | components that this product depends on. 29 | 30 | ------------------------------------------------------------------------------- 31 | This product depends on 'NETTY', an asynchronous event-driven 32 | network application framework, which can be obtained at: 33 | 34 | * LICENSE: 35 | * license/LICENSE.netty.txt (Apache license) 36 | * HOMEPAGE: 37 | * http://netty.io/ 38 | 39 | This product contains a modified version of the 'Fast MD5', 40 | a fast implementation of RSA's MD5 hash generator, 41 | which can be obtained at: 42 | 43 | * LICENSE: 44 | * license/LICENSE.fastmd5.txt (LGPL 2.1) 45 | * HOMEPAGE: 46 | * http://www.twmacinta.com/myjava/fast_md5.php 47 | 48 | This product optionally depends on 'SLF4J', a simple logging facade for Java, 49 | which can be obtained at: 50 | 51 | * LICENSE: 52 | * license/LICENSE.slf4j.txt (MIT License) 53 | * HOMEPAGE: 54 | * http://www.slf4j.org/ 55 | 56 | This product optionally depends on 'LOGBACK', a logging 57 | framework, which can be obtained at: 58 | 59 | * LICENSE: 60 | * license/LICENSE.logback.txt (LGPL 2.1) 61 | * HOMEPAGE: 62 | * http://logback.qos.ch/ 63 | 64 | This product optionally depends on 'DOM4J', open source library for working with XML, 65 | XPath and XSLT, which can be obtained at: 66 | 67 | * LICENSE: 68 | * license/LICENSE.dom4j.txt (BSD style license) 69 | * HOMEPAGE: 70 | * http://www.dom4j.org/ 71 | 72 | This product optionally depends on 'JAXEN', open source XPath library, 73 | which can be obtained at: 74 | 75 | * LICENSE: 76 | * license/LICENSE.jaxen.txt (Apache-style license) 77 | * HOMEPAGE: 78 | * http://jaxen.codehaus.org/ 79 | 80 | This product optionally depends on 'COMMONS-IO', open source XPath library, 81 | which can be obtained at: 82 | 83 | * LICENSE: 84 | * license/LICENSE.commons-io.txt (Apache license) 85 | * HOMEPAGE: 86 | * http://commons.apache.org/io/ 87 | -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | Waarp 5 | WaarpFtp 6 | 3.0.8 7 | ../pom.xml 8 | 9 | WaarpFtp-Core 10 | WaarpFtp-Core 11 | 12 | core 13 | netty 14 | zzz 15 | 16 | 17 | 18 | 19 | 20 | ../src/main/java 21 | 22 | 23 | 24 | org.codehaus.mojo 25 | animal-sniffer-maven-plugin 26 | 27 | 28 | org.codehaus.mojo.signature 29 | java16 30 | 1.0 31 | 32 | 33 | 34 | 35 | maven-compiler-plugin 36 | 37 | UTF-8 38 | 1.6 39 | 1.6 40 | true 41 | true 42 | 43 | **/${filtermodule}/** 44 | **/${filterextra}/** 45 | 46 | 47 | 48 | 49 | org.codehaus.mojo 50 | versions-maven-plugin 51 | 2.3 52 | false 53 | 54 | file:///${session.executionRootDirectory}/maven-version-rules.xml 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-site-plugin 64 | 3.3 65 | 66 | false 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /core/src/assembly/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dist 4 | 5 | tar.bz2 6 | tar.gz 7 | zip 8 | 9 | false 10 | 11 | 12 | 13 | 14 | **/README* 15 | **/LICENSE* 16 | **/NOTICE* 17 | **/COPYRIGHT* 18 | **/*.txt 19 | **/*.xml 20 | **/license/** 21 | **/lib/** 22 | **/src/** 23 | 24 | 25 | **/target/** 26 | **/.*/** 27 | 28 | 29 | 30 | 31 | 32 | ../target 33 | jar 34 | 35 | ${project.build.finalName}*.jar 36 | 37 | 38 | ${project.build.finalName}*-javadoc.jar 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /doc.txt: -------------------------------------------------------------------------------- 1 | -d D:\NEWSOURCE\GoldenGateFtpTrunk\target\api -sourceclasspath D:\NEWSOURCE\GoldenGateFtpTrunk\target\classes 2 | -doctitle "GoldenGate Open Source FTP Server V0.9.2" 3 | -bottom "" 4 | -group "GoldenGate Common Logging, Future, Command, Authentication, Session and File package" "goldengate.common*" 5 | -group "GoldenGate FTP Main Core package" "goldengate.ftp.core*" 6 | -group "GoldenGate FTP Filesystem Implementation package" "goldengate.ftp.filesystembased*" 7 | -group "GoldenGate Simple FTP Server package" "goldengate.ftp.simpleimpl*" 8 | 9 | -d D:\NEWSOURCE\GoldenGateFtp\docKernel -sourceclasspath D:\NEWSOURCE\GoldenGateFtp\bin 10 | -doctitle "GoldenGate Open Source FTP Server Kernel V0.9.1" 11 | -bottom "" 12 | -group "GoldenGate FTP Main Core Authentification package" "goldengate.ftp.core.auth*" 13 | -group "GoldenGate FTP Main Core Command package" "goldengate.ftp.core.command*" 14 | -group "GoldenGate FTP Main Core Config package" "goldengate.ftp.core.config*" 15 | -group "GoldenGate FTP Main Core Control package" "goldengate.ftp.core.control*" 16 | -group "GoldenGate FTP Main Core Data package" "goldengate.ftp.core.data*" 17 | -group "GoldenGate FTP Main Core File package" "goldengate.ftp.core.file*" 18 | -group "GoldenGate FTP Main Core Session package" "goldengate.ftp.core.session*" 19 | -group "GoldenGate FTP Main Core Other package" "goldengate.ftp.core.exception*:goldengate.ftp.core.logging*:goldengate.ftp.core.utils*" 20 | 21 | -d D:\NEWSOURCE\GoldenGateFtp\docFilesystemBased -sourceclasspath D:\NEWSOURCE\GoldenGateFtp\bin 22 | -doctitle "GoldenGate Open Source FTP Server Filesystem V0.9.1" 23 | -bottom "" 24 | -group "GoldenGate FTP Filesystem Implementation package" "goldengate.ftp.filesystembased*" 25 | 26 | -d D:\NEWSOURCE\GoldenGateFtp\docSimpleImpl -sourceclasspath D:\NEWSOURCE\GoldenGateFtp\bin 27 | -doctitle "GoldenGate Open Source FTP Server Simple Implementation V0.9.1" 28 | -bottom "" 29 | -group "GoldenGate Simple FTP Server package" "goldengate.ftp.simpleimpl*" 30 | -------------------------------------------------------------------------------- /filesystem/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | Waarp 5 | WaarpFtp 6 | 3.0.8 7 | ../pom.xml 8 | 9 | WaarpFtp-Filesystem 10 | WaarpFtp-Filesystem 11 | 12 | ftp/filesystembased 13 | zzz 14 | 15 | 16 | 17 | Waarp 18 | WaarpFtp-Core 19 | ${version} 20 | 21 | 22 | 23 | 24 | ../src/main/java 25 | 26 | 27 | 28 | org.codehaus.mojo 29 | animal-sniffer-maven-plugin 30 | 31 | 32 | org.codehaus.mojo.signature 33 | java16 34 | 1.0 35 | 36 | 37 | 38 | 39 | maven-compiler-plugin 40 | 41 | UTF-8 42 | 1.6 43 | 1.6 44 | true 45 | true 46 | 47 | **/${filtermodule}/** 48 | 49 | 50 | 51 | 52 | org.codehaus.mojo 53 | versions-maven-plugin 54 | 2.3 55 | false 56 | 57 | file:///${session.executionRootDirectory}/maven-version-rules.xml 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.apache.maven.plugins 66 | maven-site-plugin 67 | 3.3 68 | 69 | false 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /filesystem/src/assembly/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dist 4 | 5 | tar.bz2 6 | tar.gz 7 | zip 8 | 9 | false 10 | 11 | 12 | 13 | 14 | **/README* 15 | **/LICENSE* 16 | **/NOTICE* 17 | **/COPYRIGHT* 18 | **/*.txt 19 | **/*.xml 20 | **/license/** 21 | **/lib/** 22 | **/src/** 23 | 24 | 25 | **/target/** 26 | **/.*/** 27 | 28 | 29 | 30 | 31 | 32 | ../target 33 | jar 34 | 35 | ${project.build.finalName}*.jar 36 | 37 | 38 | ${project.build.finalName}*-javadoc.jar 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /license/LICENSE.dom4j.txt: -------------------------------------------------------------------------------- 1 | Redistribution and use of this software and associated documentation ("Software"), 2 | with or without modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain copyright statements and notices. 6 | Redistributions must also contain a copy of this document. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this 8 | list of conditions and the following disclaimer in the documentation and/or other 9 | materials provided with the distribution. 10 | 3. The name "DOM4J" must not be used to endorse or promote products derived from 11 | this Software without prior written permission of MetaStuff, Ltd. For written 12 | permission, please contact dom4j-info@metastuff.com. 13 | 4. Products derived from this Software may not be called "DOM4J" nor may "DOM4J" 14 | appear in their names without prior written permission of MetaStuff, Ltd. DOM4J 15 | is a registered trademark of MetaStuff, Ltd. 16 | 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org 17 | 18 | THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND ANY 19 | EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. 29 | -------------------------------------------------------------------------------- /license/LICENSE.jaxen.txt: -------------------------------------------------------------------------------- 1 | $Id: LICENSE.txt,v 1.5 2006/02/05 21:49:04 elharo Exp $ 2 | 3 | Copyright 2003-2006 The Werken Company. All Rights Reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the Jaxen Project nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /license/LICENSE.logback.txt: -------------------------------------------------------------------------------- 1 | Logback: the reliable, generic, fast and flexible logging library for Java. 2 | 3 | Copyright (C) 2000-2008, QOS.ch 4 | 5 | Source code and binaries for logback, including logback-core, 6 | logback-classic and logback-access modules, are distributed under the 7 | GNU Lesser General Public License Version 2.1, as published by the 8 | Free Software Foundation. 9 | 10 | This library is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 2.1 of the License, or (at your option) any later version. 14 | 15 | This library is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | -------------------------------------------------------------------------------- /license/LICENSE.slf4j.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2007 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | -------------------------------------------------------------------------------- /maven-version-rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | (?i).*Alpha(?:-?\d+)? 6 | (?i).*Beta(?:-?\d+)? 7 | (?i).*-B(?:-?\d+)? 8 | (?i).*RC(?:-?\d+)? 9 | (?i).*CR(?:-?\d+)? 10 | (?i).*M(?:-?\d+)? 11 | 12 | 13 | 14 | 15 | 20040902.021138 16 | 1.6.1-jboss 17 | 1.6.1-brew 18 | 19 | 20 | 21 | 22 | 6\.0\..+ 23 | 8\.0\..+ 24 | 25 | 26 | 27 | 28 | 2\.6\..+ 29 | 30 | 31 | 32 | 33 | 1\.2\..+ 34 | 1\.3\..+ 35 | 1\.4\..+ 36 | 1\.5\..+ 37 | 1\.6\..+ 38 | 2\..+ 39 | 40 | 41 | 42 | 43 | .+jre7$ 44 | 45 | 46 | 47 | 48 | ^2\.8\..+ 49 | ^2\.9\..+ 50 | 51 | 52 | 53 | 54 | ^2\.8\..+ 55 | ^2\.9\..+ 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /simpleimpl/license/LICENSE.dom4j.txt: -------------------------------------------------------------------------------- 1 | Redistribution and use of this software and associated documentation ("Software"), 2 | with or without modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain copyright statements and notices. 6 | Redistributions must also contain a copy of this document. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this 8 | list of conditions and the following disclaimer in the documentation and/or other 9 | materials provided with the distribution. 10 | 3. The name "DOM4J" must not be used to endorse or promote products derived from 11 | this Software without prior written permission of MetaStuff, Ltd. For written 12 | permission, please contact dom4j-info@metastuff.com. 13 | 4. Products derived from this Software may not be called "DOM4J" nor may "DOM4J" 14 | appear in their names without prior written permission of MetaStuff, Ltd. DOM4J 15 | is a registered trademark of MetaStuff, Ltd. 16 | 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org 17 | 18 | THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND ANY 19 | EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. 29 | -------------------------------------------------------------------------------- /simpleimpl/license/LICENSE.jaxen.txt: -------------------------------------------------------------------------------- 1 | $Id: LICENSE.txt,v 1.5 2006/02/05 21:49:04 elharo Exp $ 2 | 3 | Copyright 2003-2006 The Werken Company. All Rights Reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the Jaxen Project nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /simpleimpl/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | Waarp 5 | WaarpFtp 6 | 3.0.8 7 | ../pom.xml 8 | 9 | WaarpFtp-SimpleServer 10 | WaarpFtp-Simpleimpl 11 | 12 | ftp/simpleimpl 13 | zzz 14 | 15 | 16 | 17 | Waarp 18 | WaarpFtp-Core 19 | ${version} 20 | 21 | 22 | Waarp 23 | WaarpFtp-Filesystem 24 | ${version} 25 | 26 | 27 | 28 | 29 | ../src/main/java 30 | 31 | 32 | 33 | org.codehaus.mojo 34 | animal-sniffer-maven-plugin 35 | 36 | 37 | org.codehaus.mojo.signature 38 | java16 39 | 1.0 40 | 41 | 42 | 43 | 44 | maven-compiler-plugin 45 | 46 | UTF-8 47 | 1.6 48 | 1.6 49 | true 50 | true 51 | 52 | **/${filtermodule}/** 53 | 54 | 55 | 56 | 57 | org.codehaus.mojo 58 | versions-maven-plugin 59 | 2.3 60 | false 61 | 62 | file:///${session.executionRootDirectory}/maven-version-rules.xml 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-site-plugin 72 | 3.3 73 | 74 | false 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /simpleimpl/src/assembly/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dist 4 | 5 | tar.bz2 6 | tar.gz 7 | zip 8 | 9 | false 10 | 11 | 12 | 13 | 14 | **/README* 15 | **/LICENSE* 16 | **/NOTICE* 17 | **/COPYRIGHT* 18 | **/*.txt 19 | **/*.xml 20 | **/license/** 21 | **/lib/** 22 | **/src/** 23 | 24 | 25 | **/target/** 26 | **/.*/** 27 | 28 | 29 | 30 | 31 | 32 | ../target 33 | jar 34 | 35 | ${project.build.finalName}*.jar 36 | 37 | 38 | ${project.build.finalName}*-javadoc.jar 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | /test 2 | -------------------------------------------------------------------------------- /src/assembly/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dist 4 | 5 | tar.bz2 6 | tar.gz 7 | zip 8 | 9 | false 10 | 11 | 12 | 13 | 14 | **/README* 15 | **/LICENSE* 16 | **/NOTICE* 17 | **/COPYRIGHT* 18 | **/*.txt 19 | **/*.xml 20 | **/license/** 21 | **/src/** 22 | 23 | 24 | **/target/** 25 | **/.*/** 26 | 27 | 28 | 29 | 30 | 31 | target 32 | jar 33 | 34 | ${project.build.finalName}*.jar 35 | 36 | 37 | ${project.build.finalName}*-javadoc.jar 38 | 39 | 40 | 41 | 42 | 43 | target/api 44 | doc/api 45 | 46 | **/** 47 | 48 | 49 | 50 | 51 | 52 | target/xref 53 | doc/xref 54 | 55 | **/** 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/javadoc/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The Waarp FTP Project API Reference 4 | 5 | 6 |
7 |

The Waarp 8 | FTP project 9 | is a proposal of a new fresh FTP server implementation, 10 | fully in Java according to the following RFC: RFC 959, RFC 775, RFC 2389, RFC 2428, RFC 3659. 11 | It includes also extra commands like XCRC, XMD5, XSHA1, INTERNALSHUTDOWN. It is based mainly 12 | on the NETTY framework (NIO great framework support) and is tend to be really efficient, both 13 | in term of memory, threads and network bandwidth. Bandwidth limitation can be configured both 14 | in store and retrieve, per session (although only one value is set by default, but it can be 15 | changed dynamically if needed) or globally to the server and of course with no limitation at 16 | all if wanted. Limitation should be enough to change the bandwidth behaviour for instance 17 | depending on the time in the day, so as to allow to limit bandwidth usage when users are at 18 | work and in contrary to allow more speed when only batchs are running. The specificity of this 19 | project is you can adapt this software to your particular needs by: changing the pre or post 20 | action on commands (not only transfer), changing the underlying representation of files and 21 | directories (for instance with database entries), using any particular authentication mechanism.

22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/config/authent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | fredo 4 | fred1 5 | a 6 | b 7 | c 8 | d 9 | 1 10 | 11 | 12 | fred 13 | fred2 14 | a 15 | b 16 | c 17 | d 18 | 19 | 20 | test 21 | test 22 | 23 | -------------------------------------------------------------------------------- /src/main/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | Example of config file: change its as your need. 3 | abcdef 4 | 2021 5 | /opt/R66/GGFTP 6 | 10 7 | 102400 8 | 1024000 9 | 0 10 | 0 11 | 10000 12 | 0 13 | 0 14 | 0 15 | 65536 16 | 17 | 3001 18 | 32000 19 | 20 | src/main/config/authent.xml 21 | -------------------------------------------------------------------------------- /src/main/config/sslconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /opt/R66/GGFTP/certs/testsslnocert.jks 4 | testsslnocert 5 | testalias 6 | /opt/R66/GGFTP/certs/testcert.jks 7 | testcert 8 | False 9 | 10 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/ACCT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.access; 19 | 20 | import org.waarp.common.command.NextCommandReply; 21 | import org.waarp.common.command.exception.Reply421Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply502Exception; 24 | import org.waarp.common.command.exception.Reply530Exception; 25 | import org.waarp.ftp.core.command.AbstractCommand; 26 | 27 | /** 28 | * ACCT command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class ACCT extends AbstractCommand { 34 | @Override 35 | public void exec() throws Reply501Exception, Reply421Exception, 36 | Reply530Exception, Reply502Exception { 37 | if (!hasArg()) { 38 | invalidCurrentCommand(); 39 | throw new Reply501Exception("Need an account as argument"); 40 | } 41 | String account = getArg(); 42 | NextCommandReply nextCommandReply; 43 | try { 44 | nextCommandReply = getSession().getAuth().setAccount(account); 45 | } catch (Reply530Exception e) { 46 | getSession().reinitFtpAuth(); 47 | throw e; 48 | } 49 | setExtraNextCommand(nextCommandReply.command); 50 | getSession().setReplyCode(nextCommandReply.reply, 51 | nextCommandReply.message); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/PASS.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.access; 19 | 20 | import org.waarp.common.command.NextCommandReply; 21 | import org.waarp.common.command.exception.Reply421Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply530Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * PASS command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class PASS extends AbstractCommand { 33 | @Override 34 | public void exec() throws Reply421Exception, Reply501Exception, 35 | Reply530Exception { 36 | if (!hasArg()) { 37 | invalidCurrentCommand(); 38 | throw new Reply501Exception("Need password as argument"); 39 | } 40 | String password = getArg(); 41 | if (getSession().getAuth() == null) { 42 | getSession().reinitFtpAuth(); 43 | throw new Reply530Exception("No user specified"); 44 | } 45 | NextCommandReply nextCommandReply = null; 46 | try { 47 | nextCommandReply = getSession().getAuth().setPassword(password); 48 | } catch (Reply530Exception e) { 49 | getSession().reinitFtpAuth(); 50 | throw e; 51 | } 52 | setExtraNextCommand(nextCommandReply.command); 53 | getSession().setReplyCode(nextCommandReply.reply, 54 | nextCommandReply.message); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/QUIT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.access; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.ftp.core.command.AbstractCommand; 22 | 23 | /** 24 | * QUIT command 25 | * 26 | * @author Frederic Bregier 27 | * 28 | */ 29 | public class QUIT extends AbstractCommand { 30 | @Override 31 | public void exec() { 32 | getSession().rein(); 33 | getSession().setNextCommand(this); 34 | getSession().setReplyCode( 35 | ReplyCode.REPLY_221_CLOSING_CONTROL_CONNECTION, null); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/REIN.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.access; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | import org.waarp.ftp.core.command.FtpCommandCode; 24 | 25 | /** 26 | * REIN command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class REIN extends AbstractCommand { 32 | 33 | @Override 34 | public void exec() throws CommandAbstractException { 35 | // reset to default 36 | getSession().rein(); 37 | setExtraNextCommand(FtpCommandCode.USER); 38 | getSession().setReplyCode(ReplyCode.REPLY_220_SERVICE_READY, 39 | null); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/USER.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.access; 19 | 20 | import org.waarp.common.command.NextCommandReply; 21 | import org.waarp.common.command.exception.Reply421Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply530Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * USER command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class USER extends AbstractCommand { 33 | @Override 34 | public void exec() throws Reply501Exception, Reply421Exception, 35 | Reply530Exception { 36 | if (!hasArg()) { 37 | getSession().reinitFtpAuth(); 38 | throw new Reply501Exception("Need a username as argument"); 39 | } 40 | String username = getArg(); 41 | NextCommandReply nextCommandReply; 42 | try { 43 | nextCommandReply = getSession().getAuth().setUser(username); 44 | } catch (Reply530Exception e) { 45 | getSession().reinitFtpAuth(); 46 | throw e; 47 | } 48 | setExtraNextCommand(nextCommandReply.command); 49 | getSession().setReplyCode(nextCommandReply.reply, 50 | nextCommandReply.message); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/access/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Access related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.access; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/directory/CDUP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.directory; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply530Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | import org.waarp.ftp.core.file.FtpDir; 25 | 26 | /** 27 | * CDUP command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class CDUP extends AbstractCommand { 33 | @Override 34 | public void exec() throws CommandAbstractException { 35 | FtpDir current = getSession().getDir(); 36 | if (current == null) { 37 | throw new Reply530Exception("Not authentificated"); 38 | } 39 | if (current.changeParentDirectory()) { 40 | getSession() 41 | .setReplyCode( 42 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 43 | "\"" + current.getPwd() + 44 | "\" is the new current directory"); 45 | } else { 46 | getSession().setReplyCode( 47 | ReplyCode.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, null); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/directory/CWD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.directory; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply530Exception; 23 | import org.waarp.common.logging.WaarpLogger; 24 | import org.waarp.common.logging.WaarpLoggerFactory; 25 | import org.waarp.ftp.core.command.AbstractCommand; 26 | import org.waarp.ftp.core.file.FtpDir; 27 | 28 | /** 29 | * CWD command 30 | * 31 | * @author Frederic Bregier 32 | * 33 | */ 34 | public class CWD extends AbstractCommand { 35 | /** 36 | * Internal Logger 37 | */ 38 | private static final WaarpLogger logger = WaarpLoggerFactory 39 | .getLogger(CWD.class); 40 | 41 | @Override 42 | public void exec() throws CommandAbstractException { 43 | FtpDir current = getSession().getDir(); 44 | if (current == null) { 45 | logger.warn("not identidied"); 46 | throw new Reply530Exception("Not authentificated"); 47 | } 48 | String nextDir = getArg(); 49 | if (!hasArg()) { 50 | nextDir = "/"; 51 | } 52 | if (current.changeDirectory(nextDir)) { 53 | getSession() 54 | .setReplyCode( 55 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 56 | "\"" + current.getPwd() + 57 | "\" is the new current directory"); 58 | } else { 59 | getSession().setReplyCode( 60 | ReplyCode.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, null); 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/directory/SMNT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.directory; 19 | 20 | import org.waarp.ftp.core.command.internal.UnimplementedCommand; 21 | 22 | /** 23 | * SMNT command (unimplemented) 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class SMNT extends UnimplementedCommand {} 29 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/directory/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Directory related commands 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.directory; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/extension/XCRC.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.extension; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * XCRC command: takes a filename and returns the CRC of the file 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class XCRC extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | if (!hasArg()) { 35 | invalidCurrentCommand(); 36 | throw new Reply501Exception("Need a pathname as argument"); 37 | } 38 | String filename = getArg(); 39 | 40 | String crc = Long.toString(getSession().getDir().getCRC(filename)); 41 | getSession().setReplyCode( 42 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 43 | crc + " \"" + filename + "\" CRC"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/extension/XMD5.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.extension; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.digest.FilesystemBasedDigest; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * XMD5 command: takes a filename and returns the MD5 of the file 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class XMD5 extends AbstractCommand { 33 | @Override 34 | public void exec() throws CommandAbstractException { 35 | if (!hasArg()) { 36 | invalidCurrentCommand(); 37 | throw new Reply501Exception("Need a pathname as argument"); 38 | } 39 | String filename = getArg(); 40 | 41 | String crc = FilesystemBasedDigest.getHex(getSession().getDir().getMD5( 42 | filename)); 43 | getSession().setReplyCode( 44 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 45 | crc + " \"" + filename + "\" MD5"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/extension/XSHA1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.extension; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.digest.FilesystemBasedDigest; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * XSHA1 command: takes a filename and returns the SHA-1 of the file 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class XSHA1 extends AbstractCommand { 33 | @Override 34 | public void exec() throws CommandAbstractException { 35 | if (!hasArg()) { 36 | invalidCurrentCommand(); 37 | throw new Reply501Exception("Need a pathname as argument"); 38 | } 39 | String filename = getArg(); 40 | 41 | String crc = FilesystemBasedDigest.getHex(getSession().getDir() 42 | .getSHA1(filename)); 43 | getSession().setReplyCode( 44 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 45 | crc + " \"" + filename + "\" SHA-1"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/extension/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP non standard Extensions related command 3 | * 4 | * @apiviz.exclude 5 | * 6 | */ 7 | package org.waarp.ftp.core.command.extension; 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/info/HELP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.info; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.ftp.core.command.AbstractCommand; 22 | 23 | /** 24 | * HELP command 25 | * 26 | * @author Frederic Bregier 27 | * 28 | */ 29 | public class HELP extends AbstractCommand { 30 | @Override 31 | public void exec() { 32 | getSession().setReplyCode(ReplyCode.REPLY_214_HELP_MESSAGE, 33 | getSession().getBusinessHandler().getHelpMessage(getArg())); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/info/NOOP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.info; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.ftp.core.command.AbstractCommand; 22 | import org.waarp.ftp.core.command.FtpCommandCode; 23 | import org.waarp.ftp.core.session.FtpSession; 24 | 25 | /** 26 | * NOOP command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class NOOP extends AbstractCommand { 32 | public NOOP() { 33 | super(); 34 | } 35 | 36 | /** 37 | * Constructor for empty NOOP 38 | * 39 | * @param session 40 | */ 41 | public NOOP(FtpSession session) { 42 | super(); 43 | setArgs(session, FtpCommandCode.NOOP.name(), null, FtpCommandCode.NOOP); 44 | } 45 | 46 | @Override 47 | public void exec() { 48 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, null); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/info/SYST.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.info; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.ftp.core.command.AbstractCommand; 22 | 23 | /** 24 | * SYST command 25 | * 26 | * @author Frederic Bregier 27 | * 28 | */ 29 | public class SYST extends AbstractCommand { 30 | @Override 31 | public void exec() { 32 | getSession().setReplyCode(ReplyCode.REPLY_215_NAME_SYSTEM_TYPE, 33 | "UNIX Type: L8"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/info/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Informational related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.info; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/ConnectionCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | import org.waarp.ftp.core.command.FtpCommandCode; 24 | import org.waarp.ftp.core.session.FtpSession; 25 | 26 | /** 27 | * Connection command: initialize the process of authentication 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class ConnectionCommand extends AbstractCommand { 33 | 34 | /** 35 | * Create a ConnectionCommand 36 | * 37 | * @param session 38 | */ 39 | public ConnectionCommand(FtpSession session) { 40 | super(); 41 | setArgs(session, "Connection", null, FtpCommandCode.Connection); 42 | } 43 | 44 | @Override 45 | public void exec() throws CommandAbstractException { 46 | // Nothing to do except 220 47 | getSession().setReplyCode(ReplyCode.REPLY_220_SERVICE_READY, null); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/INTERNALSHUTDOWN.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import io.netty.channel.ChannelFuture; 21 | import io.netty.channel.ChannelFutureListener; 22 | import org.waarp.common.command.ReplyCode; 23 | import org.waarp.common.command.exception.Reply500Exception; 24 | import org.waarp.common.command.exception.Reply501Exception; 25 | import org.waarp.common.crypto.ssl.WaarpSslUtility; 26 | import org.waarp.common.logging.WaarpLogger; 27 | import org.waarp.common.logging.WaarpLoggerFactory; 28 | import org.waarp.ftp.core.command.AbstractCommand; 29 | import org.waarp.ftp.core.config.FtpConfiguration; 30 | import org.waarp.ftp.core.utils.FtpChannelUtils; 31 | 32 | /** 33 | * Internal shutdown command that will shutdown the FTP service with a password 34 | * 35 | * @author Frederic Bregier 36 | * 37 | */ 38 | public class INTERNALSHUTDOWN extends AbstractCommand { 39 | /** 40 | * Internal Logger 41 | */ 42 | private static final WaarpLogger logger = WaarpLoggerFactory 43 | .getLogger(INTERNALSHUTDOWN.class); 44 | 45 | /** 46 | * 47 | * @author Frederic Bregier 48 | * 49 | */ 50 | private static class ShutdownChannelFutureListener implements 51 | ChannelFutureListener { 52 | 53 | private final FtpConfiguration configuration; 54 | 55 | protected ShutdownChannelFutureListener(FtpConfiguration configuration) { 56 | this.configuration = configuration; 57 | } 58 | 59 | public void operationComplete(ChannelFuture arg0) throws Exception { 60 | WaarpSslUtility.closingSslChannel(arg0.channel()); 61 | FtpChannelUtils.teminateServer(configuration); 62 | } 63 | 64 | } 65 | 66 | @Override 67 | public void exec() throws Reply501Exception, Reply500Exception { 68 | if (!getSession().getAuth().isAdmin()) { 69 | // not admin 70 | throw new Reply500Exception("Command Not Allowed"); 71 | } 72 | if (!hasArg()) { 73 | throw new Reply501Exception("Shutdown Need password"); 74 | } 75 | String password = getArg(); 76 | if (!getConfiguration().checkPassword(password)) { 77 | throw new Reply501Exception("Shutdown Need a correct password"); 78 | } 79 | logger.warn("Shutdown..."); 80 | getSession().setReplyCode( 81 | ReplyCode.REPLY_221_CLOSING_CONTROL_CONNECTION, 82 | "System shutdown"); 83 | getSession().getNetworkHandler().writeIntermediateAnswer().addListener( 84 | new ShutdownChannelFutureListener(getConfiguration())); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/IncorrectCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply503Exception; 22 | import org.waarp.common.logging.WaarpLogger; 23 | import org.waarp.common.logging.WaarpLoggerFactory; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.command.FtpCommandCode; 26 | import org.waarp.ftp.core.command.info.NOOP; 27 | 28 | /** 29 | * Incorrect command 30 | * 31 | * @author Frederic Bregier 32 | * 33 | */ 34 | public class IncorrectCommand extends AbstractCommand { 35 | /** 36 | * Internal Logger 37 | */ 38 | private static final WaarpLogger logger = WaarpLoggerFactory 39 | .getLogger(IncorrectCommand.class); 40 | 41 | @Override 42 | public void exec() throws Reply503Exception { 43 | getSession().setReplyCode( 44 | ReplyCode.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, 45 | "Bas sequence of commands: " + getCommand() + " following " + 46 | getSession().getPreviousCommand().getCommand()); 47 | logger.warn(getSession().getAnswer()); 48 | if (getSession().getPreviousCommand().getCode() != FtpCommandCode.Connection && 49 | getSession().getPreviousCommand().getCode() != FtpCommandCode.PASS && 50 | getSession().getPreviousCommand().getCode() != FtpCommandCode.USER) { 51 | getSession().setNextCommand(new NOOP(getSession())); 52 | } else { 53 | invalidCurrentCommand(); 54 | } 55 | throw new Reply503Exception(getSession().getReplyCode().getMesg()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/LIMITBANDWIDTH.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply500Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * Internal limit bandwidth command that will change the global limit bandwidth 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class LIMITBANDWIDTH extends AbstractCommand { 32 | @Override 33 | public void exec() throws Reply501Exception, Reply500Exception { 34 | if (!getSession().getAuth().isAdmin()) { 35 | // not admin 36 | throw new Reply500Exception("Command Not Allowed"); 37 | } 38 | if (!hasArg()) { 39 | // reset to default 40 | getConfiguration().changeNetworkLimit(0, 0); 41 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 42 | "Limit reset to default"); 43 | return; 44 | } 45 | String[] limits = getArgs(); 46 | long writeLimit = 0; 47 | long readLimit = 0; 48 | try { 49 | if (limits.length == 1) { 50 | writeLimit = Long.parseLong(limits[0]); 51 | readLimit = writeLimit; 52 | } else { 53 | writeLimit = Long.parseLong(limits[0]); 54 | readLimit = Long.parseLong(limits[1]); 55 | } 56 | } catch (NumberFormatException e) { 57 | throw new Reply501Exception(getCommand() + 58 | " ([write and read limits in b/s] | [write limit in b/s] [read limit in b/s]"); 59 | } 60 | getConfiguration().changeNetworkLimit(writeLimit, readLimit); 61 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 62 | "Limit set to new values"); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/UnimplementedCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply502Exception; 22 | import org.waarp.common.logging.WaarpLogger; 23 | import org.waarp.common.logging.WaarpLoggerFactory; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * Unimplemented command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public abstract class UnimplementedCommand extends AbstractCommand { 33 | /** 34 | * Internal Logger 35 | */ 36 | private static final WaarpLogger logger = WaarpLoggerFactory 37 | .getLogger(UnimplementedCommand.class); 38 | 39 | @Override 40 | public void exec() throws Reply502Exception { 41 | getSession().setReplyCode( 42 | ReplyCode.REPLY_502_COMMAND_NOT_IMPLEMENTED, 43 | "Unimplemented Command: " + getCommand() + " with argument: " + 44 | getArg()); 45 | logger.warn(getSession().getAnswer()); 46 | invalidCurrentCommand(); 47 | throw new Reply502Exception(getSession().getReplyCode().getMesg()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/UnknownCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.internal; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply500Exception; 22 | import org.waarp.common.logging.WaarpLogger; 23 | import org.waarp.common.logging.WaarpLoggerFactory; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * Unrecognized command (unknown command) 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class UnknownCommand extends AbstractCommand { 33 | /** 34 | * Internal Logger 35 | */ 36 | private static final WaarpLogger logger = WaarpLoggerFactory 37 | .getLogger(UnknownCommand.class); 38 | 39 | @Override 40 | public void exec() throws Reply500Exception { 41 | getSession().setReplyCode( 42 | ReplyCode.REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED, 43 | "Unknown Command: " + getCommand() + " with argument: " + 44 | getArg()); 45 | logger.warn(getSession().getAnswer()); 46 | invalidCurrentCommand(); 47 | throw new Reply500Exception(getSession().getReplyCode().getMesg()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Internal related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.internal; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Global classes that store all informations on implemented commands, arguments, reply codes. 3 | * 4 | * @apiviz.landmark 5 | */ 6 | package org.waarp.ftp.core.command; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/parameter/MODE.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.parameter; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply501Exception; 22 | import org.waarp.common.command.exception.Reply504Exception; 23 | import org.waarp.common.exception.InvalidArgumentException; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.command.FtpArgumentCode; 26 | 27 | /** 28 | * MODE command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class MODE extends AbstractCommand { 34 | @Override 35 | public void exec() throws Reply501Exception, Reply504Exception { 36 | // First Check if any argument 37 | if (!hasArg()) { 38 | // Default 39 | getSession().getDataConn().setMode( 40 | FtpArgumentCode.TransferMode.STREAM); 41 | getSession() 42 | .setReplyCode( 43 | ReplyCode.REPLY_200_COMMAND_OKAY, 44 | "Mode set to " + 45 | FtpArgumentCode.TransferMode.STREAM.name()); 46 | return; 47 | } 48 | FtpArgumentCode.TransferMode transferMode; 49 | try { 50 | transferMode = FtpArgumentCode.getTransferMode(getArg().charAt(0)); 51 | } catch (InvalidArgumentException e) { 52 | throw new Reply501Exception("Unrecognize Mode: " + getArg()); 53 | } 54 | if (transferMode == FtpArgumentCode.TransferMode.BLOCK) { 55 | getSession().getDataConn().setMode(transferMode); 56 | } else if (transferMode == FtpArgumentCode.TransferMode.STREAM) { 57 | getSession().getDataConn().setMode(transferMode); 58 | } else { 59 | throw new Reply504Exception("Mode not implemented: " + 60 | transferMode.name()); 61 | } 62 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 63 | "Mode set to " + transferMode.name()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/parameter/STRU.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.parameter; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.Reply501Exception; 22 | import org.waarp.common.command.exception.Reply504Exception; 23 | import org.waarp.common.exception.InvalidArgumentException; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.command.FtpArgumentCode; 26 | 27 | /** 28 | * STRU command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class STRU extends AbstractCommand { 34 | @Override 35 | public void exec() throws Reply501Exception, Reply504Exception { 36 | // First Check if any argument 37 | if (!hasArg()) { 38 | getSession().getDataConn().setStructure( 39 | FtpArgumentCode.TransferStructure.FILE); 40 | getSession().setReplyCode( 41 | ReplyCode.REPLY_200_COMMAND_OKAY, 42 | "Structure set to " + 43 | FtpArgumentCode.TransferStructure.FILE.name()); 44 | return; 45 | } 46 | FtpArgumentCode.TransferStructure transferStructure; 47 | try { 48 | transferStructure = FtpArgumentCode.getTransferStructure(getArg() 49 | .charAt(0)); 50 | } catch (InvalidArgumentException e) { 51 | throw new Reply501Exception("Unrecognize Structure: " + getArg()); 52 | } 53 | if (transferStructure == FtpArgumentCode.TransferStructure.FILE) { 54 | getSession().getDataConn().setStructure(transferStructure); 55 | } else if (transferStructure == FtpArgumentCode.TransferStructure.RECORD) { 56 | getSession().getDataConn().setStructure(transferStructure); 57 | } else { 58 | throw new Reply504Exception("Structure not implemented: " + 59 | transferStructure.name()); 60 | } 61 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 62 | "Structure set to " + transferStructure.name()); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/parameter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Parameter related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.parameter; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc2389/FEAT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc2389; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.ftp.core.command.AbstractCommand; 22 | 23 | /** 24 | * FEAT command 25 | * 26 | * @author Frederic Bregier 27 | * 28 | */ 29 | public class FEAT extends AbstractCommand { 30 | @Override 31 | public void exec() { 32 | getSession().setReplyCode(ReplyCode.REPLY_211_SYSTEM_STATUS_REPLY, 33 | getSession().getBusinessHandler().getFeatMessage()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc2389/OPTS.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc2389; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | 24 | /** 25 | * OPTS command 26 | * 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | public class OPTS extends AbstractCommand { 31 | @Override 32 | public void exec() throws CommandAbstractException { 33 | String message = getSession().getBusinessHandler().getOptsMessage( 34 | getArgs()); 35 | getSession().setReplyCode(ReplyCode.REPLY_214_HELP_MESSAGE, message); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc2389/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP RFC 2389 related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.rfc2389; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc2428/EPRT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc2428; 19 | 20 | import java.net.InetSocketAddress; 21 | 22 | import org.waarp.common.command.ReplyCode; 23 | import org.waarp.common.command.exception.Reply501Exception; 24 | import org.waarp.common.command.exception.Reply522Exception; 25 | import org.waarp.common.logging.WaarpLogger; 26 | import org.waarp.common.logging.WaarpLoggerFactory; 27 | import org.waarp.ftp.core.command.AbstractCommand; 28 | import org.waarp.ftp.core.utils.FtpChannelUtils; 29 | 30 | /** 31 | * EPRT command 32 | * 33 | * @author Frederic Bregier 34 | * 35 | */ 36 | public class EPRT extends AbstractCommand { 37 | private static final WaarpLogger logger = WaarpLoggerFactory.getInstance(EPRT.class); 38 | 39 | @Override 40 | public void exec() throws Reply501Exception, Reply522Exception { 41 | // First Check if any argument 42 | if (!hasArg()) { 43 | InetSocketAddress inetSocketAddress = getSession().getDataConn().getRemoteAddress(); 44 | logger.debug("Active connect to " + inetSocketAddress); 45 | getSession().getDataConn().setActive(inetSocketAddress); 46 | getSession().setReplyCode( 47 | ReplyCode.REPLY_200_COMMAND_OKAY, 48 | "EPRT command successful on (" + 49 | FtpChannelUtils.get2428Address(inetSocketAddress) + 50 | ")"); 51 | return; 52 | } 53 | // Check if Inet Address is OK 54 | 55 | InetSocketAddress inetSocketAddress = FtpChannelUtils.get2428InetSocketAddress(getArg()); 56 | if (inetSocketAddress == null) { 57 | // ERROR 58 | throw new Reply522Exception("Can't get SocketAddress from " + getArg()); 59 | } 60 | // No Check if the Client address is the same as given 61 | // OK now try to initialize connection (not open) 62 | logger.debug("Active connect to " + inetSocketAddress); 63 | getSession().getDataConn().setActive(inetSocketAddress); 64 | getSession() 65 | .setReplyCode( 66 | ReplyCode.REPLY_200_COMMAND_OKAY, 67 | "EPRT command successful on (" + 68 | FtpChannelUtils 69 | .get2428Address(inetSocketAddress) + 70 | ")"); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc2428/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP RFC 2428 related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.rfc2428; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc3659/MDTM.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc3659; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * MDTM command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class MDTM extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | // First Check if any argument 35 | if (!hasArg()) { 36 | throw new Reply501Exception("Need a path as argument"); 37 | } 38 | String arg = getArg(); 39 | String time = getSession().getDir().getModificationTime(arg); 40 | getSession().setReplyCode(ReplyCode.REPLY_213_FILE_STATUS, time); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc3659/MLSD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc3659; 19 | 20 | import java.util.List; 21 | 22 | import org.waarp.common.command.exception.CommandAbstractException; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * MLSD command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class MLSD extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | String path = null; 35 | if (!hasArg()) { 36 | path = getSession().getDir().getPwd(); 37 | } else { 38 | path = getArg(); 39 | } 40 | List filesInfo = getSession().getDir().listFull(path, false); 41 | getSession().openDataConnection(); 42 | getSession().getDataConn().getFtpTransferControl().setNewFtpTransfer( 43 | getCode(), filesInfo, path); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc3659/MLST.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc3659; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | 24 | /** 25 | * MLST command 26 | * 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | public class MLST extends AbstractCommand { 31 | @Override 32 | public void exec() throws CommandAbstractException { 33 | // First Check if any argument 34 | String path = null; 35 | if (!hasArg()) { 36 | path = getSession().getDir().getPwd(); 37 | } else { 38 | path = getArg(); 39 | } 40 | String message = getSession().getDir().fileFull(path, false); 41 | getSession().setReplyCode( 42 | ReplyCode.REPLY_226_CLOSING_DATA_CONNECTION, message); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc3659/SIZE.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc3659; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply550Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.file.FtpFile; 26 | 27 | /** 28 | * SIZE command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class SIZE extends AbstractCommand { 34 | @Override 35 | public void exec() throws CommandAbstractException { 36 | // First Check if any argument 37 | if (!hasArg()) { 38 | throw new Reply501Exception("Need a path as argument"); 39 | } 40 | String arg = getArg(); 41 | if (!getSession().getDir().isFile(arg)) { 42 | throw new Reply550Exception("Not a file " + arg); 43 | } 44 | FtpFile file = getSession().getDir().setFile(arg, false); 45 | long length = file.length(); 46 | getSession().setReplyCode(ReplyCode.REPLY_213_FILE_STATUS, "" + length); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc3659/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP RFC 3659 related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.rfc3659; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc4217/CCC.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc4217; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply500Exception; 23 | import org.waarp.common.command.exception.Reply534Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * CCC command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class CCC extends AbstractCommand { 33 | 34 | @Override 35 | public void exec() throws CommandAbstractException { 36 | if (!getSession().getConfiguration().getFtpInternalConfiguration().isAcceptAuthProt()) { 37 | throw new Reply534Exception("CCC not supported"); 38 | } 39 | if (!getSession().isSslReady()) { 40 | // Not SSL 41 | throw new Reply500Exception("Session already not using SSL / TLS"); 42 | } 43 | getSession().setSsl(false); 44 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 45 | null); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc4217/PBSZ.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc4217; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply503Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.command.FtpCommandCode; 26 | 27 | /** 28 | * PBSZ command accepting only 0 as parameter 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class PBSZ extends AbstractCommand { 34 | 35 | @Override 36 | public void exec() throws CommandAbstractException { 37 | if (!getSession().isSslReady()) { 38 | // Not SSL 39 | throw new Reply503Exception("Session not using SSL / TLS"); 40 | } 41 | // First Check if any argument 42 | if (!hasArg()) { 43 | // Error since argument is needed 44 | throw new Reply501Exception("Missing Parameter: 0"); 45 | } 46 | String[] types = getArgs(); 47 | if (!types[0].equalsIgnoreCase("0")) { 48 | // Only 0 allowed 49 | throw new Reply501Exception("Unknown Parameter: " + types[0]); 50 | } 51 | setExtraNextCommand(FtpCommandCode.PROT); 52 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 53 | null); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc4217/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | /** 19 | * RFC 4217 on securing FTP with TLS through commands 20 | * 21 | * @author "Frederic Bregier" 22 | * 23 | */ 24 | package org.waarp.ftp.core.command.rfc4217; -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/XCUP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc775; 19 | 20 | import org.waarp.ftp.core.command.directory.CDUP; 21 | 22 | /** 23 | * XCUP command 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class XCUP extends CDUP { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/XCWD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc775; 19 | 20 | import org.waarp.ftp.core.command.directory.CWD; 21 | 22 | /** 23 | * XCWD command 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class XCWD extends CWD { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/XMKD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc775; 19 | 20 | import org.waarp.ftp.core.command.service.MKD; 21 | 22 | /** 23 | * XMKD command 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class XMKD extends MKD { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/XPWD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc775; 19 | 20 | import org.waarp.ftp.core.command.service.PWD; 21 | 22 | /** 23 | * XPWD command 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class XPWD extends PWD { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/XRMD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.rfc775; 19 | 20 | import org.waarp.ftp.core.command.service.RMD; 21 | 22 | /** 23 | * XRMD command 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | public class XRMD extends RMD { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/rfc775/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP RFC 775 related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.rfc775; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/ABOR.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | import org.waarp.ftp.core.exception.FtpNoTransferException; 24 | 25 | /** 26 | * ABOR command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class ABOR extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | // First check if the data connection is opened 35 | if (getSession().getDataConn().isActive()) { 36 | // Now check if the data connection is currently used 37 | try { 38 | getSession().getDataConn().getFtpTransferControl() 39 | .getExecutingFtpTransfer(); 40 | } catch (FtpNoTransferException e) { 41 | getSession().getDataConn().getFtpTransferControl().clear(); 42 | getSession().setReplyCode( 43 | ReplyCode.REPLY_226_CLOSING_DATA_CONNECTION, null); 44 | return; 45 | } 46 | getSession().getDataConn().getFtpTransferControl() 47 | .setTransferAbortedFromInternal(false); 48 | return; 49 | } 50 | getSession().setReplyCode(ReplyCode.REPLY_226_CLOSING_DATA_CONNECTION, 51 | null); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/ALLO.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply452Exception; 23 | import org.waarp.common.command.exception.Reply501Exception; 24 | import org.waarp.common.exception.InvalidArgumentException; 25 | import org.waarp.ftp.core.command.AbstractCommand; 26 | 27 | /** 28 | * ALLO command: test if enough space is disponible 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class ALLO extends AbstractCommand { 34 | @Override 35 | public void exec() throws CommandAbstractException { 36 | // First Check if any argument 37 | if (!hasArg()) { 38 | throw new Reply501Exception("Need a size as argument"); 39 | } 40 | String[] args = getArgs(); 41 | int size = 0; 42 | try { 43 | size = getValue(args[0]); 44 | } catch (InvalidArgumentException e) { 45 | throw new Reply501Exception("Need a valid size as argument: " + 46 | args[0]); 47 | } 48 | long free = getSession().getDir().getFreeSpace(); 49 | if (free > 0 && free < size) { 50 | throw new Reply452Exception("Not enough space left"); 51 | } 52 | if (free == -1) { 53 | getSession().setReplyCode( 54 | ReplyCode.REPLY_202_COMMAND_NOT_IMPLEMENTED, null); 55 | } else { 56 | getSession().setReplyCode(ReplyCode.REPLY_200_COMMAND_OKAY, 57 | "ALLO OK: " + free + " bytes available"); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/APPE.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.command.exception.Reply450Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply553Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.file.FtpFile; 26 | import org.waarp.ftp.core.session.FtpSession; 27 | 28 | /** 29 | * APPE command 30 | * 31 | * @author Frederic Bregier 32 | * 33 | */ 34 | public class APPE extends AbstractCommand { 35 | @Override 36 | public void exec() throws CommandAbstractException { 37 | if (!hasArg()) { 38 | invalidCurrentCommand(); 39 | throw new Reply501Exception("Need a pathname as argument"); 40 | } 41 | String filename = FtpSession.getBasename(getArg()); 42 | FtpFile file = getSession().getDir().setFile(filename, true); 43 | if (file != null) { 44 | if (file.store()) { 45 | getSession().openDataConnection(); 46 | getSession().getDataConn().getFtpTransferControl() 47 | .setNewFtpTransfer(getCode(), file); 48 | return; 49 | } 50 | throw new Reply450Exception("Append operation not started"); 51 | } 52 | throw new Reply553Exception("Filename not allowed"); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/DELE.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply450Exception; 23 | import org.waarp.common.command.exception.Reply501Exception; 24 | import org.waarp.common.command.exception.Reply550Exception; 25 | import org.waarp.ftp.core.command.AbstractCommand; 26 | import org.waarp.ftp.core.file.FtpFile; 27 | 28 | /** 29 | * DELE command 30 | * 31 | * @author Frederic Bregier 32 | * 33 | */ 34 | public class DELE extends AbstractCommand { 35 | @Override 36 | public void exec() throws CommandAbstractException { 37 | if (!hasArg()) { 38 | invalidCurrentCommand(); 39 | throw new Reply501Exception("Need a pathname as argument"); 40 | } 41 | String filename = getArg(); 42 | FtpFile file = getSession().getDir().setFile(filename, false); 43 | if (file != null) { 44 | if (file.delete()) { 45 | getSession().setReplyCode( 46 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 47 | "\"" + file.getFile() + "\" FtpFile is deleted"); 48 | return; 49 | } 50 | throw new Reply450Exception("Delete operation not allowed"); 51 | } 52 | throw new Reply550Exception("Filename not allowed"); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/LIST.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import java.util.List; 21 | 22 | import org.waarp.common.command.exception.CommandAbstractException; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * LIST command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class LIST extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | String path = null; 35 | if (!hasArg()) { 36 | path = getSession().getDir().getPwd(); 37 | } else { 38 | path = getArg(); 39 | } 40 | List filesInfo = getSession().getDir().listFull(path, true); 41 | getSession().openDataConnection(); 42 | getSession().getDataConn().getFtpTransferControl().setNewFtpTransfer( 43 | getCode(), filesInfo, path); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/MKD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * MKD command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class MKD extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | // First Check if any argument 35 | if (!hasArg()) { 36 | throw new Reply501Exception("Need a path as argument"); 37 | } 38 | String path = getArg(); 39 | String newpath = getSession().getDir().mkdir(path); 40 | getSession().setReplyCode(ReplyCode.REPLY_257_PATHNAME_CREATED, 41 | "\"" + newpath + "\" is created"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/NLST.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import java.util.List; 21 | 22 | import org.waarp.common.command.exception.CommandAbstractException; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * NLST command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class NLST extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | String path = null; 35 | List files = null; 36 | if (!hasArg()) { 37 | path = getSession().getDir().getPwd(); 38 | files = getSession().getDir().list(path); 39 | } else { 40 | path = getArg(); 41 | if (path.startsWith("-l") || path.startsWith("-L")) { 42 | // This should be a LIST command 43 | String[] paths = getArgs(); 44 | if (paths.length > 1) { 45 | files = getSession().getDir().listFull(paths[1], true); 46 | } else { 47 | files = getSession().getDir().listFull( 48 | getSession().getDir().getPwd(), true); 49 | } 50 | } else { 51 | files = getSession().getDir().list(path); 52 | } 53 | } 54 | getSession().openDataConnection(); 55 | getSession().getDataConn().getFtpTransferControl().setNewFtpTransfer( 56 | getCode(), files, path); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/PWD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.ftp.core.command.AbstractCommand; 23 | 24 | /** 25 | * PWD command 26 | * 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | public class PWD extends AbstractCommand { 31 | @Override 32 | public void exec() throws CommandAbstractException { 33 | getSession().setReplyCode( 34 | ReplyCode.REPLY_257_PATHNAME_CREATED, 35 | "\"" + getSession().getDir().getPwd() + 36 | "\" is current directory"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/REST.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.ftp.core.command.AbstractCommand; 24 | 25 | /** 26 | * REST command 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class REST extends AbstractCommand { 32 | @Override 33 | public void exec() throws CommandAbstractException { 34 | if (!hasArg()) { 35 | invalidCurrentCommand(); 36 | throw new Reply501Exception("Need a Marker as argument"); 37 | } 38 | String marker = getArg(); 39 | if (getSession().getRestart().restartMarker(marker)) { 40 | getSession() 41 | .setReplyCode( 42 | ReplyCode.REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION, 43 | null); 44 | return; 45 | } 46 | // Marker in error 47 | throw new Reply501Exception("Marker is not allowed"); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/RETR.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.command.exception.Reply450Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply550Exception; 24 | import org.waarp.common.logging.WaarpLogger; 25 | import org.waarp.common.logging.WaarpLoggerFactory; 26 | import org.waarp.ftp.core.command.AbstractCommand; 27 | import org.waarp.ftp.core.file.FtpFile; 28 | 29 | /** 30 | * RETR command 31 | * 32 | * @author Frederic Bregier 33 | * 34 | */ 35 | public class RETR extends AbstractCommand { 36 | private static final WaarpLogger logger = WaarpLoggerFactory.getInstance(RETR.class); 37 | 38 | @Override 39 | public void exec() throws CommandAbstractException { 40 | if (!hasArg()) { 41 | invalidCurrentCommand(); 42 | throw new Reply501Exception("Need a pathname as argument"); 43 | } 44 | String filename = getArg(); 45 | FtpFile file = getSession().getDir().setFile(filename, false); 46 | if (file != null) { 47 | if (file.retrieve()) { 48 | getSession().openDataConnection(); 49 | getSession().getDataConn().getFtpTransferControl() 50 | .setNewFtpTransfer(getCode(), file); 51 | return; 52 | } 53 | logger.debug("File not accessible: " + file); 54 | // FtpFile does not exist 55 | throw new Reply450Exception("Retrieve operation not allowed"); 56 | } 57 | logger.debug("Filename not allowed: " + file); 58 | // FtpFile name not allowed 59 | throw new Reply550Exception("Filename not allowed"); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/RMD.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply550Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | 26 | /** 27 | * RMD command 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class RMD extends AbstractCommand { 33 | @Override 34 | public void exec() throws Reply550Exception, CommandAbstractException { 35 | // First Check if any argument 36 | if (!hasArg()) { 37 | throw new Reply501Exception("Need a path as argument"); 38 | } 39 | String path = getArg(); 40 | String pastdir = getSession().getDir().rmdir(path); 41 | getSession().setReplyCode( 42 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 43 | "\"" + pastdir + "\" is deleted"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/RNFR.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply550Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.file.FtpFile; 26 | 27 | /** 28 | * RNFR command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class RNFR extends AbstractCommand { 34 | @Override 35 | public void exec() throws CommandAbstractException { 36 | if (!hasArg()) { 37 | invalidCurrentCommand(); 38 | throw new Reply501Exception("Need a pathname as argument"); 39 | } 40 | String filename = getArg(); 41 | FtpFile file = getSession().getDir().setFile(filename, false); 42 | if (file != null && file.exists()) { 43 | getSession() 44 | .setReplyCode( 45 | ReplyCode.REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION, 46 | "Need RNTO command"); 47 | return; 48 | } 49 | // FtpFile name not allowed or not found 50 | throw new Reply550Exception("Filename not allowed"); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/RNTO.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.ReplyCode; 21 | import org.waarp.common.command.exception.CommandAbstractException; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply553Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.exception.FtpNoFileException; 26 | import org.waarp.ftp.core.exception.FtpNoTransferException; 27 | import org.waarp.ftp.core.file.FtpFile; 28 | 29 | /** 30 | * RNTO command 31 | * 32 | * @author Frederic Bregier 33 | * 34 | */ 35 | public class RNTO extends AbstractCommand { 36 | @Override 37 | public void exec() throws CommandAbstractException { 38 | if (!hasArg()) { 39 | invalidCurrentCommand(); 40 | throw new Reply501Exception("Need a pathname as argument"); 41 | } 42 | String filename = getArg(); 43 | FtpFile file = null; 44 | try { 45 | file = getSession().getDataConn().getFtpTransferControl() 46 | .getExecutingFtpTransfer().getFtpFile(); 47 | } catch (FtpNoFileException e) { 48 | } catch (FtpNoTransferException e) { 49 | } 50 | if (file != null) { 51 | String previousName = file.getFile(); 52 | if (file.renameTo(filename)) { 53 | getSession().setReplyCode( 54 | ReplyCode.REPLY_250_REQUESTED_FILE_ACTION_OKAY, 55 | "\"" + filename + "\" as new file name for \"" + 56 | previousName + "\""); 57 | return; 58 | } 59 | } 60 | // FtpFile name not allowed or not found 61 | throw new Reply553Exception("Filename not allowed"); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/STOR.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.command.exception.Reply450Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply553Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.file.FtpFile; 26 | import org.waarp.ftp.core.session.FtpSession; 27 | 28 | /** 29 | * STOR command 30 | * 31 | * @author Frederic Bregier 32 | * 33 | */ 34 | public class STOR extends AbstractCommand { 35 | @Override 36 | public void exec() throws CommandAbstractException { 37 | if (!hasArg()) { 38 | invalidCurrentCommand(); 39 | throw new Reply501Exception("Need a pathname as argument"); 40 | } 41 | String filename = FtpSession.getBasename(getArg()); 42 | FtpFile file = getSession().getDir().setFile(filename, false); 43 | if (file != null) { 44 | if (file.store()) { 45 | getSession().openDataConnection(); 46 | getSession().getDataConn().getFtpTransferControl() 47 | .setNewFtpTransfer(getCode(), file); 48 | return; 49 | } 50 | // Cannot find file 51 | throw new Reply450Exception("Store operation not allowed"); 52 | } 53 | // Filename not allowed 54 | throw new Reply553Exception("Filename not allowed"); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/STOU.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.command.service; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.command.exception.Reply450Exception; 22 | import org.waarp.common.command.exception.Reply501Exception; 23 | import org.waarp.common.command.exception.Reply553Exception; 24 | import org.waarp.ftp.core.command.AbstractCommand; 25 | import org.waarp.ftp.core.file.FtpFile; 26 | 27 | /** 28 | * STOU command 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class STOU extends AbstractCommand { 34 | @Override 35 | public void exec() throws CommandAbstractException { 36 | if (hasArg()) { 37 | invalidCurrentCommand(); 38 | throw new Reply501Exception("No argument is allowed"); 39 | } 40 | FtpFile file = getSession().getDir().setUniqueFile(); 41 | if (file != null) { 42 | if (file.store()) { 43 | getSession().openDataConnection(); 44 | getSession().getDataConn().getFtpTransferControl() 45 | .setNewFtpTransfer(getCode(), file); 46 | return; 47 | } 48 | // Cannot find file 49 | throw new Reply450Exception("Store unique operation not allowed"); 50 | } 51 | // Filename not allowed 52 | throw new Reply553Exception("Filename not allowed"); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/command/service/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * FTP Service (transfer) related command 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.core.command.service; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/config/FtpChannelTrafficShapingHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.config; 19 | 20 | import org.waarp.common.file.DataBlock; 21 | 22 | import io.netty.handler.traffic.ChannelTrafficShapingHandler; 23 | 24 | /** 25 | * Channel Traffic Shaping Handler for FTP 26 | * @author "Frederic Bregier" 27 | * 28 | */ 29 | public class FtpChannelTrafficShapingHandler extends ChannelTrafficShapingHandler { 30 | 31 | /** 32 | * @param checkInterval 33 | */ 34 | public FtpChannelTrafficShapingHandler(long checkInterval) { 35 | super(checkInterval); 36 | } 37 | 38 | /** 39 | * @param writeLimit 40 | * @param readLimit 41 | */ 42 | public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit) { 43 | super(writeLimit, readLimit); 44 | } 45 | 46 | /** 47 | * @param writeLimit 48 | * @param readLimit 49 | * @param checkInterval 50 | */ 51 | public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval) { 52 | super(writeLimit, readLimit, checkInterval); 53 | } 54 | 55 | /** 56 | * @param writeLimit 57 | * @param readLimit 58 | * @param checkInterval 59 | * @param maxTime 60 | */ 61 | public FtpChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval, long maxTime) { 62 | super(writeLimit, readLimit, checkInterval, maxTime); 63 | } 64 | 65 | @Override 66 | protected long calculateSize(Object msg) { 67 | if (msg instanceof DataBlock) { 68 | return ((DataBlock) msg).getByteCount(); 69 | } 70 | return super.calculateSize(msg); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/config/FtpGlobalTrafficShapingHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.config; 19 | 20 | import java.util.concurrent.ScheduledExecutorService; 21 | 22 | import org.waarp.common.file.DataBlock; 23 | 24 | import io.netty.handler.traffic.GlobalChannelTrafficShapingHandler; 25 | 26 | /** 27 | * Global Traffic Shaping Handler for FTP 28 | * @author "Frederic Bregier" 29 | * 30 | */ 31 | public class FtpGlobalTrafficShapingHandler extends GlobalChannelTrafficShapingHandler { 32 | 33 | public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit, 34 | long readGlobalLimit, long writeChannelLimit, long readChannelLimit, long checkInterval, long maxTime) { 35 | super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit, checkInterval, maxTime); 36 | } 37 | 38 | public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit, 39 | long readGlobalLimit, long writeChannelLimit, long readChannelLimit, long checkInterval) { 40 | super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit, checkInterval); 41 | } 42 | 43 | public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeGlobalLimit, 44 | long readGlobalLimit, long writeChannelLimit, long readChannelLimit) { 45 | super(executor, writeGlobalLimit, readGlobalLimit, writeChannelLimit, readChannelLimit); 46 | } 47 | 48 | public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor, long checkInterval) { 49 | super(executor, checkInterval); 50 | } 51 | 52 | public FtpGlobalTrafficShapingHandler(ScheduledExecutorService executor) { 53 | super(executor); 54 | } 55 | 56 | @Override 57 | protected long calculateSize(Object msg) { 58 | if (msg instanceof DataBlock) { 59 | return ((DataBlock) msg).getByteCount(); 60 | } 61 | return super.calculateSize(msg); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing configuration 3 | * 4 | * 5 | */ 6 | package org.waarp.ftp.core.config; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/FtpControlStringDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.control; 19 | 20 | import java.nio.charset.Charset; 21 | 22 | import io.netty.handler.codec.string.StringDecoder; 23 | 24 | /** 25 | * Exactly same as StringDecoder from Netty 26 | * 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | class FtpControlStringDecoder extends StringDecoder { 31 | /** 32 | * 33 | */ 34 | public FtpControlStringDecoder() { 35 | } 36 | 37 | /** 38 | * @see StringDecoder 39 | * @param arg0 40 | */ 41 | public FtpControlStringDecoder(String arg0) { 42 | super(Charset.forName(arg0)); 43 | } 44 | 45 | /** 46 | * @see StringDecoder 47 | * @param arg0 48 | */ 49 | public FtpControlStringDecoder(Charset arg0) { 50 | super(arg0); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/FtpControlStringEncoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.control; 19 | 20 | import java.nio.charset.Charset; 21 | 22 | import io.netty.handler.codec.string.StringEncoder; 23 | 24 | /** 25 | * Exactly same as StringEncoder from Netty 26 | * 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | class FtpControlStringEncoder extends StringEncoder { 31 | /** 32 | * 33 | */ 34 | public FtpControlStringEncoder() { 35 | } 36 | 37 | /** 38 | * @see StringEncoder 39 | * @param arg0 40 | */ 41 | public FtpControlStringEncoder(String arg0) { 42 | super(Charset.forName(arg0)); 43 | } 44 | 45 | /** 46 | * @see StringEncoder 47 | * @param arg0 48 | */ 49 | public FtpControlStringEncoder(Charset arg0) { 50 | super(arg0); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/ftps/FtpsInitializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of Waarp Project. 3 | 4 | Copyright 2009, Frederic Bregier, and individual contributors by the @author 5 | tags. See the COPYRIGHT.txt in the distribution for a full listing of 6 | individual contributors. 7 | 8 | All Waarp Project is free software: you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as published 10 | by the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Waarp is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Waarp . If not, see . 20 | */ 21 | package org.waarp.ftp.core.control.ftps; 22 | 23 | import io.netty.channel.ChannelPipeline; 24 | import io.netty.channel.socket.SocketChannel; 25 | import io.netty.handler.codec.DelimiterBasedFrameDecoder; 26 | import io.netty.handler.ssl.SslHandler; 27 | import io.netty.util.concurrent.EventExecutorGroup; 28 | 29 | import org.waarp.common.crypto.ssl.WaarpSecureKeyStore; 30 | import org.waarp.common.crypto.ssl.WaarpSslContextFactory; 31 | import org.waarp.ftp.core.config.FtpConfiguration; 32 | import org.waarp.ftp.core.control.BusinessHandler; 33 | import org.waarp.ftp.core.control.FtpInitializer; 34 | import org.waarp.ftp.core.session.FtpSession; 35 | 36 | /** 37 | * @author "Frederic Bregier" 38 | * 39 | */ 40 | public class FtpsInitializer extends FtpInitializer { 41 | 42 | public static WaarpSslContextFactory waarpSslContextFactory; 43 | public static WaarpSecureKeyStore waarpSecureKeyStore; 44 | 45 | /** 46 | * Constructor which Initializes some data for Server only 47 | * 48 | * @param businessHandler 49 | * @param configuration 50 | */ 51 | public FtpsInitializer(Class businessHandler, 52 | FtpConfiguration configuration) { 53 | super(businessHandler, configuration); 54 | } 55 | 56 | /** 57 | * Create the pipeline with Handler, ObjectDecoder, ObjectEncoder. 58 | * 59 | */ 60 | @Override 61 | public void initChannel(SocketChannel ch) throws Exception { 62 | ChannelPipeline pipeline = ch.pipeline(); 63 | // Server: no renegotiation still, but possible clientAuthent 64 | SslHandler handler = waarpSslContextFactory.initInitializer(true, 65 | waarpSslContextFactory.needClientAuthentication()); 66 | pipeline.addLast("SSL", handler); 67 | // Add the text line codec combination first, 68 | pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, delimiter)); 69 | pipeline.addLast("decoder", ftpControlStringDecoder); 70 | pipeline.addLast("encoder", ftpControlStringEncoder); 71 | // Threaded execution for business logic 72 | 73 | EventExecutorGroup executorGroup = configuration.getFtpInternalConfiguration().getExecutor(); 74 | // and then business logic. New one on every connection 75 | BusinessHandler newbusiness = businessHandler.newInstance(); 76 | SslNetworkHandler newNetworkHandler = new SslNetworkHandler(new FtpSession( 77 | configuration, newbusiness)); 78 | pipeline.addLast(executorGroup, "handler", newNetworkHandler); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/ftps/SslNetworkHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of Waarp Project. 3 | 4 | Copyright 2009, Frederic Bregier, and individual contributors by the @author 5 | tags. See the COPYRIGHT.txt in the distribution for a full listing of 6 | individual contributors. 7 | 8 | All Waarp Project is free software: you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as published 10 | by the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Waarp is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Waarp . If not, see . 20 | */ 21 | package org.waarp.ftp.core.control.ftps; 22 | 23 | import io.netty.channel.Channel; 24 | import io.netty.channel.ChannelHandlerContext; 25 | 26 | import org.waarp.common.crypto.ssl.WaarpSslUtility; 27 | import org.waarp.common.logging.WaarpLogger; 28 | import org.waarp.common.logging.WaarpLoggerFactory; 29 | import org.waarp.ftp.core.control.NetworkHandler; 30 | import org.waarp.ftp.core.session.FtpSession; 31 | 32 | /** 33 | * @author "Frederic Bregier" 34 | * 35 | */ 36 | public class SslNetworkHandler extends NetworkHandler { 37 | /** 38 | * Internal Logger 39 | */ 40 | private static final WaarpLogger logger = WaarpLoggerFactory.getLogger(SslNetworkHandler.class); 41 | 42 | /** 43 | * @param session 44 | */ 45 | public SslNetworkHandler(FtpSession session) { 46 | super(session); 47 | } 48 | 49 | @Override 50 | public void channelRegistered(ChannelHandlerContext ctx) throws Exception { 51 | Channel channel = ctx.channel(); 52 | logger.debug("Add channel to ssl " + channel.toString()); 53 | WaarpSslUtility.addSslOpenedChannel(channel); 54 | getFtpSession().prepareSsl(); 55 | super.channelRegistered(ctx); 56 | } 57 | 58 | /** 59 | * To be extended to inform of an error to SNMP support 60 | * 61 | * @param error1 62 | * @param error2 63 | */ 64 | protected void callForSnmp(String error1, String error2) { 65 | // ignore 66 | } 67 | 68 | @Override 69 | public void channelActive(final ChannelHandlerContext ctx) throws Exception { 70 | if (!WaarpSslUtility.waitForHandshake(ctx.channel())) { 71 | callForSnmp("SSL Connection Error", "During Ssl Handshake"); 72 | getFtpSession().setSsl(false); 73 | return; 74 | } else { 75 | getFtpSession().setSsl(true); 76 | } 77 | super.channelActive(ctx); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/ftps/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | /** 19 | * This module is for FTPS support as native SSL/TLS on port 990 similar to RFC 2818. 20 | * 21 | * @author "Frederic Bregier" 22 | * 23 | */ 24 | package org.waarp.ftp.core.control.ftps; -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/control/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing Control connections. 3 | * 4 | *
5 | *
6 | * The internal logic is the following:
7 | *
    8 | *
  • When a connection is opened for control network:
  • 9 | * It first creates the default startup command (ConnectionCommand), then it answers it is ok to 10 | * accept identification (which is implied by ConnectionCommand). 11 | *
  • Each time a command is received:
  • 12 | *
      13 | *
    • Parsing the command
    • in order to find the corresponding class that implements it. 14 | *
    • Checking if the command is legal now
    • such that no transfer is currently running except 15 | * if is a special command (like QUIT or ABORT). 16 | *
    • Checking if the command is legal from workflow
    • that is to say the previous command 17 | * allows the usage of the current command (for instance, no transfer command is allowed if the 18 | * authentication is not finished). 19 | *
    • Running the command
    • with executing a pre and post operation on business handler. 20 | *
    • Making the final answer of the command
    • (in some cases this is a partial answer like 21 | * ready to transfer) 22 | *
    23 | *
  • When an exception occurs
  • the connection will be closed.
  • When the connection is 24 | * closed
  • all attributes are cleaned.
25 | * 26 | * @apiviz.landmark 27 | */ 28 | package org.waarp.ftp.core.control; 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/data/handler/FtpSeekAheadData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.data.handler; 19 | 20 | import io.netty.buffer.ByteBuf; 21 | 22 | /** 23 | * SeekAheadData Class used to optimize access to the incoming buffer 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | class FtpSeekAheadData { 29 | /** 30 | * Exception when NO Backend Array is found 31 | */ 32 | static class SeekAheadNoBackArrayException extends Exception { 33 | private static final long serialVersionUID = -630418804938699495L; 34 | } 35 | 36 | byte[] bytes; 37 | 38 | int readerIndex; 39 | 40 | int pos; 41 | 42 | int limit; 43 | 44 | ByteBuf buffer; 45 | 46 | /** 47 | * @param buffer 48 | */ 49 | FtpSeekAheadData(ByteBuf buffer) throws SeekAheadNoBackArrayException { 50 | if (!buffer.hasArray()) { 51 | throw new SeekAheadNoBackArrayException(); 52 | } 53 | this.buffer = buffer; 54 | this.bytes = buffer.array(); 55 | this.pos = this.readerIndex = buffer.arrayOffset() + buffer.readerIndex(); 56 | this.limit = buffer.arrayOffset() + buffer.writerIndex(); 57 | } 58 | 59 | /** 60 | * 61 | * @param minus 62 | * this value will be used as (currentPos - minus) to set the current readerIndex in 63 | * the buffer. 64 | */ 65 | void setReadPosition(int minus) { 66 | pos -= minus; 67 | readerIndex = pos; 68 | buffer.readerIndex(readerIndex); 69 | } 70 | 71 | void clear() { 72 | this.buffer = null; 73 | this.bytes = null; 74 | this.limit = 0; 75 | this.pos = 0; 76 | this.readerIndex = 0; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/data/handler/ftps/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | /** 19 | * This module is for FTPS support as native SSL/TLS on port 989 similar to RFC 2818. 20 | * 21 | * @author "Frederic Bregier" 22 | * 23 | */ 24 | package org.waarp.ftp.core.data.handler.ftps; -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/data/handler/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing Data connections 3 | * 4 | *
5 | *
6 | * The internal logic is the following:
7 | *
    8 | *
  • When a connection is opened for data network:
  • 9 | * It first tries to find the corresponding session setup from the control connection. Then it 10 | * setups the FTP codec. Finally it informs the FtpTransferControl object that the data connection 11 | * is opened and ready, such that the transfer can start correctly. 12 | *
  • Each time a block is received:
  • 13 | * the DataBlock is written into the corresponding FtpFile according to the status. 14 | *
  • If the operation is a retrieve
  • it writes the file to the data channel (from 15 | * FtpTransferControl) and wake up the process of writing from channelInterestChanged in order to 16 | * prevent OOME. 17 | *
  • When an exception occurs
  • the data connection will be closed so as the current transfer 18 | * action through the FtpTransferControl Object. 19 | *
  • When the connection is closed
  • the process tries to unbind if necessary the parent 20 | * connection (no more connections will use this binded address) and then cleans all attributes. 21 | *
22 | * 23 | * @apiviz.landmark 24 | */ 25 | package org.waarp.ftp.core.data.handler; 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/data/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing Data and Transfer status 3 | * 4 | *
5 | *
6 | * When a transfer should occur, here are the steps:
7 | *
    8 | *
  • The connection is prepared
  • through a PORT or PASV command. The PASV command implies the 9 | * creation of a new binded address (connection from the client to the server for PASSIVE mode) (or 10 | * to reuse an already opened binded address). Then it stores the session that will be used by this 11 | * new data session.
    12 | * The PORT command implies the preparation of the future data connection from the server to the 13 | * client (ACTIVE mode). In this mode, the session does not need to be setup before since it will be 14 | * setup before the real connection process.
    15 | * In both commands, if a previously data connection is already opened, it is closed before any new 16 | * startup. 17 | *
  • The transfer command is received
  • and is followed by several steps: 18 | *
      19 | *
    • First it prepares the FtpFile object
    • 20 | *
    • It opens the data connection
    • . Two possibilities:
      21 | * 1) PASSIVE mode where the server waits for the client to initiate the real connection.
      22 | * 2) ACTIVE mode where the server will initiate the data connection.
      23 | * The DataNetworkHandler will inform back the FtpTransferControl that the connection is ready. Then 24 | * the FtpDataAsyncConn is also informed of this status. 25 | *
    • The transfer is initiated
    • by calling setNewFtpTransfer method of the FtpTransferControl 26 | * object. This starts a new thread (FtpTransferExecutor) to execute the transfer.
      27 | * For STORE like operations, it waits for the end of the transfer from the data network handler 28 | * (when the last block is received or the data connection is over).
      29 | * For LIST like commands, it immediately sends the result as wanted.
      30 | * For RETRIEVE like commands, it starts the sending of the file (trueRetrieve method of the FtpFile 31 | * object).
      32 | * For STORE and RETRIEVE cases, it is waiting for the FtpTransferControl to inform back that 33 | * everything is really over (waitForCommand). For each cases, when it is over, it informs back the 34 | * FtpTransferControl the transfer is finished (setEndOfTransfer method). This enables to send early 35 | * end message (success or error) and also final message (again success or error) after a check is 36 | * completed.
      37 | *
    38 | * When the transfer command is received, it does not wait for the real transfer to be done (since 39 | * it is done in a new thread), so to allow an immediate feedback as a partial success status as 40 | * specified in the RFCs.
41 | * 42 | * @apiviz.landmark 43 | */ 44 | package org.waarp.ftp.core.data; 45 | 46 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/exception/FtpNoConnectionException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.exception; 19 | 20 | /** 21 | * No Connection exception 22 | * 23 | * @author Frederic Bregier 24 | * 25 | */ 26 | public class FtpNoConnectionException extends Exception { 27 | 28 | /** 29 | * 30 | */ 31 | private static final long serialVersionUID = 4067644127312790263L; 32 | 33 | /** 34 | * @param message 35 | */ 36 | public FtpNoConnectionException(String message) { 37 | super(message); 38 | } 39 | 40 | /** 41 | * @param message 42 | * @param cause 43 | */ 44 | public FtpNoConnectionException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/exception/FtpNoFileException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.exception; 19 | 20 | /** 21 | * No file exception 22 | * 23 | * @author Frederic Bregier 24 | * 25 | */ 26 | public class FtpNoFileException extends Exception { 27 | 28 | /** 29 | * 30 | */ 31 | private static final long serialVersionUID = -763134102928044471L; 32 | 33 | /** 34 | * @param message 35 | */ 36 | public FtpNoFileException(String message) { 37 | super(message); 38 | } 39 | 40 | /** 41 | * @param message 42 | * @param cause 43 | */ 44 | public FtpNoFileException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/exception/FtpNoTransferException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.exception; 19 | 20 | /** 21 | * No transfer exception 22 | * 23 | * @author Frederic Bregier 24 | * 25 | */ 26 | public class FtpNoTransferException extends Exception { 27 | 28 | /** 29 | * 30 | */ 31 | private static final long serialVersionUID = 977343700748516315L; 32 | 33 | /** 34 | * @param message 35 | */ 36 | public FtpNoTransferException(String message) { 37 | super(message); 38 | } 39 | 40 | /** 41 | * @param message 42 | * @param cause 43 | */ 44 | public FtpNoTransferException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/exception/FtpUnknownFieldException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.exception; 19 | 20 | /** 21 | * Unknown Field exception 22 | * 23 | * @author Frederic Bregier 24 | * 25 | */ 26 | public class FtpUnknownFieldException extends Exception { 27 | /** 28 | * serialVersionUID of long: 29 | */ 30 | private static final long serialVersionUID = 6752182711992342555L; 31 | 32 | /** 33 | * @param message 34 | */ 35 | public FtpUnknownFieldException(String message) { 36 | super(message); 37 | } 38 | 39 | /** 40 | * @param message 41 | * @param cause 42 | */ 43 | public FtpUnknownFieldException(String message, Throwable cause) { 44 | super(message, cause); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing internal exceptions 3 | * 4 | * 5 | */ 6 | package org.waarp.ftp.core.exception; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/file/FtpAuth.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.file; 19 | 20 | import org.waarp.common.command.NextCommandReply; 21 | import org.waarp.common.command.exception.Reply421Exception; 22 | import org.waarp.common.command.exception.Reply502Exception; 23 | import org.waarp.common.command.exception.Reply530Exception; 24 | import org.waarp.common.file.AuthInterface; 25 | 26 | /** 27 | * @author Frederic Bregier 28 | * 29 | */ 30 | public interface FtpAuth extends AuthInterface { 31 | 32 | /** 33 | * @return the account 34 | */ 35 | public String getAccount(); 36 | 37 | /** 38 | * @param account 39 | * the account to set 40 | * @return (NOOP,230) if the Account is OK, else return the following command that must follow 41 | * and the associated reply 42 | * @throws Reply421Exception 43 | * if there is a problem during the authentication 44 | * @throws Reply530Exception 45 | * if there is a problem during the authentication 46 | * @throws Reply502Exception 47 | */ 48 | public NextCommandReply setAccount(String account) 49 | throws Reply421Exception, Reply530Exception, Reply502Exception; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/file/FtpDir.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.file; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.file.DirInterface; 22 | 23 | /** 24 | * @author Frederic Bregier 25 | * 26 | */ 27 | public interface FtpDir extends DirInterface { 28 | /** 29 | * Create a new FtpFile 30 | * 31 | * @param path 32 | * @param append 33 | * @return the new Ftp FileInterface 34 | * @throws CommandAbstractException 35 | */ 36 | public abstract FtpFile newFile(String path, boolean append) 37 | throws CommandAbstractException; 38 | 39 | /** 40 | * Set a path as the current FileInterface 41 | * 42 | * @param path 43 | * @param append 44 | * True if this file is supposed to be in append mode (APPE), False in any other 45 | * cases 46 | * @return the Ftp FileInterface if it is correctly initiate 47 | * @throws CommandAbstractException 48 | */ 49 | public abstract FtpFile setFile(String path, boolean append) 50 | throws CommandAbstractException; 51 | 52 | /** 53 | * Set a new unique path as the current FileInterface from the current Directory (STOU) 54 | * 55 | * @return the Ftp FileInterface if it is correctly initiate 56 | * @throws CommandAbstractException 57 | */ 58 | public abstract FtpFile setUniqueFile() 59 | throws CommandAbstractException; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/file/FtpFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.file; 19 | 20 | import org.waarp.common.file.FileInterface; 21 | 22 | /** 23 | * @author Frederic Bregier 24 | * 25 | */ 26 | public interface FtpFile extends FileInterface { 27 | 28 | /** 29 | * Launch retrieve operation (internal method, should not be called directly) 30 | * 31 | */ 32 | public void trueRetrieve(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/file/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Interfaces for FtpFile, FtpDir and FtpAuth as specific FTP extension of interfaces FileInterface, 3 | * DirInterface and AuthInterface 4 | * 5 | * @apiviz.landmark 6 | */ 7 | package org.waarp.ftp.core.file; 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/session/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing session 3 | * 4 | * @apiviz.landmark 5 | */ 6 | package org.waarp.ftp.core.session; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/utils/FtpShutdownHook.java: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of Waarp Project. 3 | 4 | Copyright 2009, Frederic Bregier, and individual contributors by the @author 5 | tags. See the COPYRIGHT.txt in the distribution for a full listing of 6 | individual contributors. 7 | 8 | All Waarp Project is free software: you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as published 10 | by the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Waarp is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Waarp . If not, see . 20 | */ 21 | package org.waarp.ftp.core.utils; 22 | 23 | import org.waarp.common.utility.WaarpShutdownHook; 24 | import org.waarp.ftp.core.config.FtpConfiguration; 25 | 26 | /** 27 | * @author "Frederic Bregier" 28 | * 29 | */ 30 | public class FtpShutdownHook extends WaarpShutdownHook { 31 | 32 | protected static FtpConfiguration configuration; 33 | 34 | /** 35 | * @param configuration 36 | */ 37 | public FtpShutdownHook(ShutdownConfiguration configuration, FtpConfiguration ftpconfiguration) { 38 | super(configuration); 39 | FtpShutdownHook.configuration = ftpconfiguration; 40 | } 41 | 42 | @Override 43 | protected void exit() { 44 | FtpChannelUtils.exit(FtpShutdownHook.configuration); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/utils/FtpTimerTask.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.core.utils; 19 | 20 | import java.util.TimerTask; 21 | 22 | import org.waarp.common.logging.WaarpLogger; 23 | import org.waarp.common.logging.WaarpLoggerFactory; 24 | import org.waarp.ftp.core.config.FtpConfiguration; 25 | 26 | /** 27 | * Timer Task used mainly when the server is going to shutdown in order to be sure the program exit. 28 | * 29 | * @author Frederic Bregier 30 | * 31 | */ 32 | public class FtpTimerTask extends TimerTask { 33 | /** 34 | * Internal Logger 35 | */ 36 | private static final WaarpLogger logger = WaarpLoggerFactory 37 | .getLogger(FtpTimerTask.class); 38 | 39 | /** 40 | * EXIT type (System.exit(1)) 41 | */ 42 | public static final int TIMER_EXIT = 1; 43 | /** 44 | * Finalize Control connection 45 | */ 46 | public static final int TIMER_CONTROL = 2; 47 | 48 | /** 49 | * Type of execution in run() method 50 | */ 51 | private final int type; 52 | /** 53 | * Configuration 54 | */ 55 | private FtpConfiguration configuration = null; 56 | 57 | /** 58 | * Constructor from type 59 | * 60 | * @param type 61 | */ 62 | public FtpTimerTask(int type) { 63 | super(); 64 | this.type = type; 65 | } 66 | 67 | @Override 68 | public void run() { 69 | switch (type) { 70 | case TIMER_EXIT: 71 | logger.error("System will force EXIT"); 72 | System.exit(0); 73 | break; 74 | case TIMER_CONTROL: 75 | logger.info("Exit Shutdown Command"); 76 | FtpChannelUtils.terminateCommandChannels(getConfiguration()); 77 | logger.warn("Exit end of Command Shutdown"); 78 | //FtpChannelUtils.stopLogger(); 79 | break; 80 | default: 81 | logger.info("Type unknown in TimerTask"); 82 | } 83 | } 84 | 85 | /** 86 | * @return the configuration 87 | */ 88 | public FtpConfiguration getConfiguration() { 89 | return configuration; 90 | } 91 | 92 | /** 93 | * @param configuration the configuration to set 94 | */ 95 | public void setConfiguration(FtpConfiguration configuration) { 96 | this.configuration = configuration; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/core/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing utilities functions 3 | * 4 | * 5 | */ 6 | package org.waarp.ftp.core.utils; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/filesystembased/FilesystemBasedFtpDir.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.filesystembased; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.file.filesystembased.FilesystemBasedDirImpl; 22 | import org.waarp.common.file.filesystembased.FilesystemBasedOptsMLSxImpl; 23 | import org.waarp.ftp.core.file.FtpDir; 24 | import org.waarp.ftp.core.file.FtpFile; 25 | import org.waarp.ftp.core.session.FtpSession; 26 | 27 | /** 28 | * Filesystem implementation of a FtpDir 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public abstract class FilesystemBasedFtpDir extends FilesystemBasedDirImpl implements FtpDir { 34 | /** 35 | * 36 | * @param session 37 | */ 38 | public FilesystemBasedFtpDir(FtpSession session) { 39 | super(session, new FilesystemBasedOptsMLSxImpl()); 40 | } 41 | 42 | public FtpFile setUniqueFile() 43 | throws CommandAbstractException { 44 | return (FtpFile) super.setUniqueFile(); 45 | } 46 | 47 | public FtpFile setFile(String path, 48 | boolean append) throws CommandAbstractException { 49 | return (FtpFile) super.setFile(path, append); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/filesystembased/FilesystemBasedFtpRestart.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.filesystembased; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.common.command.exception.Reply502Exception; 22 | import org.waarp.common.file.filesystembased.FilesystemBasedRestartImpl; 23 | import org.waarp.ftp.core.command.FtpArgumentCode.TransferMode; 24 | import org.waarp.ftp.core.command.FtpArgumentCode.TransferStructure; 25 | import org.waarp.ftp.core.command.FtpArgumentCode.TransferType; 26 | import org.waarp.ftp.core.data.FtpDataAsyncConn; 27 | import org.waarp.ftp.core.session.FtpSession; 28 | 29 | /** 30 | * Filesystem implementation of a Restart.
31 | * Only FILE+STREAM is supported (byte position in file). 32 | * 33 | * @author Frederic Bregier 34 | * 35 | */ 36 | public class FilesystemBasedFtpRestart extends FilesystemBasedRestartImpl { 37 | /** 38 | * @param session 39 | */ 40 | public FilesystemBasedFtpRestart(FtpSession session) { 41 | super(session); 42 | } 43 | 44 | @Override 45 | public boolean restartMarker(String marker) throws CommandAbstractException { 46 | FtpDataAsyncConn dataConn = ((FtpSession) getSession()).getDataConn(); 47 | if (dataConn.getStructure() == TransferStructure.FILE && 48 | dataConn.getMode() == TransferMode.STREAM && 49 | dataConn.getType() != TransferType.LENGTH) { 50 | long newposition = 0; 51 | String[] args = marker.split(" "); 52 | try { 53 | newposition = Long.parseLong(args[0]); 54 | if (args.length > 1) { 55 | limit = Integer.parseInt(args[1]); 56 | } 57 | } catch (NumberFormatException e) { 58 | throw new Reply502Exception( 59 | "Marker must be length in byte as a position"); 60 | } 61 | position = newposition; 62 | setSet(true); 63 | return true; 64 | } 65 | throw new Reply502Exception( 66 | "Marker not implemented for such Mode, Type and Structure"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/filesystembased/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes implementing File, Directory and Authentication according to a filesystem implementation 3 | * for FTP 4 | * 5 | * @apiviz.landmark 6 | */ 7 | package org.waarp.ftp.filesystembased; 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | /** 19 | * @author "Frederic Bregier" 20 | * 21 | */ 22 | package org.waarp.ftp; -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/SimpleGatewayFtpServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.simpleimpl; 19 | 20 | import org.waarp.common.file.filesystembased.FilesystemBasedFileParameterImpl; 21 | import org.waarp.common.logging.WaarpLogger; 22 | import org.waarp.common.logging.WaarpLoggerFactory; 23 | import org.waarp.common.logging.WaarpSlf4JLoggerFactory; 24 | import org.waarp.ftp.core.exception.FtpNoConnectionException; 25 | import org.waarp.ftp.simpleimpl.config.FileBasedConfiguration; 26 | import org.waarp.ftp.simpleimpl.control.SimpleBusinessHandler; 27 | import org.waarp.ftp.simpleimpl.data.FileSystemBasedDataBusinessHandler; 28 | 29 | /** 30 | * Example of FTP Server using simple authentication (XML FileInterface based), and standard 31 | * Directory and FileInterface implementation (Filesystem based). 32 | * 33 | * @author Frederic Bregier 34 | * 35 | */ 36 | public class SimpleGatewayFtpServer { 37 | /** 38 | * Internal Logger 39 | */ 40 | private static WaarpLogger logger = null; 41 | 42 | /** 43 | * Take a simple XML file as configuration. 44 | * 45 | * @param args 46 | */ 47 | public static void main(String[] args) { 48 | if (args.length != 1) { 49 | System.err.println("Usage: " + 50 | SimpleGatewayFtpServer.class.getName() + " "); 51 | return; 52 | } 53 | WaarpLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(null)); 54 | logger = WaarpLoggerFactory.getLogger(SimpleGatewayFtpServer.class); 55 | String config = args[0]; 56 | FileBasedConfiguration configuration = new FileBasedConfiguration( 57 | SimpleGatewayFtpServer.class, SimpleBusinessHandler.class, 58 | FileSystemBasedDataBusinessHandler.class, 59 | new FilesystemBasedFileParameterImpl()); 60 | if (!configuration.setConfigurationFromXml(config)) { 61 | System.err.println("Bad configuration"); 62 | return; 63 | } 64 | // Start server. 65 | try { 66 | configuration.serverStartup(); 67 | } catch (FtpNoConnectionException e) { 68 | logger.error("FTP not started", e); 69 | } 70 | logger.info("FTP started"); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/config/CircularIntValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.simpleimpl.config; 19 | 20 | import java.util.concurrent.atomic.AtomicInteger; 21 | 22 | /** 23 | * Circular Value used by passive connections to find the next valid port to propose to the client. 24 | * 25 | * @author Frederic Bregier 26 | * 27 | */ 28 | class CircularIntValue { 29 | /** 30 | * Min value 31 | */ 32 | private final int min; 33 | 34 | /** 35 | * Max value 36 | */ 37 | private final int max; 38 | 39 | /** 40 | * Current Value 41 | */ 42 | private AtomicInteger current; 43 | 44 | /** 45 | * Create a circular range of values 46 | * 47 | * @param min 48 | * @param max 49 | */ 50 | public CircularIntValue(int min, int max) { 51 | this.min = min; 52 | this.max = max; 53 | current = new AtomicInteger(this.min - 1); 54 | } 55 | 56 | /** 57 | * Get the next value 58 | * 59 | * @return the next value 60 | */ 61 | public int getNext() { 62 | synchronized (current) { 63 | if (!current.compareAndSet(max, min)) { 64 | current.incrementAndGet(); 65 | } 66 | return current.get(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple configuration example. 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.simpleimpl.config; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/control/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple FTP server example of control business. 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.simpleimpl.control; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/data/FileSystemBasedDataBusinessHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.simpleimpl.data; 19 | 20 | import io.netty.channel.Channel; 21 | import org.waarp.common.logging.WaarpLogger; 22 | import org.waarp.common.logging.WaarpLoggerFactory; 23 | import org.waarp.ftp.core.data.handler.DataBusinessHandler; 24 | 25 | /** 26 | * DataBusinessHandler implementation based on Simple Filesystem 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class FileSystemBasedDataBusinessHandler extends DataBusinessHandler { 32 | /** 33 | * Internal Logger 34 | */ 35 | private static final WaarpLogger logger = WaarpLoggerFactory 36 | .getLogger(FileSystemBasedDataBusinessHandler.class); 37 | 38 | @Override 39 | protected void cleanSession() { 40 | // logger.debug("FSDBH Clean session"); 41 | } 42 | 43 | @Override 44 | public void exceptionLocalCaught(Throwable e) { 45 | logger.warn("FSDBH Execption", e); 46 | } 47 | 48 | @Override 49 | public void executeChannelClosed() { 50 | // logger.debug("FSDBH Channel closed"); 51 | } 52 | 53 | @Override 54 | public void executeChannelConnected(Channel channel) { 55 | // logger.debug("FSDBH Channel connected {}", channel); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/data/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple FTP server example of data business. 3 | * 4 | * @apiviz.exclude 5 | */ 6 | package org.waarp.ftp.simpleimpl.data; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/file/FileBasedDir.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.simpleimpl.file; 19 | 20 | import org.waarp.common.command.exception.CommandAbstractException; 21 | import org.waarp.ftp.core.file.FtpFile; 22 | import org.waarp.ftp.core.session.FtpSession; 23 | import org.waarp.ftp.filesystembased.FilesystemBasedFtpDir; 24 | 25 | /** 26 | * FtpFile implementation based on true directories and files 27 | * 28 | * @author Frederic Bregier 29 | * 30 | */ 31 | public class FileBasedDir extends FilesystemBasedFtpDir { 32 | /** 33 | * @param session 34 | */ 35 | public FileBasedDir(FtpSession session) { 36 | super(session); 37 | } 38 | 39 | public FtpFile newFile(String path, boolean append) 40 | throws CommandAbstractException { 41 | return new FileBasedFile((FtpSession) getSession(), this, path, append); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/file/FileBasedFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Waarp Project. 3 | * 4 | * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the 5 | * COPYRIGHT.txt in the distribution for a full listing of individual contributors. 6 | * 7 | * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of 8 | * the GNU General Public License as published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 13 | * Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with Waarp . If not, see 16 | * . 17 | */ 18 | package org.waarp.ftp.simpleimpl.file; 19 | 20 | import java.io.File; 21 | 22 | import org.waarp.common.command.exception.CommandAbstractException; 23 | import org.waarp.ftp.core.file.FtpFile; 24 | import org.waarp.ftp.core.session.FtpSession; 25 | import org.waarp.ftp.filesystembased.FilesystemBasedFtpFile; 26 | 27 | /** 28 | * FtpFile implementation based on true directories and files 29 | * 30 | * @author Frederic Bregier 31 | * 32 | */ 33 | public class FileBasedFile extends FilesystemBasedFtpFile { 34 | /** 35 | * @param session 36 | * @param fileBasedDir 37 | * It is not necessary the directory that owns this file. 38 | * @param path 39 | * @param append 40 | * @throws CommandAbstractException 41 | */ 42 | public FileBasedFile(FtpSession session, FileBasedDir fileBasedDir, 43 | String path, boolean append) throws CommandAbstractException { 44 | super(session, fileBasedDir, path, append); 45 | } 46 | 47 | /** 48 | * This method is a good to have in a true {@link FtpFile} implementation. 49 | * 50 | * @return the File associated with the current FtpFile operation 51 | */ 52 | public File getTrueFile() { 53 | try { 54 | return getFileFromPath(getFile()); 55 | } catch (CommandAbstractException e) { 56 | return null; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/file/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Filesystem based implementation example of File, Dir, Auth and SimpleAuth. 3 | * 4 | * 5 | */ 6 | package org.waarp.ftp.simpleimpl.file; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/waarp/ftp/simpleimpl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Main class for the simple FTP server example based on Filesystem and simple authentication. 3 | * 4 | * @apiviz.landmark 5 | */ 6 | package org.waarp.ftp.simpleimpl; 7 | 8 | -------------------------------------------------------------------------------- /src/site/resources/html/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | Reload to Waarp Ftp main page 3 | 4 | 5 | 6 | If your browser does not reload, please follow this link... 7 | 8 | -------------------------------------------------------------------------------- /src/site/resources/html/filesystem/index.html: -------------------------------------------------------------------------------- 1 | 2 | Reload to Waarp Ftp main page 3 | 4 | 5 | 6 | If your browser does not reload, please follow this link... 7 | 8 | -------------------------------------------------------------------------------- /src/site/resources/html/simpleimpl/index.html: -------------------------------------------------------------------------------- 1 | 2 | Reload to Waarp Ftp main page 3 | 4 | 5 | 6 | If your browser does not reload, please follow this link... 7 | 8 | -------------------------------------------------------------------------------- /src/site/resources/images/bench-100vu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/bench-100vu.png -------------------------------------------------------------------------------- /src/site/resources/images/bench-10K.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/bench-10K.png -------------------------------------------------------------------------------- /src/site/resources/images/bench-1K.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/bench-1K.png -------------------------------------------------------------------------------- /src/site/resources/images/connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/connections.png -------------------------------------------------------------------------------- /src/site/resources/images/waarp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/waarp.gif -------------------------------------------------------------------------------- /src/site/resources/images/waarp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waarp/WaarpFtp/925606ee067e4790e9c3a0ba8df6a0cb25aeeb5f/src/site/resources/images/waarp.jpg -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.apache.maven/skins 5 | maven-default-skin 6 | 1.0 7 | 8 | 9 | 10 | Waarp Project 11 | images/waarp.jpg 12 | http://www.waarp.it 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------