|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SFtpClient
This class represents the Sftp client. The user is expected to implement all the methods provided in this interface using third party SFTP client implementation.
Method Summary | |
---|---|
boolean |
acceptUnknownHostKeys()
Returns whether to accept keys from unknown SFTP hosts |
void |
cd(String dir)
Changes the working directory on the remote server |
void |
connect()
Connects to the SSH server and authenticates the user using the pre-set authentication method |
void |
disconnect()
Disconnects from the remote server and cleans up the resources |
void |
get(String remotePath,
OutputStream outStream,
SFtpFileTransferMode mode)
Retrieves the file on the remote server and copies it to a stream |
InputStream |
get(String remotePath,
SFtpFileTransferMode mode)
Retrieves the file given the path as a stream |
void |
get(String remotePath,
String localPath,
SFtpFileTransferMode mode)
Retrieves the file on the remote server and copies it on to the local file system |
SFtpAuthMethod |
getAuthenticationMethod()
Retrieves the SFtp client authentication method |
HashMap<String,Object> |
getCustomProperties()
Retrieves additional properties for connecting to SFTP server |
String |
getHostname()
Returns the Host name of the SSH server |
int |
getPort()
Return the port number of the SSH server |
SFtpVersion |
getSSHVersion()
Retrieves the SSH version |
String |
getUserName()
Returns the user name |
List<SFtpFile> |
list()
Returns list of files available in the current working directory on the Remote server |
List<SFtpFile> |
list(String path)
Returns a list of files available on the remote server given the path to the directory |
void |
mkdir(String dir)
Creates a new directory on the remote server. |
void |
mkdirs(String dir)
Create a directory or set of directories. |
void |
put(InputStream inStream,
String remotePath,
SFtpFileTransferMode mode)
Copies the stream on to the remote server |
void |
put(String localPath,
String remotePath,
SFtpFileTransferMode mode)
Copies the local file on to the remote server |
String |
pwd()
Returns the absolute path name of the current remote working directory. |
void |
rename(String oldPath,
String newPath)
Renames the file given the old path and new path to the file |
void |
rm(String path)
Removes the file given the path on the remote server |
void |
rmdir(String path)
Removes the directory given the path on the remote server |
void |
setAcceptUnknownHostKeys(boolean accept)
Sets whether to accept unknown host server keys or not |
void |
setAuthenticationMethod(SFtpAuthMethod authMethod)
Sets the SFtp client authentication method |
void |
setCustomProperties(HashMap<String,Object> props)
Sets the additional properties for connecting to SFTP server |
void |
setPassPhrase(char[] phrase)
Sets the Pass phrase for the private key file |
void |
setPassword(char[] pwd)
Sets the password used for authentication |
void |
setPrivateKeyFile(String path)
Sets the Private key file for authentication |
void |
setSSHVersion(SFtpVersion sshVersion)
Sets the SSH version |
void |
setUserName(String userName)
Sets the user name for authentication |
Method Detail |
---|
void setAuthenticationMethod(SFtpAuthMethod authMethod)
authMethod
- - auth methodSFtpAuthMethod getAuthenticationMethod()
void setAcceptUnknownHostKeys(boolean accept)
accept
- - whether to accept unknown host keysboolean acceptUnknownHostKeys()
void setSSHVersion(SFtpVersion sshVersion)
sshVersion
- - SSH versionSFtpVersion getSSHVersion()
void connect() throws SFtpClientException
SFtpClientException
- - if failed to connect to the server or
failed to authenticate with the servervoid setUserName(String userName)
userName
- - name of the userString getUserName()
String getHostname()
int getPort()
void setPassword(char[] pwd)
pwd
- - passwordvoid setPassPhrase(char[] phrase)
phrase
- - pass phrasevoid setPrivateKeyFile(String path)
path
- - path to the private key filevoid setCustomProperties(HashMap<String,Object> props)
props
- - name value pairsHashMap<String,Object> getCustomProperties()
String pwd() throws SFtpClientException
Returns the absolute path name of the current remote working directory.
SFtpClientException
void cd(String dir) throws SFtpClientException
dir
- - path to the directory
SFtpClientException
void mkdir(String dir) throws SFtpClientException
Creates a new directory on the remote server. This method will throw an
exception if the directory already exists. To create directories and
disregard any errors use the mkdirs
method.
dir
- the name of the new directory
SFtpClientException
void mkdirs(String dir) throws SFtpClientException
Create a directory or set of directories. This method will not fail even
if the directories exist. It is advisable to test whether the directory
exists before attempting an operation by using the stat
method to return the directories attributes.
dir
- the path of directories to create.
SFtpClientException
void rm(String path) throws SFtpClientException
path
- - path to the file to be removed
SFtpClientException
void rmdir(String path) throws SFtpClientException
path
- - path to the directory
SFtpClientException
void rename(String oldPath, String newPath) throws SFtpClientException
oldPath
- - path to the file to be renamednewPath
- - path to the new file name
SFtpClientException
List<SFtpFile> list(String path) throws SFtpClientException
path
- - path to the directory
SFtpClientException
List<SFtpFile> list() throws SFtpClientException
SFtpClientException
InputStream get(String remotePath, SFtpFileTransferMode mode) throws SFtpClientException
remotePath
- - path to the filemode
- - File transfer mode (Binary/ASCII)
SFtpClientException
void get(String remotePath, String localPath, SFtpFileTransferMode mode) throws SFtpClientException
remotePath
- - path to the file on the remote serverlocalPath
- - Path where to copy in the local file systemmode
- - File transfer mode (Binary/ASCII)
SFtpClientException
void get(String remotePath, OutputStream outStream, SFtpFileTransferMode mode) throws SFtpClientException
remotePath
- - path to the file on the remote serveroutStream
- - stream where to copy the remote filemode
- - File transfer mode (Binary/ASCII)
SFtpClientException
void put(String localPath, String remotePath, SFtpFileTransferMode mode) throws SFtpClientException
localPath
- - path to the local fileremotePath
- - path to the remote filemode
- - File transfer mode (Binary/ASCII)
SFtpClientException
void put(InputStream inStream, String remotePath, SFtpFileTransferMode mode) throws SFtpClientException
inStream
- - stream containing the fileremotePath
- - path to the remote filemode
- - File transfer mode (Binary/ASCII)
SFtpClientException
void disconnect() throws SFtpClientException
SFtpClientException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |