Secure iNet Factory

com.jscape.filetransfer
Class SftpTransfer

java.lang.Object
  extended by com.jscape.filetransfer.SftpTransfer
All Implemented Interfaces:
FileTransfer

public class SftpTransfer
extends java.lang.Object
implements FileTransfer

Implements the basic functionality of a SFTP (FTP over SSH) client.

Example Usage:

   // connection information
   String hostname = "10.0.0.1";
   String username = "jsmith";
   String password = "secret";

   // create com.jscape.inet.ssh.util.SshParameters instance
   SshParameters params = new SshParameters(hostname,username,password);

   // create SftpTransfer instance
   FileTransfer ftp = new SftpTransfer(params)

   // connect to server
   ftp.connect();

   // print directory listing to console
   System.out.println(ftp.getDirListingAsString());

   // disconnect from server
   sftp.disconnect();
 


Field Summary
 
Fields inherited from interface com.jscape.filetransfer.FileTransfer
ASCII, AUTO, BINARY, CURRENT_DIR, UP_DIR
 
Constructor Summary
SftpTransfer(SshParameters parameters)
          Creates SftpTransfer instance.
SftpTransfer(SshParameters parameters, SftpConfiguration configuration)
          Creates SftpTransfer instance.
SftpTransfer(SshParameters parameters, SftpConfiguration configuration, java.util.Set<FileTransferListener> listeners)
          Creates SftpTransfer instance.
SftpTransfer(java.lang.String host, java.lang.String user, java.lang.String pwd)
          Creates SftpTransfer instance.
SftpTransfer(java.lang.String host, java.lang.String user, java.lang.String pwd, java.io.File privateKey)
          Creates SftpTransfer instance.
SftpTransfer(java.lang.String host, java.lang.String user, java.lang.String password, int port)
          Creates SftpTransfer instance.
SftpTransfer(java.lang.String host, java.lang.String user, java.lang.String pwd, java.lang.Integer port)
          Creates SftpTransfer instance.
SftpTransfer(java.lang.String host, java.lang.String user, java.lang.String pwd, int port, SftpConfiguration configuration)
          Creates SftpTransfer instance.
 
