|
Secure iNet Factory | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jscape.inet.sftp.SftpClient
public class SftpClient
The SFTP client. Takes responsibility for protocol request/response exchange and transform occured errors to the appropriate exceptions.
| Field Summary | |
|---|---|
static int |
VERSION
The client version |
| Constructor Summary | |
|---|---|
SftpClient(com.jscape.inet.util.connection.Connection connection,
SftpConfiguration config)
Creates a new client instance. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the current client. |
void |
close(byte[] handle)
Closes the file or directory handle. |
boolean |
containsExtension(java.lang.String name)
Checks if the client contains the specified server extension. |
static SftpClient |
create(java.lang.Class clientClass,
com.jscape.inet.util.connection.Connection connection,
SftpConfiguration config)
Creates a SFTP client instance. |
SftpFileAttributes |
fstat(byte[] handle)
Obtains the remote file attributes. |
java.lang.String |
getCharset()
|
com.jscape.inet.util.connection.Connection |
getConnection()
Returns the client session channel. |
byte[] |
getExtension(java.lang.String name)
Obtains the specified server extension. |
JFile |
getFile(JFile parent,
java.lang.String child)
Creates a new JFile instance from a parent abstract pathname and a child pathname string. |
JFile |
getFile(JFile parent,
java.lang.String child,
SftpFileAttributes attrs)
Creates a new JFile instance from a parent abstract pathname and a child pathname string. |
JFile |
getFile(java.lang.String pathname)
Creates a new JFile instance by converting the given pathname string into an abstract pathname. |
java.lang.String |
getStringExtension(java.lang.String name)
Obtains the specified string server extension. |
int |
getVersion()
Returns the client protocol version. |
boolean |
isClosed()
Checks if the current client is already closed. |
boolean |
knowsPacket(int type)
Checks if the client knows this packet, i.e. |
SftpFileAttributes |
lstat(java.lang.String path)
Obtains the link target attributes. |
void |
mkdir(java.lang.String path,
SftpFileAttributes attrs)
Creates a new directory. |
byte[] |
open(java.lang.String path,
JFileOpenFlags flags,
JAcl.Mask accessType,
SftpFileAttributes attrs)
Opens or creates the file. |
byte[] |
opendir(java.lang.String path)
Opens the remote directory for listing. |
byte[] |
read(byte[] handle,
long offset,
int len)
Reads the file content. |
SftpName[] |
readdir(byte[] handle)
Reads the directory content. |
java.lang.String |
realPath(java.lang.String path)
Obtains the real file path in the remote system. |
void |
registerPacket(int type,
java.lang.Class packetClass)
Adds the packet to the client. |
void |
remove(java.lang.String fileName)
Deletes the file. |
void |
rmdir(java.lang.String path)
Removes the directory. |
SftpPacket |
sendRequest(SftpPacket request)
Sends the request to the server. |
void |
setCharset(java.lang.String charset)
|
void |
setFstat(byte[] handle,
SftpFileAttributes attrs)
Setups the remote file attributes. |
void |
setStat(java.lang.String path,
SftpFileAttributes attrs)
Setups the remote file attributes. |
SftpFileAttributes |
stat(java.lang.String path)
Obtains the remote file attributes. |
void |
unregisterPacket(int type)
Removes the packet from the client. |
void |
write(byte[] handle,
long offset,
byte[] data)
Writes the data to the file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int VERSION
| Constructor Detail |
|---|
public SftpClient(com.jscape.inet.util.connection.Connection connection,
SftpConfiguration config)
throws java.io.IOException
connection - the session connectionconfig - the configuration
SftpException - if an I/O or SFTP error occurs.
java.io.IOException| Method Detail |
|---|
public static SftpClient create(java.lang.Class clientClass,
com.jscape.inet.util.connection.Connection connection,
SftpConfiguration config)
throws SftpException
clientClass - the target client classconnection - the connectionconfig - the SFTP configuration
SftpException - if an I/O or protocol error occurs
public void registerPacket(int type,
java.lang.Class packetClass)
type - the packet typepacketClass - the packet classpublic void unregisterPacket(int type)
type - public boolean knowsPacket(int type)
type - the packet type
true if the packet is registered;
false otherwisepublic void close()
close in interface JFileSystempublic boolean isClosed()
isClosed in interface JFileSystemtrue if the client is closed;
false otherwisepublic int getVersion()
public com.jscape.inet.util.connection.Connection getConnection()
public boolean containsExtension(java.lang.String name)
name - the server extension name
true if the client contains extension;
false otherwisepublic byte[] getExtension(java.lang.String name)
name - the server extension to obtain
public java.lang.String getStringExtension(java.lang.String name)
name - the server extension to obtain
public JFile getFile(java.lang.String pathname)
getFile in interface JFileSystempathname - a pathname string
public JFile getFile(JFile parent,
java.lang.String child)
getFile in interface JFileSystemparent - the parent abstract pathnamechild - the child pathname string
public JFile getFile(JFile parent,
java.lang.String child,
SftpFileAttributes attrs)
parent - the parent abstract pathnamechild - the child pathname stringattrs -
public SftpPacket sendRequest(SftpPacket request)
throws SftpException
request - the request to send
SftpException - if an I/O or SFTP error occurs.
public byte[] open(java.lang.String path,
JFileOpenFlags flags,
JAcl.Mask accessType,
SftpFileAttributes attrs)
throws SftpException
path - the file pathflags - the open flagsaccessType - file access typeattrs - the file attributes
SftpException - if an I/O or SFTP error occurs.
public void close(byte[] handle)
throws SftpException
handle - the handle to close
SftpException - if an I/O or SFTP error occurs.
public byte[] read(byte[] handle,
long offset,
int len)
throws SftpException
handle - the file handleoffset - the file offsetlen - desired data length
SftpException - if an I/O or SFTP error occurs.
public void write(byte[] handle,
long offset,
byte[] data)
throws SftpException
handle - the file handleoffset - the file offsetdata - the data to write
SftpException - if an I/O or SFTP error occurs.
public void remove(java.lang.String fileName)
throws SftpException
fileName - the file to delete
SftpException - if an I/O or SFTP error occurs.
public void mkdir(java.lang.String path,
SftpFileAttributes attrs)
throws SftpException
path - the directory pathattrs - the directory attributes
SftpException - if an I/O or SFTP error occurs.
public void rmdir(java.lang.String path)
throws SftpException
path - the directory to remove
SftpException - if an I/O or SFTP error occurs.
public byte[] opendir(java.lang.String path)
throws SftpException
path - the directory path
SftpException - if an I/O or SFTP error occurs.
public SftpName[] readdir(byte[] handle)
throws SftpException
handle - the directory handle
SftpException - if an I/O or SFTP error occurs.
public SftpFileAttributes stat(java.lang.String path)
throws SftpException
path - the file path
SftpException - if an I/O or SFTP error occurs.
public SftpFileAttributes lstat(java.lang.String path)
throws SftpException
path - the link path
SftpException - if an I/O or SFTP error occurs.
public SftpFileAttributes fstat(byte[] handle)
throws SftpException
handle - the file handle
SftpException - if an I/O or SFTP error occurs.
public void setStat(java.lang.String path,
SftpFileAttributes attrs)
throws SftpException
path - the file pathattrs - desired file attributes
SftpException - if an I/O or SFTP error occurs.
public void setFstat(byte[] handle,
SftpFileAttributes attrs)
throws SftpException
handle - the file handleattrs - desired file attributes
SftpException - if an I/O or SFTP error occurs.
public java.lang.String realPath(java.lang.String path)
throws SftpException
path - the file path
SftpException - if an I/O or SFTP error occurs.public java.lang.String getCharset()
public void setCharset(java.lang.String charset)
|
Secure iNet Factory | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||