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.
-
APPE_HELP
-
-
authentified
-
-
CDUP_HELP
-
-
challenge
-
-
CWD_HELP
-
-
DATA_ASCII
-
-
DATA_BIN
-
-
dataHost
-
-
dataMode
-
-
dataPort
-
-
DELE_HELP
-
-
HELP_HELP
-
-
HELP_QUIT
-
-
incoming
-
-
LIST_HELP
-
-
loginTime
-
-
MDTM_HELP
-
-
MKD_HELP
-
-
multilineAllowed
-
-
NLST_HELP
-
-
NOOP_HELP
-
-
outcoming
-
-
PASS_HELP
-
-
passive
-
-
PASV_HELP
-
-
path
-
-
PORT_HELP
-
-
PWD_HELP
-
-
random
-
-
renameName
-
-
renameNameFlag
-
-
REST_HELP
-
-
restartOffset
-
-
RETR_HELP
-
-
RMD_HELP
-
-
RNFR_HELP
-
-
RNTO_HELP
-
-
server
-
-
SITE_HELP
-
-
SITE_HELP_HELP
-
-
SITE_MIME
-
-
SIZE_HELP
-
-
socket
-
-
status
-
-
STOR_HELP
-
-
SYST_HELP
-
-
TYPE_HELP
-
-
user
-
-
USER_HELP
-
-
version
-
-
FTPDConnection(FTPDaemon, Socket)
- Create new FTP connection for the specified server on the specified
socket.
-
APPE(String)
-
-
buildDataConnection(String, String, long)
- Builds data connection using either previous PORT command data or
passive mode port.
-
CDUP(String)
-
-
CWD(String)
-
-
debug()
- Convenience method: used to obtain server's debug flag.
-
DELE(String)
-
-
getDataType()
- Get the String that represents current data transfer mode.
-
HELP(String)
-
-
HELP(String, boolean)
- Helper for the HELP command.
-
LIST(String)
-
-
LIST(String, boolean)
- Helper method for LIST and NLST commands.
-
makePath(String)
- Creates a path that represents a resource referenced by 'name'.
-
MDTM(String)
-
-
MKD(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.
-
nextRandom()
- Returns next long random value.
-
NLST(String)
-
-
NOOP(String)
-
-
PASS(String)
-
-
PASV(String)
-
-
PORT(String)
-
-
PWD(String)
-
-
REST(String)
-
-
RETR(String)
-
-
RMD(String)
-
-
RNFR(String)
-
-
RNTO(String)
-
-
run()
- Processes commands sent by the client.
-
SITE_HELP(String)
-
-
SITE_MIME(String)
-
-
SIZE(String)
-
-
STOR(String)
-
-
SYST(String)
-
-
TYPE(String)
-
-
USER(String)
-
server
protected FTPDaemon server
socket
protected Socket socket
outcoming
protected PrintWriter outcoming
incoming
protected BufferedReader incoming
dataHost
protected InetAddress dataHost
dataPort
protected int dataPort
path
protected String path
authentified
protected boolean authentified
user
protected String user
status
protected String status
dataMode
protected int dataMode
DATA_ASCII
public static final int DATA_ASCII
DATA_BIN
public static final int DATA_BIN
loginTime
protected long loginTime
version
protected static final String version
passive
protected FTPDConnection. Passive passive
renameName
protected String renameName
renameNameFlag
protected boolean renameNameFlag
restartOffset
protected long restartOffset
multilineAllowed
protected boolean multilineAllowed
challenge
protected String challenge
random
protected Random random
USER_HELP
public static final String USER_HELP
PASS_HELP
public static final String PASS_HELP
CWD_HELP
public static final String CWD_HELP
CDUP_HELP
public static final String CDUP_HELP
PWD_HELP
public static final String PWD_HELP
TYPE_HELP
public static final String TYPE_HELP
PORT_HELP
public static final String PORT_HELP
PASV_HELP
public static final String PASV_HELP
RETR_HELP
public static final String RETR_HELP
REST_HELP
public static final String REST_HELP
STOR_HELP
public static final String STOR_HELP
APPE_HELP
public static final String APPE_HELP
SIZE_HELP
public static final String SIZE_HELP
MDTM_HELP
public static final String MDTM_HELP
NLST_HELP
public static final String NLST_HELP
LIST_HELP
public static final String LIST_HELP
SYST_HELP
public static final String SYST_HELP
RNFR_HELP
public static final String RNFR_HELP
RNTO_HELP
public static final String RNTO_HELP
MKD_HELP
public static final String MKD_HELP
DELE_HELP
public static final String DELE_HELP
RMD_HELP
public static final String RMD_HELP
HELP_HELP
public static final String HELP_HELP
SITE_HELP_HELP
public static final String SITE_HELP_HELP
NOOP_HELP
public static final String NOOP_HELP
SITE_MIME
public static final String SITE_MIME
HELP_QUIT
public static final String HELP_QUIT
SITE_HELP
public static final String SITE_HELP
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
debug
public final boolean debug()
- Convenience method: used to obtain server's debug flag.
getDataType
protected String getDataType()
- Get the String that represents current data transfer mode.
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.
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.
nextRandom
public long nextRandom()
- Returns next long random value. This can be used to generate challenge.
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.
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.
USER
public String USER(String name)
PASS
public String PASS(String password) throws InterruptedException
CWD
public String CWD(String dir) throws IOException, FTPDException
CDUP
public String CDUP(String dummy) throws IOException, FTPDException
PWD
public String PWD(String dummy)
TYPE
public String TYPE(String type)
PORT
public String PORT(String address) throws UnknownHostException
PASV
public String PASV(String dummy) throws IOException
RETR
public String RETR(String name) throws Exception
REST
public String REST(String arg)
STOR
public String STOR(String name) throws Exception
APPE
public String APPE(String name) throws Exception
SIZE
public String SIZE(String name) throws Exception
MDTM
public String MDTM(String name) throws Exception
NLST
public String NLST(String name) throws Exception
LIST
public String LIST(String name) throws Exception
SYST
public String SYST(String name) throws IOException
RNFR
public String RNFR(String name) throws IOException, FTPDException
RNTO
public String RNTO(String name) throws FTPDException
MKD
public String MKD(String name) throws FTPDException
DELE
public String DELE(String name) throws FTPDException
RMD
public String RMD(String name) throws FTPDException
HELP
public String HELP(String name) throws FTPDException
SITE_HELP
public String SITE_HELP(String name) throws FTPDException
NOOP
public String NOOP(String arg)
SITE_MIME
public String SITE_MIME(String arg) throws FTPDException
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.
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