Method Summary
 void abortDownloadThread(java.lang.String file)
          Abort download thread.
 void abortDownloadThreads()
          Abort all download thrads spawned by Sftp instance.
 void abortUploadThread(java.lang.String file)
          Abort upload thread.
 void abortUploadThreads()
          Abort all upload threads spawned by Sftp instance.
 void addFileTransferListener(FileTransferListener listener)
          See FileTransfer interface for method description.
 void clearProxySettings()
          Clears proxy server values.
 void connect()
          See FileTransfer interface for method description.
 FileTransfer copy()
          Returns a copy of current transfer instance with same listeners.
 void deleteDir(java.lang.String name)
          See FileTransfer interface for method description.
 void deleteDir(java.lang.String name, boolean recursive)
          See FileTransfer interface for method description.
 void deleteFile(java.lang.String remoteFile)
          See FileTransfer interface for method description.
 void disconnect()
          See FileTransfer interface for method description.
 void download(java.io.OutputStream out, java.lang.String remoteFile)
          See FileTransfer interface for method description.
 java.io.File download(java.lang.String remoteFile)
          See FileTransfer interface for method description.
 java.io.File download(java.lang.String localFile, java.lang.String remoteFile)
          See FileTransfer interface for method description.
 void downloadDir(java.lang.String remoteDir)
          See FileTransfer interface for method description.
 void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum)
          Downloads remote directory and contents.
 void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum, int threadCount)
          Downloads remote directory and contents.
 boolean exists(java.lang.String path)
          Checks if the specified path exists on the remote server.
 int getBlockTransferSize()
          Deprecated. see #getUploadBlockSize
 boolean getDebug()
          See FileTransfer interface for method description.
 java.io.PrintStream getDebugStream()
          See FileTransfer interface for method description.
 java.lang.String getDir()
          See FileTransfer interface for method description.
 java.util.Enumeration getDirListing()
          See FileTransfer interface for method description.
 java.util.Enumeration getDirListing(java.lang.String filter)
          See FileTransfer interface for method description.
 java.lang.String getDirListingAsString()
          See FileTransfer interface for method description.
 java.lang.String getDirListingAsString(java.lang.String filter)
          See FileTransfer interface for method description.
 int getDownloadBlockSize()
          Obtains the current download buffer size.
 long getFilesize(java.lang.String remoteFile)
          See FileTransfer interface for method description.
 java.util.Date getFileTimestamp(java.lang.String remoteFile)
          See FileTransfer interface for method description.
 java.lang.String getHostname()
          See FileTransfer interface for method description.
 java.lang.Object getImplementation()
          See FileTransfer interface for method description.
 java.io.InputStream getInputStream(java.lang.String filename, long offset)
          Get input stream.
 java.io.File getLocalDir()
          See FileTransfer interface for method description.
 java.util.Enumeration getLocalDirListing()
          See FileTransfer interface for method description.
 int getMode()
          See FileTransfer interface for method description.
 java.util.Enumeration getNameListing()
          See FileTransfer interface for method description.
 java.util.Enumeration getNameListing(java.lang.String filter)
          See FileTransfer interface for method description.
 java.io.OutputStream getOutputStream(java.lang.String filename, long offset, boolean append)
          Gets OutputStream for writing to remote file.
 boolean getPassive()
          See FileTransfer interface for method description.
 java.lang.String getPassword()
          See FileTransfer interface for method description.
 int getPort()
          See FileTransfer interface for method description.
 java.io.File getPrivateKey()
          Returns SSH private key used for session
 int getRecursiveDirectoryFileCount(java.lang.String directory)
          Get recursive directory file count.
 long getRecursiveDirectorySize(java.lang.String directory)
          Get recursive size of all files in directory.
 java.util.Vector getRemoteFileList(java.lang.String directory)
          Get remote file list.
 long getTimeout()
          See FileTransfer interface for method description.
 int getUploadBlockSize()
          Obtains the current upload buffer size.
 java.lang.String getUsername()
          See FileTransfer interface for method description.
 java.lang.String getWireEncoding()
          Gets encoding set used when issuing commands and transferring files
 void interrupt()
          See FileTransfer interface for method description.
 boolean interrupted()
          See FileTransfer interface for method description.
 boolean isConnected()
          See FileTransfer interface for method description.
 boolean isValidPath(java.lang.String path)
          See FileTransfer interface for method description.
 void makeDir(java.lang.String name)
          See FileTransfer interface for method description.
 void makeDirRecursive(java.lang.String name)
          See FileTransfer interface for method description.
 java.io.File makeLocalDir(java.lang.String name)
          See FileTransfer interface for method description.
 void mdelete(java.lang.String filter)
          Deletes multiple files matching filter to SFTP server's current directory.
 void mdownload(java.util.Enumeration fileNames)
          See FileTransfer interface for method description.
 void mdownload(java.lang.String filter)
          See FileTransfer interface for method description.
 void mupload(java.util.Enumeration fileNames)
          See FileTransfer interface for method description.
 void mupload(java.lang.String filter)
          See FileTransfer interface for method description.
 void removeFileTransferListener(FileTransferListener listener)
          See FileTransfer interface for method description.
 void renameFile(java.lang.String remoteFile, java.lang.String newFile)
          See FileTransfer interface for method description.
 void reset()
          See FileTransfer interface for method description.
 void resumeDownload(java.lang.String remoteFile, long offset)
          See FileTransfer interface for method description.
 void resumeDownload(java.lang.String localFile, java.lang.String remoteFile, long offset)
          See FileTransfer interface for method description.
 void resumeUpload(java.io.File file, long offset)
          See FileTransfer interface for method description.
 void resumeUpload(java.io.File localFile, java.lang.String remoteFile, long off)
          Resume upload of file to server.
 void resumeUpload(java.lang.String file, long offset)
          See FileTransfer interface for method description.
 boolean sameChecksum(java.io.File localFile, java.lang.String remoteFile)
          Checks a checksum equality of local and remote files.
 void setAscii()
          Sets data transfer mode to ASCII.
 void setAuto(boolean auto)
          See FileTransfer interface for method description.
 void setBinary()
          See FileTransfer interface for method description.
 void setBlockTransferSize(int blocksize)
          Deprecated. see #setUploadBlockSize
 void setDebug(boolean debug)
          See FileTransfer interface for method description.
 void setDebugStream(java.io.PrintStream ps)
          See FileTransfer interface for method description.
 void setDir(java.lang.String name)
          See FileTransfer interface for method description.
 void setDirUp()
          See FileTransfer interface for method description.
 void setDownloadBlockSize(int blockSize)
          Sets the transfer buffer size for download operation.
 void setFileModificationTime(java.lang.String remoteFile, java.util.Date modificationTime)
          Set modification time.
 void setFileTimestamp(java.lang.String remoteFile, java.util.Date timestamp)
          See FileTransfer interface for method description.
 void setHostname(java.lang.String host)
          See FileTransfer interface for method description.
 void setLineTerminator(java.lang.String lineTerminator)
          Sets the line terminator for transfer mode ASCII.
 void setLocalDir(java.io.File dir)
          See FileTransfer interface for method description.
 void setPassive(boolean passive)
          See FileTransfer interface for method description.
 void setPassword(java.lang.String password)
          See FileTransfer interface for method description.
 void setPort(int port)
          See FileTransfer interface for method description.
 void setPreserveFileDownloadTimestamp(boolean value)
          Set preserve file download timestamps.
 void setPreserveFileUploadTimestamp(boolean value)
          Get preserve file upload timestamps.
 void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
          Sets the proxy authentication username and password to use with proxy server.
 void setProxyHost(java.lang.String proxyHostname, int proxyPort)
          Sets the proxy hostname and port for this connection.
 void setProxyType(java.lang.String proxyType)
          Sets the proxy type will be used for this connection.
 void setTimeout(long timeout)
          See FileTransfer interface for method description.
 void setTimeZone(java.util.TimeZone timeZone)
          Set the timezone, used for preserving timestamps.
 void setUploadBlockSize(int blockSize)
          Sets the transfer buffer size for upload operation.
 void setUsername(java.lang.String username)
          See FileTransfer interface for method description.
 void setWireEncoding(java.lang.String encoding)
          Sets encoding set used when issuing commands and transferring files.
 void upload(byte[] data, java.lang.String name)
          See FileTransfer interface for method description.
 void upload(byte[] data, java.lang.String name, boolean append)
          See FileTransfer interface for method description.
 void upload(java.io.File file)
          See FileTransfer interface for method description.
 void upload(java.io.File file, boolean append)
          See FileTransfer interface for method description.
 void upload(java.io.File file, java.lang.String remoteName)
          See FileTransfer interface for method description.
 void upload(java.io.File file, java.lang.String remoteName, boolean append)
          See FileTransfer interface for method description.
 void upload(java.lang.String name)
          See FileTransfer interface for method description.
 void upload(java.lang.String name, boolean append)
          See FileTransfer interface for method description.
 void upload(java.lang.String extension, java.io.File file)
          Uploads a file to server with the extension specified by the argument.
 void upload(java.lang.String name, java.lang.String remoteName)
          See FileTransfer interface for method description.
 void upload(java.lang.String name, java.lang.String remoteName, boolean append)
          See FileTransfer interface for method description.
 void uploadDir(java.io.File localDir)
          See FileTransfer interface for method description.
 void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum, java.lang.String extension)
          Uploads local directory and contents.
 void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum, java.lang.String extension, int threadCount)
          Uploads local directory and contents.
 void uploadDir(java.io.File localDir, java.lang.String extension)
          Uploads local directory and contents recursively to server.
 java.lang.String uploadUnique(java.io.File file)
          See FileTransfer interface for method description.
 java.lang.String uploadUnique(java.io.InputStream in, java.lang.String fileName)
          See FileTransfer interface for method description.
 java.lang.String uploadUnique(java.lang.String fileName)
          See FileTransfer interface for method description.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SftpTransfer

