All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kmy.net.ftpd.FTPDConnection

kmy.net.ftpd.FTPDConnection

public class FTPDConnection
Class FTPDConnection encapsulates a single FTP connection to the server. This class is running while connection is open. It processes FTP commands as they are received from the client. The main trick that most commands are translated to the calls to the corresponding methods of this class using Java reflection. Specifically, all methods that have the following signature:
     public String XXXX( String arg );
  
will become valid FTP commands. (XXXX is a sequence of upper-case letters, digits or '_'. Also, names like SITE_XXXX will become accessible as SITE commands. HELP strings can be added using public members of type String that have names like XXXX_HELP.


Variable Index

 o APPE_HELP
 o authentified
 o CDUP_HELP
 o challenge
 o CWD_HELP
 o DATA_ASCII
 o DATA_BIN
 o dataHost
 o dataMode
 o dataPort
 o DELE_HELP
 o HELP_HELP
 o HELP_QUIT
 o incoming
 o LIST_HELP
 o loginTime
 o MDTM_HELP
 o MKD_HELP
 o multilineAllowed
 o NLST_HELP
 o NOOP_HELP
 o outcoming
 o PASS_HELP
 o passive
 o PASV_HELP
 o path
 o PORT_HELP
 o PWD_HELP
 o random
 o renameName
 o renameNameFlag
 o REST_HELP
 o restartOffset
 o RETR_HELP
 o RMD_HELP
 o RNFR_HELP
 o RNTO_HELP
 o server
 o SITE_HELP
 o SITE_HELP_HELP
 o SITE_MIME
 o SIZE_HELP
 o socket
 o status
 o STOR_HELP
 o SYST_HELP
 o TYPE_HELP
 o user
 o USER_HELP
 o version

Constructor Index

 o FTPDConnection(FTPDaemon, Socket)
Create new FTP connection for the specified server on the specified socket.

Method Index

 o APPE(String)
 o buildDataConnection(String, String, long)
Builds data connection using either previous PORT command data or passive mode port.
 o CDUP(String)
 o CWD(String)
 o debug()
Convenience method: used to obtain server's debug flag.
 o DELE(String)
 o getDataType()
Get the String that represents current data transfer mode.
 o HELP(String)
 o HELP(String, boolean)
Helper for the HELP command.
 o LIST(String)
 o LIST(String, boolean)
Helper method for LIST and NLST commands.
 o makePath(String)
Creates a path that represents a resource referenced by 'name'.
 o MDTM(String)
 o MKD(String)
 o nextChallenge()
Produces new challenge that is sent to the client as a part of the request for the password and can be used for authentication.
 o nextRandom()
Returns next long random value.
 o NLST(String)
 o NOOP(String)
 o PASS(String)
 o PASV(String)
 o PORT(String)
 o PWD(String)
 o REST(String)
 o RETR(String)
 o RMD(String)
 o RNFR(String)
 o RNTO(String)
 o run()
Processes commands sent by the client.
 o SITE_HELP(String)
 o SITE_MIME(String)
 o SIZE(String)
 o STOR(String)
 o SYST(String)
 o TYPE(String)
 o USER(String)

Variables

 o server
 protected FTPDaemon server
 o socket
 protected Socket socket
 o outcoming
 protected PrintWriter outcoming
 o incoming
 protected BufferedReader incoming
 o dataHost
 protected InetAddress dataHost
 o dataPort
 protected int dataPort
 o path
 protected String path
 o authentified
 protected boolean authentified
 o user
 protected String user
 o status
 protected String status
 o dataMode
 protected int dataMode
 o DATA_ASCII
 public static final int DATA_ASCII
 o DATA_BIN
 public static final int DATA_BIN
 o loginTime
 protected long loginTime
 o version
 protected static final String version
 o passive
 protected FTPDConnection. Passive passive
 o renameName
 protected String renameName
 o renameNameFlag
 protected boolean renameNameFlag
 o restartOffset
 protected long restartOffset
 o multilineAllowed
 protected boolean multilineAllowed
 o challenge
 protected String challenge
 o random
 protected Random random
 o USER_HELP
 public static final String USER_HELP
 o PASS_HELP
 public static final String PASS_HELP
 o CWD_HELP
 public static final String CWD_HELP
 o CDUP_HELP
 public static final String CDUP_HELP
 o PWD_HELP
 public static final String PWD_HELP
 o TYPE_HELP
 public static final String TYPE_HELP
 o PORT_HELP
 public static final String PORT_HELP
 o PASV_HELP
 public static final String PASV_HELP
 o RETR_HELP
 public static final String RETR_HELP
 o REST_HELP
 public static final String REST_HELP
 o STOR_HELP
 public static final String STOR_HELP
 o APPE_HELP
 public static final String APPE_HELP
 o SIZE_HELP
 public static final String SIZE_HELP
 o MDTM_HELP
 public static final String MDTM_HELP
 o NLST_HELP
 public static final String NLST_HELP
 o LIST_HELP
 public static final String LIST_HELP
 o SYST_HELP
 public static final String SYST_HELP
 o RNFR_HELP
 public static final String RNFR_HELP
 o RNTO_HELP
 public static final String RNTO_HELP
 o MKD_HELP
 public static final String MKD_HELP
 o DELE_HELP
 public static final String DELE_HELP
 o RMD_HELP
 public static final String RMD_HELP
 o HELP_HELP
 public static final String HELP_HELP
 o SITE_HELP_HELP
 public static final String SITE_HELP_HELP
 o NOOP_HELP
 public static final String NOOP_HELP
 o SITE_MIME
 public static final String SITE_MIME
 o HELP_QUIT
 public static final String HELP_QUIT
 o SITE_HELP
 public static final String SITE_HELP

Constructors

 o FTPDConnection
 public FTPDConnection(FTPDaemon sr,
                       Socket sk) throws IOException
Create new FTP connection for the specified server on the specified socket.

Throws: IOException
if was not able to set socket options and set up input-output streams

Methods

 o debug
 public final boolean debug()
Convenience method: used to obtain server's debug flag.

 o getDataType
 protected String getDataType()
Get the String that represents current data transfer mode.

 o buildDataConnection
 public Socket buildDataConnection(String name,
                                   String dataType,
                                   long bytes) throws Exception
Builds data connection using either previous PORT command data or passive mode port. On success sends "150" FTP reply to the client.

Throws: Exception
if cannot connect to the port specified in port command or listening on the "passive" socket produced an exception or if neither PORT nor PASV commands were given.
 o nextChallenge
 protected String nextChallenge()
Produces new challenge that is sent to the client as a part of the request for the password and can be used for authentication. Override this method if you want to generate challenge yourself.

 o nextRandom
 public long nextRandom()
Returns next long random value. This can be used to generate challenge.

 o makePath
 protected String makePath(String name)
Creates a path that represents a resource referenced by 'name'. The resulting path takes into account current working directory of this connection.

 o run
 public final void run()
Processes commands sent by the client. Commands QUIT and SITE are processed directly, the rest is processed using java reflection call to the corresponding "String XXX( String arg )" method.

 o USER
 public String USER(String name)
 o PASS
 public String PASS(String password) throws InterruptedException
 o CWD
 public String CWD(String dir) throws IOException, FTPDException
 o CDUP
 public String CDUP(String dummy) throws IOException, FTPDException
 o PWD
 public String PWD(String dummy)
 o TYPE
 public String TYPE(String type)
 o PORT
 public String PORT(String address) throws UnknownHostException
 o PASV
 public String PASV(String dummy) throws IOException
 o RETR
 public String RETR(String name) throws Exception
 o REST
 public String REST(String arg)
 o STOR
 public String STOR(String name) throws Exception
 o APPE
 public String APPE(String name) throws Exception
 o SIZE
 public String SIZE(String name) throws Exception
 o MDTM
 public String MDTM(String name) throws Exception
 o NLST
 public String NLST(String name) throws Exception
 o LIST
 public String LIST(String name) throws Exception
 o SYST
 public String SYST(String name) throws IOException
 o RNFR
 public String RNFR(String name) throws IOException, FTPDException
 o RNTO
 public String RNTO(String name) throws FTPDException
 o MKD
 public String MKD(String name) throws FTPDException
 o DELE
 public String DELE(String name) throws FTPDException
 o RMD
 public String RMD(String name) throws FTPDException
 o HELP
 public String HELP(String name) throws FTPDException
 o SITE_HELP
 public String SITE_HELP(String name) throws FTPDException
 o NOOP
 public String NOOP(String arg)
 o SITE_MIME
 public String SITE_MIME(String arg) throws FTPDException
 o LIST
 protected String LIST(String name,
                       boolean verbose) throws Exception
Helper method for LIST and NLST commands. LIST calls this method with verbose=true, and NLST with verbose=false.

Throws: Exception
if the given resource cannot be listed or data connection cannot be built.
 o HELP
 protected String HELP(String name,
                       boolean isSite)
Helper for the HELP command.

Parameters:
name - the name of command on which help information is requested. null if no command was mentioned.
isSite - tells if SITE HELP command is used.

All Packages  Class Hierarchy  This Package  Previous  Next  Index