com.mindbright.ssh2
public class SSH2FTPOverSFTP extends java.lang.Object implements FTPServerEventHandler
| Modifier and Type | Field and Description |
|---|---|
protected SSH2Connection |
connection
The
SSH2Connection to use |
protected FTPServer |
ftp
FTP server instance
|
protected SSH2SFTPClient |
sftp
SFTP client instance
|
| Modifier | Constructor and Description |
|---|---|
protected |
SSH2FTPOverSFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
java.lang.String identity,
boolean needPassword) |
|
SSH2FTPOverSFTP(SSH2Connection connection,
java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
boolean remoteIsWindows,
java.lang.String identity) |
|
SSH2FTPOverSFTP(SSH2Connection connection,
java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
java.lang.String identity) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort() |
void |
append(java.lang.String file,
java.io.InputStream data,
boolean binary)
Append to a file on the server.
|
void |
changeDirectory(java.lang.String dir)
Change current directory on the server.
|
void |
chmod(int mod,
java.lang.String file)
Modify the file permissions.
|
void |
delete(java.lang.String file)
Delete the given file.
|
protected void |
initFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
boolean remoteIsWindows,
java.lang.String identity,
boolean needPassword)
Initialize the FTP server portion of this class.
|
protected void |
initFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
java.lang.String identity,
boolean needPassword)
Initialize the FTP server portion of this class.
|
protected void |
initSFTP(SSH2Connection connection)
Connect this instance with an
SSH2Connection which is
connected to the server we want to transfer files to/from. |
boolean |
isPlainFile(java.lang.String file)
Check if the name refers to a normal file as opposed to for example
a directory.
|
void |
list(java.lang.String path,
java.io.OutputStream data)
Lists the names of the files and directories in the given directory.
|
boolean |
login(java.lang.String user,
java.lang.String pass)
Login to server.
|
void |
mkdir(java.lang.String dir)
Create a new directory.
|
long |
modTime(java.lang.String file)
Find out when a file was last modified.
|
void |
nameList(java.lang.String path,
java.io.OutputStream data)
Lists the contents of the given directory.
|
java.lang.String |
pwd()
Get the current working directory.
|
void |
quit()
Close the ftp session.
|
void |
renameFrom(java.lang.String from)
The first step in a rename operation.
|
void |
renameTo(java.lang.String to)
The second step in the rename operation.
|
void |
retrieve(java.lang.String file,
java.io.OutputStream data,
boolean binary)
Retrieve a file from the server.
|
void |
rmdir(java.lang.String dir)
Remove the given directory.
|
long |
size(java.lang.String file)
Get the size of a file.
|
void |
store(java.lang.String file,
java.io.InputStream data,
boolean binary)
Store a file on the server.
|
java.lang.String |
system()
Get the type of system the server is running.
|
protected SSH2Connection connection
SSH2Connection to useprotected SSH2SFTPClient sftp
protected FTPServer ftp
protected SSH2FTPOverSFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
java.lang.String identity,
boolean needPassword)
public SSH2FTPOverSFTP(SSH2Connection connection, java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, java.lang.String identity) throws SSH2SFTP.SFTPException
SSH2SFTP.SFTPExceptionpublic SSH2FTPOverSFTP(SSH2Connection connection, java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, boolean remoteIsWindows, java.lang.String identity) throws SSH2SFTP.SFTPException
SSH2SFTP.SFTPExceptionprotected void initSFTP(SSH2Connection connection) throws SSH2SFTP.SFTPException
SSH2Connection which is
connected to the server we want to transfer files to/from.connection - Established connection to the server.SSH2SFTP.SFTPExceptionprotected void initFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
java.lang.String identity,
boolean needPassword)
ftpInput - The ftp command input stream.ftpOutput - The ftp command output stream.identity - Username to log in asneedPassword - Tells the instance if it should request a
password or not from the user. The actual password
the user then gives is ignored.protected void initFTP(java.io.InputStream ftpInput,
java.io.OutputStream ftpOutput,
boolean remoteIsWindows,
java.lang.String identity,
boolean needPassword)
ftpInput - The ftp command input stream.ftpOutput - The ftp command output stream.remoteIsWindows - Whether remote system is a Windows system or not.identity - Username to log in asneedPassword - Tells the instance if it should request a
password or not from the user. The actual password
the user then gives is ignored.public boolean login(java.lang.String user,
java.lang.String pass)
login in interface FTPServerEventHandleruser - Username to login as.pass - Password.public void quit()
FTPServerEventHandlerquit in interface FTPServerEventHandlerpublic boolean isPlainFile(java.lang.String file)
FTPServerEventHandlerisPlainFile in interface FTPServerEventHandlerfile - The name of the file.public void changeDirectory(java.lang.String dir)
throws FTPException
FTPServerEventHandlerchangeDirectory in interface FTPServerEventHandlerdir - Name of new directoryFTPExceptionpublic void renameFrom(java.lang.String from)
throws FTPException
FTPServerEventHandlerrenameTo.renameFrom in interface FTPServerEventHandlerfrom - The name of the file to rename.FTPExceptionpublic void renameTo(java.lang.String to)
throws FTPException
FTPServerEventHandlerrenameFromrenameTo in interface FTPServerEventHandlerto - The new name of the file.FTPExceptionpublic void delete(java.lang.String file)
throws FTPException
FTPServerEventHandlerdelete in interface FTPServerEventHandlerfile - Name of the file to delete.FTPExceptionpublic void rmdir(java.lang.String dir)
throws FTPException
FTPServerEventHandlerrmdir in interface FTPServerEventHandlerdir - Directory to remove.FTPExceptionpublic void mkdir(java.lang.String dir)
throws FTPException
FTPServerEventHandlermkdir in interface FTPServerEventHandlerdir - Name of directory to create.FTPExceptionpublic void chmod(int mod,
java.lang.String file)
throws FTPException
FTPServerEventHandlerchmod in interface FTPServerEventHandlermod - New file permissions.file - Name of file to modify.FTPExceptionpublic java.lang.String pwd()
FTPServerEventHandlerpwd in interface FTPServerEventHandlerpublic java.lang.String system()
FTPServerEventHandlersystem in interface FTPServerEventHandlerpublic long modTime(java.lang.String file)
throws FTPException
FTPServerEventHandlermodTime in interface FTPServerEventHandlerfile - Name of file to investigate.FTPExceptionpublic long size(java.lang.String file)
throws FTPException
FTPServerEventHandlersize in interface FTPServerEventHandlerfile - Name of file to get the size of.FTPExceptionpublic void append(java.lang.String file,
java.io.InputStream data,
boolean binary)
throws FTPException
FTPServerEventHandlerappend in interface FTPServerEventHandlerfile - File to append to.data - Stream from which the contents of the file is read.binary - Controls the translating of line endings.FTPExceptionpublic void store(java.lang.String file,
java.io.InputStream data,
boolean binary)
throws FTPException
FTPServerEventHandlerstore in interface FTPServerEventHandlerfile - Name to store file as.data - Stream from which the contents of the file is read.binary - Controls the translating of line endings.FTPExceptionpublic void retrieve(java.lang.String file,
java.io.OutputStream data,
boolean binary)
throws FTPException
FTPServerEventHandlerretrieve in interface FTPServerEventHandlerfile - Name of file to retrieve.data - Stream to which the file content is written.binary - Controls the translating of line endings.FTPExceptionpublic void list(java.lang.String path,
java.io.OutputStream data)
throws FTPException
FTPServerEventHandlernameList is
that the latter appends a trailing '/' to directory names.list in interface FTPServerEventHandlerpath - Directory to list the contens of.data - Stream to write the results to.FTPExceptionpublic void nameList(java.lang.String path,
java.io.OutputStream data)
throws FTPException
FTPServerEventHandlerlist is
that the this appends a trailing '/' to directory names.nameList in interface FTPServerEventHandlerpath - Directory to list the contens of.data - Stream to write the results to.FTPExceptionpublic void abort()
abort in interface FTPServerEventHandler