public SftpTransfer(SshParameters parameters,
                    SftpConfiguration configuration,
                    java.util.Set<FileTransferListener> listeners)
Creates SftpTransfer instance.

Parameters:
parameters - the connection parameters
configuration - the configuration

SftpTransfer

public SftpTransfer(SshParameters parameters,
                    SftpConfiguration configuration)
Creates SftpTransfer instance.

Parameters:
parameters - the connection parameters
configuration - the configuration

SftpTransfer

public SftpTransfer(SshParameters parameters)
Creates SftpTransfer instance.

Parameters:
parameters - Connection parameters for SSH protocol

SftpTransfer

public SftpTransfer(java.lang.String host,
                    java.lang.String user,
                    java.lang.String password,
                    int port)
Creates SftpTransfer instance.

Parameters:
host - the hostname of SSH server
user - the username of SSH user
password - the password of SSH user
port - the port of SSH server

SftpTransfer

public SftpTransfer(java.lang.String host,
                    java.lang.String user,
                    java.lang.String pwd)
Creates SftpTransfer instance.

Parameters:
host - the hostname of SSH server
user - the username of SSH user
pwd - the password of SSH user

SftpTransfer

public SftpTransfer(java.lang.String host,
                    java.lang.String user,
                    java.lang.String pwd,
                    java.lang.Integer port)
Creates SftpTransfer instance.

Parameters:
host - the hostname of SSH server
user - the username of SSH user
pwd - the password of SSH user
port - the port of SSH server

SftpTransfer

public SftpTransfer(java.lang.String host,
                    java.lang.String user,
                    java.lang.String pwd,
                    java.io.File privateKey)
Creates SftpTransfer instance.

Parameters:
host - the hostname of SSH server
user - the username of SSH user
pwd - the password of SSH user
privateKey - a private key for session

SftpTransfer

public SftpTransfer(java.lang.String host,
                    java.lang.String user,
                    java.lang.String pwd,
                    int port,
                    SftpConfiguration configuration)
Creates SftpTransfer instance.

Parameters:
host - the hostname of SSH server
user - the username of SSH user
pwd - the password of SSH user
port - the port of SSH server
configuration - Sftp configuration instance.
Method Detail

setAscii

public void setAscii()
              throws FileTransferException
Description copied from interface: FileTransfer
Sets data transfer mode to ASCII. You must be connected to the server prior to invoking this method.

Specified by:
setAscii in interface FileTransfer
Throws:
FileTransferException - exception

setAuto

public void setAuto(boolean auto)
See FileTransfer interface for method description.

Specified by:
setAuto in interface FileTransfer
Parameters:
auto - true to turn automatic detect on false to turn off
See Also:
FileTransfer.setAuto(boolean)

setBinary

public void setBinary()
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
setBinary in interface FileTransfer
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.setBinary()

setBlockTransferSize

public void setBlockTransferSize(int blocksize)
Deprecated. see #setUploadBlockSize

Sets block size for use in transferring files.

Specified by:
setBlockTransferSize in interface FileTransfer
Parameters:
blocksize - the blocksize in bytes

getBlockTransferSize

public int getBlockTransferSize()
Deprecated. see #getUploadBlockSize

Gets blocksize for use in transferring files.

Specified by:
getBlockTransferSize in interface FileTransfer
Returns:
blocksize in bytes

isConnected

public boolean isConnected()
See FileTransfer interface for method description.

Specified by:
isConnected in interface FileTransfer
Returns:
true if connected false otherwise
See Also:
FileTransfer.isConnected()

setDebug

public void setDebug(boolean debug)
See FileTransfer interface for method description.

Specified by:
setDebug in interface FileTransfer
Parameters:
debug - true to turn debugging on
See Also:
FileTransfer.setDebug(boolean)

getDebug

public boolean getDebug()
See FileTransfer interface for method description.

Specified by:
getDebug in interface FileTransfer
Returns:
true if debugging is on
See Also:
FileTransfer.getDebug()

