|
KindFTP © 1998-2001 Joseph Kiniry © 2001 KindSoftware All Rights Reserved |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--kindftp.FTPProxy
The following implementation of the FTP protocol is written to fulfill RFC 959.
All of the documentation on reply codes, all state diagrams, and all other FTP-specific discussion and documentation is copies in whole or in part from RFC 959 by J. Postel and J. Reynolds.
serverControlPort > 0serverDataPort > 0initialized implies (serverInetAddress != null)initialized implies (debug != null)initialized implies (debugOutput != null)initialized implies (assert != null)initialized implies (debugConstants != null)state == BEGIN || state == WAIT || state == ERROR ||
state == FAILURE || state == SUCCESS(commandSocket != null) implies
(commandOutputStream != null) &&
(commandInputStream != null) &&
(PORTaddress != null) &&
(PORTport > 0)| Field Summary | |
static int |
BEGIN
|
static int |
ERROR
|
static int |
FAILURE
|
static int |
SUCCESS
|
static int |
WAIT
|
| Constructor Summary | |
FTPProxy(java.net.InetAddress address,
int port,
idebug.Debug debug,
idebug.DebugOutput debugOutput)
Build a new FTPProxy for the given server parameters. |
|
| Method Summary | |
void |
ABOR()
This command tells the server to abort the previous FTP service command and any associated transfer of data. |
void |
ACCT(java.lang.String account)
Send an account name to the server. |
void |
ALLO(long reservation_size,
long record_size)
This command may be required by some servers to reserve sufficient storage to accommodate the new file to be transferred. |
void |
APPE(java.lang.String pathname,
boolean streaming,
java.io.File file)
This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. |
void |
CDUP()
This command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory. |
void |
completeCommandHandshake()
Completes the command channel handshake after a streaming RETR attempt, whether the transfer is successful or not. |
void |
connect()
Build a new command connection to the server. |
void |
CWD(java.lang.String pathname)
This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login or accounting information. |
void |
DELE(java.lang.String pathname)
This command causes the file specified in the pathname parameter to be deleted at the server site. |
java.io.File |
getDataFile()
This method returns a reference to a file containing the data that has been received from the server after a successful completion of the RETR command in non-streaming mode. |
java.lang.Object |
getDataObject()
This method returns a reference to an Object
containing the data that has been received from the server after a
successful completion of the RETR command in non-streaming mode. |
java.io.BufferedInputStream |
getInputStream()
This method allows the user-DTP to obtain the server data input stream when a legitimate channel to the server exists. |
java.lang.String |
getLastResponse()
|
java.io.BufferedOutputStream |
getOutputStream()
This method allows the user-DTP to obtain the server data output stream when a legitimate channel to the server exists. |
int |
getPrefix()
|
int |
getReplyCode()
|
int |
getState()
|
void |
HELP(java.lang.String command)
This command shall cause the server to send helpful information regarding its implementation status over the control connection to the user. |
void |
LIST(java.lang.String pathname)
This command causes a list to be sent from the server to the passive DTP. |
java.util.Date |
MDTM(java.lang.String pathname)
Return the last modification time for a file specified by the pathname parameter. |
void |
MKD(java.lang.String pathname)
This command causes the directory specified in the pathname parameter to be created as a directory (if the
path is absolute) or as a subdirectory of the current working
directory (if the the path is relative). |
void |
MODE(char mode_code)
The argument is a single character code specifying the data transfer modes described in the Section on Transmission Modes in RFC 959. |
void |
NLST(java.lang.String pathname)
This command causes a directory listing to be sent from server to user site. |
void |
NOOP()
This command does not affect any parameters or previously entered commands. |
void |
PASS(java.lang.String password)
Send a password to the server for user authentication. |
void |
PASV()
This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. |
void |
PORT(java.net.InetAddress address,
int port)
The arguments are a HOST-PORT specification for the data port to be used in data connection. |
void |
PWD()
This command causes the name of the current working directory to be returned in the reply. |
void |
QUIT()
This command terminates a USER and if file transfer is not in progress, the server closes the control connection. |
void |
REIN()
This command terminates a USER, flushing all I/O and account information, except to allow any transfer in progress to be completed. |
void |
REST(byte[] marker)
Prepare for a restarted data transfer. |
void |
RETR(java.lang.String pathname)
This command causes the server-DTP to transfer a copy of the file, specified in the path parameter, to the server- or user-DTP at the other end of the data connection. |
void |
RETR(java.lang.String pathname,
boolean streaming)
This command causes the server-DTP to transfer a copy of the file, specified in the pathname parameter, to the server- or
user-DTP at the other end of the data connection. |
void |
RMD(java.lang.String pathname)
This command causes the directory specified in the pathname parameter to be removed as a directory (if the
path is absolute) or as a subdirectory of the current working
directory (if the path is relative). |
void |
RNFR(java.lang.String pathname)
This command specifies the old path of the file which is to be renamed. |
void |
RNTO(java.lang.String pathname)
This command specifies the new pathname of the file specified in the immediately preceding "rename from" command. |
void |
SITE(java.lang.String site_parameters)
This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol. |
long |
SIZE(java.lang.String pathname)
Returns the size of a file, in bytes. |
void |
SMNT(java.lang.String pathname)
This command allows the user to mount a different file system data structure without altering his login or accounting information. |
void |
STAT(java.lang.String pathname)
This command shall cause a status response to be sent over the control connection in the form of a reply. |
void |
STOR(java.lang.String pathname)
Store a file to the server's current directory. |
void |
STOR(java.lang.String pathname,
java.io.File file)
Store a file to the server's current directory. |
void |
STOR(java.lang.String pathname,
java.lang.Object object)
Store an object to the server's current directory. |
void |
STOU()
This command behaves like STOR except that the resultant file is to be created in the current directory under a name unique to that directory. |
void |
STRU(char structure_code)
The argument is a single character code specifying file structure described in the Section on Data Representation and Storage in RFC 959. |
void |
SYST()
This command is used to find out the type of operating system at the server. |
void |
TYPE(char type_code)
The argument specifies the representation type of data that is to be transferred. |
void |
USER(java.lang.String username)
Identify the user to the server. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int BEGIN
public static final int WAIT
public static final int ERROR
public static final int FAILURE
public static final int SUCCESS
| Constructor Detail |
public FTPProxy(java.net.InetAddress address,
int port,
idebug.Debug debug,
idebug.DebugOutput debugOutput)
Build a new FTPProxy for the given server parameters.
address - the address of the FTP server.port - the port to connect to on the server. A port of 0
means connect to the default port.debug - a Debug object for the debugging subsystem.debugOutput - a DebugOutput object for the
debugging subsystem.address != nullport >= 0debug != nulldebugOutput != nullthis.debug == debugthis.debugOutput == debugOutputassert != nulldebugConstants != nullserverInetAddress == addressport == 0 implies serverControlPort == DEFAULT_CONTROL_PORTserverDataPort == serverControlPort - 1| Method Detail |
public int getState()
return == BEGIN || return == WAIT || return == ERROR ||
return == FAILURE || return == SUCCESSpublic int getPrefix()
return == ReplyCodes.POSITIVE_PRELIMINARY ||
return == ReplyCodes.POSITIVE_COMPLETION ||
return == ReplyCodes.POSITIVE_INTERMEDIATE ||
return == ReplyCodes.TRANSIENT_NEGATIVE_COMPLETION ||
return == ReplyCodes.PERMANENT_NEGATIVE_COMPLETIONpublic int getReplyCode()
return >= 100 && return <= 553public java.lang.String getLastResponse()
public void connect()
throws java.io.IOException
Build a new command connection to the server.
serverInetAddress != null
public void USER(java.lang.String username)
throws java.io.IOException
Identify the user to the server.
The argument field is a string identifying the user. The user identification is that which is required by the server for access to its file system. This command will normally be the first command transmitted by the user after the control connections are made (some servers may require this). Additional identification information in the form of a password and/or an account command may also be required by some servers. Servers may allow a new USER command to be entered at any point in order to change the access control and/or accounting information. This has the effect of flushing any user, password, and account information already supplied and beginning the login sequence again. All transfer parameters are unchanged and any file transfer in progress is completed under the old access control parameters.
A reply code of ReplyCodes.USER_LOGGED_IN means
that the username was accepted and no password is required, thus you
can start issuing FTP commands. A code of
ReplyCodes.USER_NAME_OK indicates that a call to the
PASS method is required. A code of
ReplyCodes.NEED_ACCOUNT_FOR_LOGIN indicates a call to
ACCT is necessary to login. Anything else indicates a failure; see
the specific code for more information.
username != nullgetReplyCode() == ReplyCodes.USER_LOGGED_IN ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.USER_NAME_OK ||
getReplyCode() == ReplyCodes.NEED_ACCOUNT_FOR_LOGIN
public void PASS(java.lang.String password)
throws java.io.IOException
Send a password to the server for user authentication.
The argument field is a string specifying the user's password. This command must be immediately preceded by the user name command, and, for some sites, completes the user's identification for access control. Since password information is quite sensitive, it is desirable in general to "mask" it or suppress typeout. It appears that the server has no foolproof way to achieve this. It is therefore the responsibility of the user-FTP process to hide the sensitive password information.
A reply code of ReplyCodes.USER_LOGGED_IN or
ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS means the
password was accepted or was superfluous (resp.) and you can start
issuing FTP commands. A code of
ReplyCodes.NEED_ACCOUNT_FOR_LOGIN means that a call to
the ACCT method is required. Anything else indicates of
failure; see the specific code for more information.
password - the password to send to the server.password != nullgetReplyCode() == ReplyCodes.USER_LOGGED_IN ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() == ReplyCodes.BAD_SEQUENCE_OF_COMMANDS ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.NEED_ACCOUNT_FOR_LOGIN
public void ACCT(java.lang.String account)
throws java.io.IOException
Send an account name to the server.
The argument field is a string identifying the user's account. The command is not necessarily related to the USER command, as some sites may require an account for login and others only for specific access, such as storing files. In the latter case the command may arrive at any time.
A reply code of ReplyCodes.USER_LOGGED_IN or
ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS means the
account name was accepted or was superfluous (resp.) and you can start
issuing FTP commands. A code of ReplyCodes.NOT_LOGGED_IN
means that the account name provided failed. Anything else indicates
some other failure; see the specific code for more information.
account - the account name to send to the server.account != nullgetReplyCode() == ReplyCodes.USER_LOGGED_IN ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN ||
getReplyCode() == ReplyCodes.BAD_SEQUENCE_OF_COMMANDS ||
ReplyCodes.isStandardError_500_501_502_421(getReplyCode())
public void CWD(java.lang.String pathname)
throws java.io.IOException
This command allows the user to work with a different directory or
dataset for file storage or retrieval without altering his login or
accounting information. Transfer parameters are similarly
unchanged. The argument pathname is a path specifying a
directory or other system dependent file group designator.
A reply code of
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED means the command
succeeded. Anything else indicates some other failure; see the
specific code for more information.
pathname - the path to change to.pathname != nullgetReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void CDUP()
throws java.io.IOException
This command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory. The reply codes shall be identical to the reply codes of CWD.
A reply code of
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED means the command
succeeded. Anything else indicates some other failure; see the
specific code for more information.
getReplyCode() == ReplyCodes.COMMAND_OK ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void SMNT(java.lang.String pathname)
throws java.io.IOException
This command allows the user to mount a different file system data
structure without altering his login or accounting
information. Transfer parameters are similarly unchanged. The argument
pathname is a path specifying a directory or other system
dependent file group designator.
A reply code of
ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS or
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED means the command
succeeded (perhaps because it was unnecessary in the former case).
Anything else indicates some other failure; see the specific code for
more information.
pathname - a path specifying a directory or other system
dependent file group designator.pathname != nullgetReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS ||
getReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void QUIT()
throws java.io.IOException
This command terminates a USER and if file transfer is not in progress, the server closes the control connection. If file transfer is in progress, the connection will remain open for result response and the server will then close it.
An unexpected close on the control connection will cause the server to take the effective action of an abort (ABOR) and a logout (QUIT).
A reply code of
ReplyCodes.SERVICE_CLOSING_CONTROL_CONNECTION means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
getReplyCode() == ReplyCodes.SERVICE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND
public void REIN()
throws java.io.IOException
This command terminates a USER, flushing all I/O and account information, except to allow any transfer in progress to be completed. All parameters are reset to the default settings and the control connection is left open. This is identical to the state in which a user finds himself immediately after the control connection is opened. A USER command may be expected to follow.
A reply code of
ReplyCodes.SERVICE_READY_IN_NNN_MINUTES means that the
service isn't currently ready but will be in approximately NNN
minutes. A code of ReplyCodes.SERVICE_READY_FOR_NEW_USER
indicates that the current user is terminated and all account
information is flushed. Anything else indicates a failure; see the
specific code for more information.
We currently do nothing special to handle the first case above.
getReplyCode() == ReplyCodes.SERVICE_READY_IN_NNN_MINUTES ||
getReplyCode() == ReplyCodes.SERVICE_READY_FOR_NEW_USER ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS
public void PORT(java.net.InetAddress address,
int port)
throws java.io.IOException
The arguments are a HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, but this class does not support the defaults. The PORT command and/or the PASV command must be used in all data transfers.
A reply code of ReplyCodes.COMMAND_OK means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
address - the address of the system that has the data port
(i.e. the server should connect to if not in PASV mode).port - the port of the system designated with the
address parameter.address != nullport >= 0 && port <= 65536getReplyCode() == ReplyCodes.COMMAND_OK ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN
public void PASV()
throws java.io.IOException
This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command.
Note that the next connection-oriented command (STOR, RETR, LIST, NLST, etc.) will clear the state of this value on the server. A PASV command must be issued prior to every data command action.
A reply code of ReplyCodes.ENTERING_PASSIVE_MODE
means the command succeeded. Anything else indicates some other
failure; see the specific code for more information.
getReplyCode() == ReplyCodes.ENTERING_PASSIVE_MODE ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN
public void TYPE(char type_code)
throws java.io.IOException
The argument specifies the representation type of data that is to be transferred.
A reply code of ReplyCodes.COMMAND_OK means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
type_code - must either be 'A' for ASCII or 'I' for Image. Most
servers only support ASCII and Image types; we do not support 'E'
(EBCDIC) or 'L' (local byte size) types. See RFC 959 for details.type_code == 'A' || type_code == 'I' ||
type_code == 'E' || type_code == 'L'getReplyCode() == ReplyCodes.COMMAND_OK ||
ReplyCodes.isStandardError_500_501_504_421_530(getReplyCode())
public void STRU(char structure_code)
throws java.io.IOException
The argument is a single character code specifying file structure described in the Section on Data Representation and Storage in RFC 959.
A reply code of ReplyCodes.COMMAND_OK means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
structure_code - must be either 'F' for file, 'R' for
record, and 'P' for page. Most servers only support file
structure mode; we only supports file structure mode.structure_code == 'F' || structure_code == 'R' || structure_code == 'P'getReplyCode() == ReplyCodes.COMMAND_OK ||
ReplyCodes.isStandardError_500_501_504_421_530(getReplyCode())
public void MODE(char mode_code)
throws java.io.IOException
The argument is a single character code specifying the data transfer modes described in the Section on Transmission Modes in RFC 959.
A reply code of ReplyCodes.COMMAND_OK means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
mode_code - must be either 'S' for stream, 'B' for block, or
'C' for compressed. Most servers only support stream mode; we
only support stream mode.mode_code == 'S' || mode_code == 'B' || mode_code == 'C'getReplyCode() == ReplyCodes.COMMAND_OK ||
ReplyCodes.isStandardError_500_501_504_421_530(getReplyCode())
public void RETR(java.lang.String pathname,
boolean streaming)
throws java.io.IOException
This command causes the server-DTP to transfer a copy of the file,
specified in the pathname parameter, to the server- or
user-DTP at the other end of the data connection. The status and
contents of the file at the server site shall be unaffected.
If the streaming parameter is true, then the proxy's
getState() method will return a state of
FTPProxy.WAIT and getReplyCode() will hold a
ReplyCodes.POSITIVE_PRELIMINARY code. Finally, the
user-DTP process is expected to call getInputStream() and
handle the incoming data itself. The channel will be closed by the
server when all of the data has been sent.
Whether or not the transfer is
successful, after the data has been (successfully or not) streamed,
the completeCommandHandshake() method
must be called to complete the command channel
handshake for the transfer.
If streaming is false, the user-DTP should call
getDataFile() when this method successfully returns.
A reply code of
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING
or
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION
means that the command was accepted the data is about to arrive over
the data connection. A code of
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION
or ReplyCodes.FILE_ACTION_OK_AND_COMPLETED indicates that
the data has been transferred successfully. A code of
ReplyCodes.RESTART_MARKER_REPLY indicates a successful
restarted transfer has begun. Anything else indicates a failure of
some kind; see the specific code for more information.
pathname - the name of the file to retrieve.streaming - a flag that indicates if the transfer should
take place in streaming mode.pathname != nullgetReplyCode() ==
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING ||
getReplyCode() ==
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION ||
getReplyCode() == ReplyCodes.RESTART_MARKER_REPLY ||
getReplyCode() ==
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION ||
getReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
getReplyCode() == ReplyCodes.CANNOT_OPEN_DATA_CONNECTION ||
getReplyCode() == ReplyCodes.CONNECTION_CLOSED_TRANSFER_ABORTED ||
getReplyCode() == ReplyCodes.ACTION_ABORTED_LOCAL_ERROR ||
getReplyCode() ==
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.NOT_LOGGED_INgetInputStream(),
getState(),
getReplyCode(),
getPrefix()
public void RETR(java.lang.String pathname)
throws java.io.IOException
This command causes the server-DTP to transfer a copy of the file, specified in the path parameter, to the server- or user-DTP at the other end of the data connection. The status and contents of the file at the server site shall be unaffected.
Note that this command will only work for retrieving serialized Java objects from the server.
See the other RETR() method for more information.
After the successful completion of this method,
getDataObject() should be called to get the transferred
object.
pathname - the name of the file to retrieve.pathname != nullRETR(java.lang.String, boolean)
public void STOR(java.lang.String pathname,
java.io.File file)
throws java.io.IOException
Store a file to the server's current directory.
This command causes the server-DTP to accept the data transferred
via the data connection and to store the data as a file at the server
site. If the file specified in the pathname exists at the
server site, then its contents shall be replaced by the data being
transferred. A new file is created at the server site if the file
specified in the pathname does not already exist.
See the main STOR method for more information.
pathname - the path to the file on the server where the data
should be stored. If pathname has a path component
(i.e. is not just a filename), the path must already exist.file - a reference to the file that contains the data that
is sent to the server if streaming is false. file should be null
if streaming is true.pathname != nullfile != nullSTOR(java.lang.String, java.io.File)
public void STOR(java.lang.String pathname,
java.lang.Object object)
throws java.io.IOException
Store an object to the server's current directory.
This command causes the server-DTP to accept the data transferred
via the data connection and to store the data as a file at the server
site. If the file specified in the pathname exists at the
server site, then its contents shall be replaced by the data being
transferred. A new file is created at the server site if the file
specified in the pathname does not already exist.
See the main STOR method for more information.
pathname - the path to the file on the server where the data
should be stored. If pathname has a path component
(i.e. is not just a filename), the path must already exist.object - a reference to a serializable object that is sent
to the server.pathname != nullobject != nullobject instanceof SerializableSTOR(java.lang.String, java.io.File),
RETR(java.lang.String, boolean)
public void STOR(java.lang.String pathname)
throws java.io.IOException
Store a file to the server's current directory.
This command causes the server-DTP to accept the data transferred
via the data connection and to store the data as a file at the server
site. If the file specified in the pathname exists at the
server site, then its contents shall be replaced by the data being
transferred. A new file is created at the server site if the file
specified in the pathname does not already exist.
If the streaming parameter is true, the user-DTP is
expected to call getOutputStream() and handle sending the
data itself.
See the main STOR method for more information.
pathname - the path to the file on the server where the data
should be stored. If pathname has a path component
(i.e. is not just a filename), the path must already exist.pathname != nullSTOR(java.lang.String, java.io.File)
public void STOU()
throws java.io.IOException
This command behaves like STOR except that the resultant file is to be created in the current directory under a name unique to that directory.
This action is currently not supported by this client nor by any FTP servers that the author has tested.
public void APPE(java.lang.String pathname,
boolean streaming,
java.io.File file)
throws java.io.IOException
This command causes the server-DTP to accept the data transferred
via the data connection and to store the data in a file at the server
site. If the file specified in the pathname parameter
exists at the server site, then the data shall be appended to that
file; otherwise the file specified shall be created at the server
site.
Note that many FTP servers do not support the APPE operation.
pathname - the path to the file on the server where the data
should be stored. If this parameter has a path component (i.e. is not
just a filename), the path must already exist.streaming - a flag that, if true, indicates that the client
of FTPProxy will be streaming the data for the file through the
stream returned by getOutputStream().file - a reference to the file that contains the data that
is sent to the server if streaming is false. file should be null
if streaming is true.
public void ALLO(long reservation_size,
long record_size)
throws java.io.IOException
This command may be required by some servers to reserve sufficient storage to accommodate the new file to be transferred. This command shall be followed by a STORe or APPEnd command. The ALLO command should be treated as a NOOP (no operation) by those servers which do not require that the maximum size of the file be declared before a send, and those servers interested in only the maximum record or page size should accept a dummy value in the first argument and ignore it.
Note that many servers today do not support the ALLO command.
A reply code of ReplyCodes.COMMAND_OK or
ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS means the
command succeeded or was superfluous respectively. Anything else
indicates some other failure; see the specific code for more
information.
reservation_size - the number of bytes (using the logical
byte size) of storage to be reserved for the file.record_size - a maximum record or page size (in logical
bytes) for files sent with record or page structure. A record
size of 0 means that record size will not be specified in the
issued ALLO command.reservation_size >= 0 && record_size >= 0getReplyCode() == ReplyCodes.COMMAND_OK ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS ||
ReplyCodes.isStandardError_500_501_504_421_530(getReplyCode())
public void REST(byte[] marker)
throws java.io.IOException
Prepare for a restarted data transfer. This command does not cause file transfer but skips over the file to the specified data checkpoint. This command shall be immediately followed by the appropriate FTP service command which shall cause file transfer to resume.
marker - the server marker at which file transfer is to be
restarted.
public void RNFR(java.lang.String pathname)
throws java.io.IOException
This command specifies the old path of the file which is to be renamed. This command must be immediately followed by a "rename to" (RNTO) command specifying the new file pathname.
A reply code of
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY or
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE means the
command did not succeed because the file is either (possible)
temporarily or permanently unavailable for this operation. A code of
ReplyCodes.REQUESTED_ACTION_PENDING_MORE_INFO indicates
that the command succeeded and is server is waiting for the
RFTO command that should immediately follow. Any other
code indicates some other failure; see the specific code for more
information.
pathname - the old path of the file which is to be renamed.pathname != nullgetReplyCode() ==
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY ||
getReplyCode() ==
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.REQUESTED_ACTION_PENDING_MORE_INFO
public void RNTO(java.lang.String pathname)
throws java.io.IOException
This command specifies the new pathname of the file specified in the immediately preceding "rename from" command. Together the two commands cause a file to be renamed.
A reply code of
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED indicates that
the command succeeded. A code of ReplyCodes.NEED_ACCOUNT
indicates that an account needs to be specified with the
ACCT command before this rename can complete. A code of
ReplyCodes.ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED
indicates that the filename is not a legal filename on the server.
Any other code indicates some other failure; see the specific code for
more information.
pathname - the new pathname of the file specified in the
immediately preceding "rename from" (RNFR) command.pathname != nullgetReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
getReplyCode() == ReplyCodes.NEED_ACCOUNT ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.BAD_SEQUENCE_OF_COMMANDS
public void ABOR()
throws java.io.IOException
This command tells the server to abort the previous FTP service command and any associated transfer of data. The abort command may require "special action", as discussed in the Section on FTP Commands (in RFC 959), to force recognition by the server. No action is to be taken if the previous command has been completed (including data transfer). The control connection is not to be closed by the server, but the data connection must be closed.
There are two cases for the server upon receipt of this command: (1) the FTP service command was already completed, or (2) the FTP service command is still in progress.
A reply code of
ReplyCodes.DATA_CONNECTION_OPEN_NO_TRANSFER_IN_PROGRESS
or
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION
means the command succeeded. Anything else indicates some other
failure; see the specific code for more information.
getReplyCode() ==
ReplyCodes.DATA_CONNECTION_OPEN_NO_TRANSFER_IN_PROGRESS ||
getReplyCode() ==
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION
public void DELE(java.lang.String pathname)
throws java.io.IOException
This command causes the file specified in the
pathname parameter to be deleted at the server site. If
an extra level of protection is desired (such as the query, "Do you
really wish to delete?"), it should be provided by the user-FTP
process.
WARNING: Most FTP servers do not support deletes of non-empty directories and the FTP protocol specification mentions nothing with respect to these delete semantics. Thus, this method could automatically delete whole subtrees, regardless of content. Use this method wisely...
A reply code of
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED means the command
succeeded. A code of
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY
means that the file was busy and the client can retry later if they
desire. A code of
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE means that
the file is unavailable for other reasons (file not found,
insufficient permissions, etc.). Anything else indicates some other
failure; see the specific code for more information.
pathname - the path to be deleted at the server site.pathname != nullgetReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
getReplyCode() ==
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN
public void RMD(java.lang.String pathname)
throws java.io.IOException
This command causes the directory specified in the
pathname parameter to be removed as a directory (if the
path is absolute) or as a subdirectory of the current working
directory (if the path is relative). See Appendix II.
A reply code of
ReplyCodes.FILE_ACTION_OK_AND_COMPLETED means the command
succeeded (perhaps because it was unnecessary in the latter case).
Anything else indicates some other failure; see the specific code for
more information.
pathname - the path to be removed.pathname != nullgetReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void MKD(java.lang.String pathname)
throws java.io.IOException
This command causes the directory specified in the
pathname parameter to be created as a directory (if the
path is absolute) or as a subdirectory of the current working
directory (if the the path is relative). See Appendix II of RFC 959
for more information.
A reply code of ReplyCodes.DIRECTORY_CREATED means
the command succeeded. Anything else indicates some other failure;
see the specific code for more information.
pathname - the path to be created.pathname != nullgetReplyCode() == ReplyCodes.DIRECTORY_CREATED ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void PWD()
throws java.io.IOException
This command causes the name of the current working directory to be returned in the reply. See Appendix II of RFC 959 for more details.
A reply code of ReplyCodes.DIRECTORY_CREATED means
the command succeeded. Anything else indicates some other failure;
see the specific code for more information.
If this command succeeds, then the current directory can be
obtained by calling getLastResponse().
public void LIST(java.lang.String pathname)
throws java.io.IOException
This command causes a list to be sent from the server to the
passive DTP. If the pathname parameter specifies a
directory or other group of files, the server should transfer a list
of files in the specified directory. If it specifies a file then the
server should send current information on the file. A null argument
implies the user's current working or default directory. The data
transfer is over the data connection in type ASCII or type EBCDIC
(though this implementation only supports type ASCII). The user must
ensure that the TYPE is appropriately ASCII or EBCDIC. Since the
information on a file may vary widely from system to system, this
information may be hard to use automatically in a program, but may be
quite useful to a human user.
A reply code of
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING
or
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION
means that the command was accepted the data is about to arrive over
the data connection. A code of
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION
or ReplyCodes.FILE_ACTION_OK_AND_COMPLETED indicates that
the data has been transferred successfully. Anything else indicates a
failure of some kind; see the specific code for more information.
After a successful LIST the listing is available via
getLastResponse().
pathname - the path to list. A null implies the
current working directory.getReplyCode() ==
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING ||
getReplyCode() ==
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION ||
getReplyCode() ==
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION ||
getReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
getReplyCode() == ReplyCodes.CANNOT_OPEN_DATA_CONNECTION ||
getReplyCode() == ReplyCodes.CONNECTION_CLOSED_TRANSFER_ABORTED ||
getReplyCode() == ReplyCodes.ACTION_ABORTED_LOCAL_ERROR ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode())
public void NLST(java.lang.String pathname)
throws java.io.IOException
This command causes a directory listing to be sent from server to
user site. The pathname parameter should specify a
directory or other system-specific file group descriptor; a null
argument implies the current directory. The server will return a
stream of names of files and no other information. The data will be
transferred in ASCII or EBCDIC type over the data connection as valid
pathname strings separated by
A reply code of
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING
or
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION
means that the command was accepted the data is about to arrive over
the data connection. A code of
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION
or ReplyCodes.FILE_ACTION_OK_AND_COMPLETED indicates that
the data has been transferred successfully. Anything else indicates a
failure of some kind; see the specific code for more information.
After a successful LIST the listing is available via
getLastResponse().
pathname - the path to list. A null implies the current
working directory.getReplyCode() ==
ReplyCodes.DATA_CONNECTION_ALREADY_OPEN_TRANFER_STARTING ||
getReplyCode() ==
ReplyCodes.FILE_STATUS_OK_ABOUT_TO_OPEN_DATA_CONNECTION ||
getReplyCode() ==
ReplyCodes.CLOSING_DATA_CONNECTION_AFTER_SUCCESSFUL_ACTION ||
getReplyCode() == ReplyCodes.FILE_ACTION_OK_AND_COMPLETED ||
getReplyCode() == ReplyCodes.CANNOT_OPEN_DATA_CONNECTION ||
getReplyCode() == ReplyCodes.CONNECTION_CLOSED_TRANSFER_ABORTED ||
getReplyCode() == ReplyCodes.ACTION_ABORTED_LOCAL_ERROR ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode())
public void SITE(java.lang.String site_parameters)
throws java.io.IOException
This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol. The nature of these services and the specification of their syntax can be stated in a reply to the HELP SITE command.
A reply code of ReplyCodes.COMMAND_OK or
ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS means the
command succeeded (perhaps because it was unnecessary in the latter
case). Anything else indicates some other failure; see the specific
code for more information.
site_parameters - the system-specific service specification.site_parameters != nullgetReplyCode() == ReplyCodes.COMMAND_OK ||
getReplyCode() == ReplyCodes.COMMAND_NOT_IMPLEMENTED_SUPERFLUOUS ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_PARAMETERS ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN
public void SYST()
throws java.io.IOException
This command is used to find out the type of operating system at the server.
A reply code of ReplyCodes.SYSTEM_TYPE means that the
command succeeded, thus the server system type can be obtained by
calling getSystemType(). Anything else indicates a failure; see the
specific code for more information.
getReplyCode() == ReplyCodes.SYSTEM_TYPE ||
ReplyCodes.isStandardError_500_501_502_421(getReplyCode())
public void STAT(java.lang.String pathname)
throws java.io.IOException
This command shall cause a status response to be sent over the control connection in the form of a reply. The command may be sent during a file transfer (along with the Telnet IP and Synch signals--see the Section on FTP Commands in RFC 959) in which case the server will respond with the status of the operation in progress, or it may be sent between file transfers.
In the latter case, the command may have an argument field. If the argument is a path, the command is analogous to the "list" command except that data shall be transferred over the control connection. If a partial path is given, the server may respond with a list of file names or attributes associated with that specification. If no argument is given, the server should return general status information about the server FTP process. This should include current values of all transfer parameters and the status of connections.
A reply code of ReplyCodes.STATUS_OR_HELP_REPLY or
ReplyCodes.DIRECTORY_STATUS or
ReplyCodes.FILE_STATUS means that the command succeeded
(perhaps because it was unnecessary in the former case). Anything
else indicates some other failure; see the specific code for more
information.
If this command succeeds, getLastResponse() contains
a appropriate status message from the server. If
pathname is non-null, an "ls -l"-like listing
will be returned instead.
pathname - an optional path on which to get a status. If
path is null, a general server status is checked.getReplyCode() == ReplyCodes.STATUS_OR_HELP_REPLY ||
getReplyCode() == ReplyCodes.DIRECTORY_STATUS ||
getReplyCode() == ReplyCodes.FILE_STATUS ||
getReplyCode() ==
ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE_FILE_BUSY ||
ReplyCodes.isStandardError_500_501_502_421_530(getReplyCode()) ||
getReplyCode() == ReplyCodes.NOT_LOGGED_IN
public void HELP(java.lang.String command)
throws java.io.IOException
This command shall cause the server to send helpful information regarding its implementation status over the control connection to the user. The command may take an argument (e.g., any command name) and return more specific information as a response. On most servers, the HELP command is allowed before entering a USER command. The server may use this reply to specify site-dependent parameters, e.g., in response to HELP SITE.
A reply code of ReplyCodes.STATUS_OR_HELP_REPLY or
ReplyCodes.HELP_MESSAGE means the command succeeded.
Anything else indicates some other failure; see the specific code for
more information.
command - the (optional) command to ask for help on. A null
indicates that general server help is requested.command != nullgetReplyCode() == ReplyCodes.STATUS_OR_HELP_REPLY ||
getReplyCode() == ReplyCodes.HELP_MESSAGE ||
ReplyCodes.isStandardError_500_501_502_421(getReplyCode())
public void NOOP()
throws java.io.IOException
This command does not affect any parameters or previously entered commands. It specifies no action other than that the server send an OK reply.
A reply code of ReplyCodes.COMMAND_OK means the
command succeeded. Anything else indicates some other failure; see
the specific code for more information.
getReplyCode() == ReplyCodes.COMMAND_OK ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() ==
ReplyCodes.SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION
public java.util.Date MDTM(java.lang.String pathname)
throws java.io.IOException
Return the last modification time for a file specified by the
pathname parameter. If the modification time cannot be
determined, a null will be returned.
A reply code of ReplyCodes.FILE_STATUS indicates the
file exists, can be read, and the server determined the last
modification time, thus it is the return value of this method. A code
of ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE means
that the file wasn't available for some reason (it didn't exist, it
was unreadable, etc.). Anything else indicates a failure of some
kind; see the specific code for more information.
pathname - the path to the file to check.pathname != nullgetReplyCode() == ReplyCodes.FILE_STATUS ||
getReplyCode() == ReplyCodes.SYNTAX_ERROR_IN_COMMAND ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public long SIZE(java.lang.String pathname)
throws java.io.IOException
Returns the size of a file, in bytes. If the size cannot be determined, a -1 will be returned.
pathname - the path to the file to size.pathname != nullreturn >= 0getReplyCode() == ReplyCodes.FILE_STATUS ||
getReplyCode() == ReplyCodes.ACTION_NOT_TAKEN_FILE_UNAVAILABLE
public void completeCommandHandshake()
throws java.io.IOException
Completes the command channel handshake after a streaming RETR attempt, whether the transfer is successful or not.
public java.io.BufferedInputStream getInputStream()
throws java.io.IOException
This method allows the user-DTP to obtain the server data input stream when a legitimate channel to the server exists. Such a channel is normally only valid just after a streaming RETR command.
public java.io.BufferedOutputStream getOutputStream()
throws java.io.IOException
This method allows the user-DTP to obtain the server data output stream when a legitimate channel to the server exists. Such a channel is normally only valid just after a streaming STOR command.
public java.io.File getDataFile()
throws java.io.IOException
This method returns a reference to a file containing the data that has been received from the server after a successful completion of the RETR command in non-streaming mode. This is the only time this method can be called. This file is typically stored in a cache private to this class and should not be deleted, manipulated, or mangled in any way. The user-DTP should deal with the file (e.g. copy it, etc.) before issuing another command to the server.
public java.lang.Object getDataObject()
throws java.io.IOException
This method returns a reference to an Object
containing the data that has been received from the server after a
successful completion of the RETR command in non-streaming mode. This
is the only time this method can be called.
|
KindFTP © 1998-2001 Joseph Kiniry © 2001 KindSoftware All Rights Reserved |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||