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.SFTPException
public SSH2FTPOverSFTP(SSH2Connection connection, java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, boolean remoteIsWindows, java.lang.String identity) throws SSH2SFTP.SFTPException
SSH2SFTP.SFTPException
protected 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.SFTPException
protected 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 FTPServerEventHandler
user
- Username to login as.pass
- Password.public void quit()
FTPServerEventHandler
quit
in interface FTPServerEventHandler
public boolean isPlainFile(java.lang.String file)
FTPServerEventHandler
isPlainFile
in interface FTPServerEventHandler
file
- The name of the file.public void changeDirectory(java.lang.String dir) throws FTPException
FTPServerEventHandler
changeDirectory
in interface FTPServerEventHandler
dir
- Name of new directoryFTPException
public void renameFrom(java.lang.String from) throws FTPException
FTPServerEventHandler
renameTo
.renameFrom
in interface FTPServerEventHandler
from
- The name of the file to rename.FTPException
public void renameTo(java.lang.String to) throws FTPException
FTPServerEventHandler
renameFrom
renameTo
in interface FTPServerEventHandler
to
- The new name of the file.FTPException
public void delete(java.lang.String file) throws FTPException
FTPServerEventHandler
delete
in interface FTPServerEventHandler
file
- Name of the file to delete.FTPException
public void rmdir(java.lang.String dir) throws FTPException
FTPServerEventHandler
rmdir
in interface FTPServerEventHandler
dir
- Directory to remove.FTPException
public void mkdir(java.lang.String dir) throws FTPException
FTPServerEventHandler
mkdir
in interface FTPServerEventHandler
dir
- Name of directory to create.FTPException
public void chmod(int mod, java.lang.String file) throws FTPException
FTPServerEventHandler
chmod
in interface FTPServerEventHandler
mod
- New file permissions.file
- Name of file to modify.FTPException
public java.lang.String pwd()
FTPServerEventHandler
pwd
in interface FTPServerEventHandler
public java.lang.String system()
FTPServerEventHandler
system
in interface FTPServerEventHandler
public long modTime(java.lang.String file) throws FTPException
FTPServerEventHandler
modTime
in interface FTPServerEventHandler
file
- Name of file to investigate.FTPException
public long size(java.lang.String file) throws FTPException
FTPServerEventHandler
size
in interface FTPServerEventHandler
file
- Name of file to get the size of.FTPException
public void append(java.lang.String file, java.io.InputStream data, boolean binary) throws FTPException
FTPServerEventHandler
append
in interface FTPServerEventHandler
file
- File to append to.data
- Stream from which the contents of the file is read.binary
- Controls the translating of line endings.FTPException
public void store(java.lang.String file, java.io.InputStream data, boolean binary) throws FTPException
FTPServerEventHandler
store
in interface FTPServerEventHandler
file
- Name to store file as.data
- Stream from which the contents of the file is read.binary
- Controls the translating of line endings.FTPException
public void retrieve(java.lang.String file, java.io.OutputStream data, boolean binary) throws FTPException
FTPServerEventHandler
retrieve
in interface FTPServerEventHandler
file
- Name of file to retrieve.data
- Stream to which the file content is written.binary
- Controls the translating of line endings.FTPException
public void list(java.lang.String path, java.io.OutputStream data) throws FTPException
FTPServerEventHandler
nameList
is
that the latter appends a trailing '/' to directory names.list
in interface FTPServerEventHandler
path
- Directory to list the contens of.data
- Stream to write the results to.FTPException
public void nameList(java.lang.String path, java.io.OutputStream data) throws FTPException
FTPServerEventHandler
list
is
that the this appends a trailing '/' to directory names.nameList
in interface FTPServerEventHandler
path
- Directory to list the contens of.data
- Stream to write the results to.FTPException
public void abort()
abort
in interface FTPServerEventHandler