setDebugStream

public void setDebugStream(java.io.PrintStream ps)
See FileTransfer interface for method description.

Specified by:
setDebugStream in interface FileTransfer
Parameters:
ps - the PrintStream to send debug statements to
See Also:
FileTransfer.setDebugStream(PrintStream)

getDebugStream

public java.io.PrintStream getDebugStream()
See FileTransfer interface for method description.

Specified by:
getDebugStream in interface FileTransfer
Returns:
the PrintStream used in reporting debug statements
See Also:
FileTransfer.getDebugStream()

setDir

public void setDir(java.lang.String name)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
setDir in interface FileTransfer
Parameters:
name - the remote directory
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.setDir(String)

getDir

public java.lang.String getDir()
                        throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getDir in interface FileTransfer
Returns:
current directory
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getDir()

getDirListing

public java.util.Enumeration getDirListing()
                                    throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getDirListing in interface FileTransfer
Returns:
an Enumeration of FileTransferRemoteFile objects
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getDirListing()

getDirListing

public java.util.Enumeration getDirListing(java.lang.String filter)
                                    throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getDirListing in interface FileTransfer
Parameters:
filter - the filename filter
Returns:
an Enumeration of FileTransferRemoteFile objects
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getDirListing(String)

getDirListingAsString

public java.lang.String getDirListingAsString()
                                       throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getDirListingAsString in interface FileTransfer
Returns:
a directory listing
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getDirListingAsString()

getDirListingAsString

public java.lang.String getDirListingAsString(java.lang.String filter)
                                       throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getDirListingAsString in interface FileTransfer
Parameters:
filter - a filename filter
Returns:
a directory listing
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getDirListingAsString(String)

setDirUp

public void setDirUp()
              throws FileTransferException
See FileTransfer interface for method description.

Specified by:
setDirUp in interface FileTransfer
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.setDirUp()

setDownloadBlockSize

public void setDownloadBlockSize(int blockSize)
Sets the transfer buffer size for download operation.

Parameters:
blockSize - desired buffer size

getDownloadBlockSize

public int getDownloadBlockSize()
Obtains the current download buffer size.

Returns:
the current download buffer size

setFileTimestamp

public void setFileTimestamp(java.lang.String remoteFile,
                             java.util.Date timestamp)
                      throws FileTransferException
See FileTransfer interface for method description.

Specified by:
setFileTimestamp in interface FileTransfer
Parameters:
remoteFile - the remote file
timestamp - the new date/timestamp
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.setFileTimestamp(String, Date)

setFileModificationTime

public void setFileModificationTime(java.lang.String remoteFile,
                                    java.util.Date modificationTime)
                             throws FileTransferException
Set modification time.

Specified by:
setFileModificationTime in interface FileTransfer
Parameters:
remoteFile - - the remote file.
modificationTime - - the time.
Throws:
FileTransferException

sameChecksum

public boolean sameChecksum(java.io.File localFile,
                            java.lang.String remoteFile)
                     throws FileTransferException
Description copied from interface: FileTransfer
Checks a checksum equality of local and remote files.

Specified by:
sameChecksum in interface FileTransfer
Parameters:
localFile - a local file
remoteFile - a remote file
Returns:
true if checksums are equal; false otherwise
Throws:
FileTransferException - if an error occurs

getFileTimestamp

public java.util.Date getFileTimestamp(java.lang.String remoteFile)
                                throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getFileTimestamp in interface FileTransfer
Parameters:
remoteFile - the remote file
Returns:
date the date/timestamp of remote file
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.getFileTimestamp(String)

getFilesize

public long getFilesize(java.lang.String remoteFile)
                 throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getFilesize in interface FileTransfer
Parameters:
remoteFile - the remote file
Returns:
filesize in bytes
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
FileTransfer.getFilesize(String)

setHostname

public void setHostname(java.lang.String host)
See FileTransfer interface for method description.

Specified by:
setHostname in interface FileTransfer
Parameters:
host - the hostname or IP address of server
See Also:
FileTransfer.setHostname(String)

getHostname

public java.lang.String getHostname()
See FileTransfer interface for method description.

Specified by:
getHostname in interface FileTransfer
Returns:
hostname
See Also:
FileTransfer.getHostname()

getInputStream

public java.io.InputStream getInputStream(java.lang.String filename,
                                          long offset)
                                   throws FileTransferException
Get input stream.

Specified by:
getInputStream in interface FileTransfer
Parameters:
filename - the remote file to get InputStream for
offset - the byte offset, 0 to get full file
Returns:
an InputStream
Throws:
FileTransferException - if an I/O or protocol related error occurs

getImplementation

public java.lang.Object getImplementation()
See FileTransfer interface for method description.

Specified by:
getImplementation in interface FileTransfer
Returns:
underlying file transfer implementation
See Also:
Ftp, Ftps

setLineTerminator

public void setLineTerminator(java.lang.String lineTerminator)
Sets the line terminator for transfer mode ASCII.

Parameters:
lineTerminator - The line terminator

setLocalDir

public void setLocalDir(java.io.File dir)
See FileTransfer interface for method description.

Specified by:
setLocalDir in interface FileTransfer
Parameters:
dir - the local directory
See Also:
FileTransfer.setLocalDir(File)

getLocalDir

public java.io.File getLocalDir()
See FileTransfer interface for method description.

Specified by:
getLocalDir in interface FileTransfer
Returns:
the local directory
See Also:
FileTransfer.getLocalDir()

abortDownloadThread

public void abortDownloadThread(java.lang.String file)
Description copied from interface: FileTransfer
Abort download thread.

Specified by:
abortDownloadThread in interface FileTransfer

abortUploadThread

public void abortUploadThread(java.lang.String file)
Description copied from interface: FileTransfer
Abort upload thread.

Specified by:
abortUploadThread in interface FileTransfer

abortUploadThreads

public void abortUploadThreads()
Abort all upload threads spawned by Sftp instance.

Specified by:
abortUploadThreads in interface FileTransfer

abortDownloadThreads

public void abortDownloadThreads()
Abort all download thrads spawned by Sftp instance.

Specified by:
abortDownloadThreads in interface FileTransfer

getRemoteFileList

public java.util.Vector getRemoteFileList(java.lang.String directory)
                                   throws FileTransferException
Get remote file list.

Specified by:
getRemoteFileList in interface FileTransfer
Returns:
list of files.
Throws:
FileTransferException

getRecursiveDirectorySize

public long getRecursiveDirectorySize(java.lang.String directory)
Get recursive size of all files in directory.

Specified by:
getRecursiveDirectorySize in interface FileTransfer
Returns:
size

getRecursiveDirectoryFileCount

public int getRecursiveDirectoryFileCount(java.lang.String directory)
Get recursive directory file count.

Specified by:
getRecursiveDirectoryFileCount in interface FileTransfer
Returns:
size

getLocalDirListing

public java.util.Enumeration getLocalDirListing()
See FileTransfer interface for method description.

Specified by:
getLocalDirListing in interface FileTransfer
Returns:
an java.util.Enumeration of File
See Also:
FileTransfer.getLocalDirListing()

getMode

public int getMode()
See FileTransfer interface for method description.

Specified by:
getMode in interface FileTransfer
Returns:
the data transfer mode
See Also:
FileTransfer.getMode()

getNameListing

public java.util.Enumeration getNameListing()
                                     throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getNameListing in interface FileTransfer
Returns:
an Enumeration of String where each item represents a file or directory name
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.getNameListing()

getNameListing

public java.util.Enumeration getNameListing(java.lang.String filter)
                                     throws FileTransferException
See FileTransfer interface for method description.

Specified by:
getNameListing in interface FileTransfer
Parameters:
filter - the filename filter
Returns:
an Enumeration of String where each item represents a file or directory name
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.getNameListing(String)

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String filename,
                                            long offset,
                                            boolean append)
                                     throws FileTransferException
Description copied from interface: FileTransfer
Gets OutputStream for writing to remote file.

Specified by:
getOutputStream in interface FileTransfer
Parameters:
filename - the remote filename
offset - the byte offset, 0 to write at beginning of file
append - true to append to remote file, false otherwise
Returns:
an OutputStream
Throws:
FileTransferException - if an I/O or protocol related error occurs

copy

public FileTransfer copy()
Description copied from interface: FileTransfer
Returns a copy of current transfer instance with same listeners.

Specified by:
copy in interface FileTransfer
Returns:
a copy of current transfer instance

setPassive

public void setPassive(boolean passive)
See FileTransfer interface for method description.

Specified by:
setPassive in interface FileTransfer
Parameters:
passive - if true, the transfers will be passive.
See Also:
FileTransfer.setPassive(boolean)

getPassive

public boolean getPassive()
See FileTransfer interface for method description.

Specified by:
getPassive in interface FileTransfer
Returns:
true if passive mode is used, false otherwise
See Also:
FileTransfer.getPassive()

setPassword

public void setPassword(java.lang.String password)
See FileTransfer interface for method description.

Specified by:
setPassword in interface FileTransfer
Parameters:
password - the password
See Also:
FileTransfer.setPassword(String)

getPassword

public java.lang.String getPassword()
See FileTransfer interface for method description.

Specified by:
getPassword in interface FileTransfer
Returns:
the password
See Also:
FileTransfer.getPassword()

setPort

public void setPort(int port)
See FileTransfer interface for method description.

Specified by:
setPort in interface FileTransfer
Parameters:
port - the port
See Also:
FileTransfer.setPort(int)

getPort

public int getPort()
See FileTransfer interface for method description.

Specified by:
getPort in interface FileTransfer
Returns:
server port
See Also:
FileTransfer.getPort()

getPrivateKey

public java.io.File getPrivateKey()
Returns SSH private key used for session

Returns:
private key file.

setProxyAuthentication

public void setProxyAuthentication(java.lang.String proxyUsername,
                                   java.lang.String proxyPassword)
Sets the proxy authentication username and password to use with proxy server. To clear these settings invoke the #clearProxySettings method.

Specified by:
setProxyAuthentication in interface FileTransfer
Parameters:
proxyUsername - the proxy username
proxyPassword - the proxy password
See Also:
clearProxySettings()

setProxyHost

public void setProxyHost(java.lang.String proxyHostname,
                         int proxyPort)
Sets the proxy hostname and port for this connection. To clear these settings invoke the #clearProxySettings method.

Specified by:
setProxyHost in interface FileTransfer
Parameters:
proxyHostname - the hostname or ip address of the proxy server
proxyPort - the port of the proxy server to connect to
See Also:
clearProxySettings()

setProxyType

public void setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection.

Specified by:
setProxyType in interface FileTransfer
Parameters:
proxyType - The proxy type. Values allowed: HTTP, SOCKS5

clearProxySettings

public void clearProxySettings()
Clears proxy server values.

Specified by:
clearProxySettings in interface FileTransfer

setTimeout

public void setTimeout(long timeout)
See FileTransfer interface for method description.

Specified by:
setTimeout in interface FileTransfer
Parameters:
timeout - the timeout in milliseconds
See Also:
FileTransfer.setTimeout(long)

getTimeout

public long getTimeout()
See FileTransfer interface for method description.

Specified by:
getTimeout in interface FileTransfer
Returns:
timeout in milliseconds
See Also:
FileTransfer.getTimeout()

setUploadBlockSize

public void setUploadBlockSize(int blockSize)
Sets the transfer buffer size for upload operation.

Parameters:
blockSize - desired buffer size

getUploadBlockSize

public int getUploadBlockSize()
Obtains the current upload buffer size.

Returns:
the current upload buffer size

setUsername

public void setUsername(java.lang.String username)
See FileTransfer interface for method description.

Specified by:
setUsername in interface FileTransfer
Parameters:
username - the username
See Also:
FileTransfer.setUsername(String)

getUsername

public java.lang.String getUsername()
See FileTransfer interface for method description.

Specified by:
getUsername in interface FileTransfer
Returns:
username
See Also:
FileTransfer.getUsername()

isValidPath

public boolean isValidPath(java.lang.String path)
                    throws FileTransferException
See FileTransfer interface for method description.

Parameters:
path - the absolute path to check
Returns:
true if path is valid, false otherwise
Throws:
FileTransferException - if error occurs

setWireEncoding

public void setWireEncoding(java.lang.String encoding)
Sets encoding set used when issuing commands and transferring files. The default encoding is UTF8

Specified by:
setWireEncoding in interface FileTransfer
Parameters:
encoding - the character encoding to be used

getWireEncoding

public java.lang.String getWireEncoding()
Gets encoding set used when issuing commands and transferring files

Specified by:
getWireEncoding in interface FileTransfer
Returns:
the encoding is being used

addFileTransferListener

public void addFileTransferListener(FileTransferListener listener)
See FileTransfer interface for method description.

Specified by:
addFileTransferListener in interface FileTransfer
Parameters:
listener - the listener to add
See Also:
FileTransfer.addFileTransferListener(FileTransferListener)

connect

public void connect()
             throws FileTransferException
See FileTransfer interface for method description.

Specified by:
connect in interface FileTransfer
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.connect()

setPreserveFileUploadTimestamp

public void setPreserveFileUploadTimestamp(boolean value)
Description copied from interface: FileTransfer
Get preserve file upload timestamps.

Specified by:
setPreserveFileUploadTimestamp in interface FileTransfer

setPreserveFileDownloadTimestamp

public void setPreserveFileDownloadTimestamp(boolean value)
Description copied from interface: FileTransfer
Set preserve file download timestamps.

Specified by:
setPreserveFileDownloadTimestamp in interface FileTransfer

setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Description copied from interface: FileTransfer
Set the timezone, used for preserving timestamps.

Specified by:
setTimeZone in interface FileTransfer

deleteDir

public void deleteDir(java.lang.String name)
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
deleteDir in interface FileTransfer
Parameters:
name - the directory to remove
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.deleteDir(String)

deleteDir

public void deleteDir(java.lang.String name,
                      boolean recursive)
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
deleteDir in interface FileTransfer
Parameters:
name - the directory to remove
recursive - true if it should delete files and subdirectories within directory
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.deleteDir(String, boolean)

exists

public boolean exists(java.lang.String path)
               throws FileTransferException
Description copied from interface: FileTransfer
Checks if the specified path exists on the remote server.

Specified by:
exists in interface FileTransfer
Parameters:
path - a path to verify
Returns:
true if path exists; false otherwise
Throws:
FileTransferException - if an error occurs

deleteFile

public void deleteFile(java.lang.String remoteFile)
                throws FileTransferException
See FileTransfer interface for method description.

Specified by:
deleteFile in interface FileTransfer
Parameters:
remoteFile - name of file to delete
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.deleteFile(String)

disconnect

public void disconnect()
                throws FileTransferException
See FileTransfer interface for method description.

Specified by:
disconnect in interface FileTransfer
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.disconnect()

download

public void download(java.io.OutputStream out,
                     java.lang.String remoteFile)
              throws FileTransferException
See FileTransfer interface for method description.

Specified by:
download in interface FileTransfer
Parameters:
out - the OutputStream to write download to
remoteFile - remote filename
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.download(OutputStream, String)

download

public java.io.File download(java.lang.String remoteFile)
                      throws FileTransferException
See FileTransfer interface for method description.

Specified by:
download in interface FileTransfer
Parameters:
remoteFile - the file to download
Returns:
File the file downloaded
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.download(String)

download

public java.io.File download(java.lang.String localFile,
                             java.lang.String remoteFile)
                      throws FileTransferException
See FileTransfer interface for method description.

Specified by:
download in interface FileTransfer
Parameters:
localFile - destination filename
remoteFile - remote filename
Returns:
File the file downloaded
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.download(String, String)

downloadDir

public void downloadDir(java.lang.String remoteDir)
                 throws FileTransferException
See FileTransfer interface for method description.

Specified by:
downloadDir in interface FileTransfer
Parameters:
remoteDir - the directory to download
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.downloadDir(String)

downloadDir

public void downloadDir(java.lang.String remoteDir,
                        int retryLimit,
                        boolean performChecksum)
                 throws FileTransferException
Downloads remote directory and contents. Downloads are stored relative to current local directory.

Specified by:
downloadDir in interface FileTransfer
Parameters:
remoteDir - the directory to download
retryLimit - Retry number when an error occurs
performChecksum - Checksum perform indicator
Throws:
FileTransferException - if an I/O or FTP error occurs.

downloadDir

public void downloadDir(java.lang.String remoteDir,
                        int retryLimit,
                        boolean performChecksum,
                        int threadCount)
                 throws FileTransferException
Downloads remote directory and contents. Downloads are stored relative to current local directory.

Specified by:
downloadDir in interface FileTransfer
Parameters:
remoteDir - the directory to download
retryLimit - Retry number when an error occurs
performChecksum - Checksum perform indicator
threadCount - the number of threads to start for download.
Throws:
FileTransferException - if an I/O or FTP error occurs.

interrupt

public void interrupt()
See FileTransfer interface for method description.

Specified by:
interrupt in interface FileTransfer
See Also:
FileTransfer.interrupt()

interrupted

public boolean interrupted()
See FileTransfer interface for method description.

Specified by:
interrupted in interface FileTransfer
Returns:
true if transfer process was interrupted.
See Also:
FileTransfer.interrupted()

makeDir

public void makeDir(java.lang.String name)
             throws FileTransferException
See FileTransfer interface for method description.

Specified by:
makeDir in interface FileTransfer
Parameters:
name - name of directory to make
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.makeDir(String)

makeDirRecursive

public void makeDirRecursive(java.lang.String name)
                      throws FileTransferException
See FileTransfer interface for method description.

Specified by:
makeDirRecursive in interface FileTransfer
Parameters:
name - full path of directory to make
Throws:
FileTransferException - if an I/O or server error occurs
See Also:
FileTransfer.makeDirRecursive(String)

makeLocalDir

public java.io.File makeLocalDir(java.lang.String name)
See FileTransfer interface for method description.

Specified by:
makeLocalDir in interface FileTransfer
Parameters:
name - name of directory
Returns:
the directory
See Also:
FileTransfer.makeLocalDir(String)

mdelete

public void mdelete(java.lang.String filter)
             throws FileTransferException
Deletes multiple files matching filter to SFTP server's current directory. Wildcards may be used to specify multiple files e.g. .*\.txt

Specified by:
mdelete in interface FileTransfer
Parameters:
filter - the regular expression filter to use
Throws:
FileTransferException - if an I/O or SFTP error occurs.

mdownload

public void mdownload(java.util.Enumeration fileNames)
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
mdownload in interface FileTransfer
Parameters:
fileNames - filenames of files to download
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.mdownload(Enumeration)

mdownload

public void mdownload(java.lang.String filter)
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
mdownload in interface FileTransfer
Parameters:
filter - the regular expression to use
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.mdownload(String)

mupload

public void mupload(java.util.Enumeration fileNames)
             throws FileTransferException
See FileTransfer interface for method description.

Specified by:
mupload in interface FileTransfer
Parameters:
fileNames - filenames of files to upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.mupload(Enumeration)

mupload

public void mupload(java.lang.String filter)
             throws FileTransferException
See FileTransfer interface for method description.

Specified by:
mupload in interface FileTransfer
Parameters:
filter - the regular expression to use
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.mupload(String)

removeFileTransferListener

public void removeFileTransferListener(FileTransferListener listener)
See FileTransfer interface for method description.

Specified by:
removeFileTransferListener in interface FileTransfer
Parameters:
listener - the listener to remove
See Also:
FileTransfer.removeFileTransferListener(FileTransferListener)

renameFile

public void renameFile(java.lang.String remoteFile,
                       java.lang.String newFile)
                throws FileTransferException
See FileTransfer interface for method description.

Specified by:
renameFile in interface FileTransfer
Parameters:
remoteFile - name of file to rename
newFile - new name of file
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.renameFile(String, String)

reset

public void reset()
See FileTransfer interface for method description.

Specified by:
reset in interface FileTransfer
See Also:
FileTransfer.reset()

resumeDownload

public void resumeDownload(java.lang.String remoteFile,
                           long offset)
                    throws FileTransferException
See FileTransfer interface for method description.

Specified by:
resumeDownload in interface FileTransfer
Parameters:
remoteFile - the file to download
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.resumeDownload(String, long)

resumeDownload

public void resumeDownload(java.lang.String localFile,
                           java.lang.String remoteFile,
                           long offset)
                    throws FileTransferException
See FileTransfer interface for method description.

Specified by:
resumeDownload in interface FileTransfer
Parameters:
localFile - local file name
remoteFile - the file to download
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.resumeDownload(String, String, long)

resumeUpload

public void resumeUpload(java.io.File file,
                         long offset)
                  throws FileTransferException
See FileTransfer interface for method description.

Specified by:
resumeUpload in interface FileTransfer
Parameters:
file - the local file to upload
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.resumeUpload(File, long)

resumeUpload

public void resumeUpload(java.lang.String file,
                         long offset)
                  throws FileTransferException
See FileTransfer interface for method description.

Specified by:
resumeUpload in interface FileTransfer
Parameters:
file - the local file to upload
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.resumeUpload(String, long)

upload

public void upload(byte[] data,
                   java.lang.String name)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
data - the raw contents of the file to upload
name - the filename to store file as on FTP server
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(byte[], String)

upload

public void upload(byte[] data,
                   java.lang.String name,
                   boolean append)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
data - the raw contents of the file to upload
name - the filename to store file as on server
append - true to append to remote file on FTP server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(byte[], String, boolean)

upload

public void upload(java.io.File file)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
file - the local file to upload
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(File)

upload

public void upload(java.io.File file,
                   boolean append)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
file - the local file to upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(File, boolean)

upload

public void upload(java.lang.String extension,
                   java.io.File file)
            throws FileTransferException
Uploads a file to server with the extension specified by the argument. After the file has been uploaded then the file name is renamed to the original file name.

Specified by:
upload in interface FileTransfer
Parameters:
extension - The extension file will be used to upload the file.
file - The file will be uploaded
Throws:
FileTransferException

upload

public void upload(java.io.File file,
                   java.lang.String remoteName)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
file - the local file to upload
remoteName - the destination filename of upload
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(File, String)

upload

public void upload(java.io.File file,
                   java.lang.String remoteName,
                   boolean append)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
file - the local file to upload
remoteName - the destination filename of upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs
See Also:
FileTransfer.upload(File, String, boolean)

upload

public void upload(java.lang.String name)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
name - the local file to upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.upload(String)

upload

public void upload(java.lang.String name,
                   boolean append)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
name - the local file to upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.upload(String, boolean)

upload

public void upload(java.lang.String name,
                   java.lang.String remoteName)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
name - the local file to upload
remoteName - the destination of upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.upload(String, String)

upload

public void upload(java.lang.String name,
                   java.lang.String remoteName,
                   boolean append)
            throws FileTransferException
See FileTransfer interface for method description.

Specified by:
upload in interface FileTransfer
Parameters:
name - the local file to upload
remoteName - the destination of upload
append - true to append to remote file on FTP server, false otherwise
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
FileTransfer.upload(String, String, boolean)

uploadDir

public void uploadDir(java.io.File localDir)
               throws FileTransferException
See FileTransfer interface for method description.

Specified by:
uploadDir in interface FileTransfer
Parameters:
localDir - the directory to upload
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
FileTransfer.uploadDir(File)

uploadDir

public void uploadDir(java.io.File localDir,
                      java.lang.String extension)
               throws FileTransferException
Uploads local directory and contents recursively to server. Uploads are stored relative to current remote directory. Files are uploaded with the extension specified in the argument extension but when the upload has finished the remote file name is renamed to the original file name.

Specified by:
uploadDir in interface FileTransfer
Parameters:
localDir - the directory to upload
extension - The extension file name used to upload each file
Throws:
FileTransferException - if an I/O or FTP error occurs.

uploadDir

public void uploadDir(java.io.File localDir,
                      int retryLimit,
                      boolean performChecksum,
                      java.lang.String extension,
                      int threadCount)
               throws FileTransferException
Uploads local directory and contents. Uploads are stored relative to current remote directory.

Specified by:
uploadDir in interface FileTransfer
Parameters:
localDir - the directory to upload
retryLimit - Retry number when an error occurs
performChecksum - Checksum perform indicator
extension - the extension which will be used to upload the files
threadCount - the thread count
Throws:
FileTransferException - if an I/O or FTP error occurs.

uploadDir

public void uploadDir(java.io.File localDir,
                      int retryLimit,
                      boolean performChecksum,
                      java.lang.String extension)
               throws FileTransferException
Uploads local directory and contents. Uploads are stored relative to current remote directory.

Specified by:
uploadDir in interface FileTransfer
Parameters:
localDir - the directory to upload
retryLimit - Retry number when an error occurs
performChecksum - Checksum perform indicator
extension - The extension which will be used to upload the files
Throws:
FileTransferException - if an I/O or FTP error occurs.

uploadUnique

public java.lang.String uploadUnique(java.lang.String fileName)
                              throws FileTransferException
See FileTransfer interface for method description.

Specified by:
uploadUnique in interface FileTransfer
Parameters:
fileName - the file to be uploaded relative to current local directory
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
FileTransfer.uploadUnique(String)

uploadUnique

public java.lang.String uploadUnique(java.io.File file)
                              throws FileTransferException
See FileTransfer interface for method description.

Specified by:
uploadUnique in interface FileTransfer
Parameters:
file - the file to be uploaded
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
FileTransfer.uploadUnique(File)

uploadUnique

public java.lang.String uploadUnique(java.io.InputStream in,
                                     java.lang.String fileName)
                              throws FileTransferException
See FileTransfer interface for method description.

Specified by:
uploadUnique in interface FileTransfer
Parameters:
in - the InputStream to upload file from
fileName - the filename to be used as seed value for determining unique filename
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
FileTransfer.uploadUnique(InputStream, String)

resumeUpload

public void resumeUpload(java.io.File localFile,
                         java.lang.String remoteFile,
                         long off)
                  throws FileTransferException
Description copied from interface: FileTransfer
Resume upload of file to server.

Specified by:
resumeUpload in interface FileTransfer
Throws:
FileTransferException

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved