Top Fields Constructors Methods
org.apache.sshd.sftp.client.impl

public abstract Class AbstractSftpClient

extends AbstractSubsystemClient
implements FullAccessSftpClient, SftpErrorDataHandler
Class Inheritance
All Implemented Interfaces
org.apache.sshd.sftp.client.SftpErrorDataHandler, org.apache.sshd.sftp.client.FullAccessSftpClient, org.apache.sshd.sftp.client.RawSftpClient, org.apache.sshd.sftp.client.SftpClient, org.apache.sshd.client.subsystem.SubsystemClient, org.apache.sshd.client.channel.ClientChannelHolder, org.apache.sshd.common.channel.ChannelHolder, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable, org.apache.sshd.common.NamedResource, org.apache.sshd.client.session.ClientSessionHolder, org.apache.sshd.common.session.SessionHolder, org.apache.sshd.common.session.SessionContextHolder
Known Direct Subclasses
org.apache.sshd.sftp.client.impl.DefaultSftpClient, org.apache.sshd.sftp.client.fs.SftpFileSystem.Wrapper
Imports
java.io.IOException, .InputStream, java.nio.channels.FileChannel, java.nio.charset.Charset, java.nio.file.attribute.FileTime, java.time.Duration, java.util.ArrayList, .Collection, .Collections, .EnumSet, .List, .Map, .Objects, java.util.concurrent.atomic.AtomicInteger, .AtomicReference, org.apache.sshd.client.channel.ClientChannel, org.apache.sshd.client.subsystem.AbstractSubsystemClient, org.apache.sshd.common.Property, .SshConstants, .SshException, org.apache.sshd.common.channel.Channel, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.Buffer, .ByteArrayBuffer, org.apache.sshd.sftp.SftpModuleProperties, org.apache.sshd.sftp.client.FullAccessSftpClient, .SftpErrorDataHandler, org.apache.sshd.sftp.client.extensions.BuiltinSftpClientExtensions, .SftpClientExtension, .SftpClientExtensionFactory, org.apache.sshd.sftp.common.SftpConstants, .SftpException, .SftpHelper, org.apache.sshd.sftp.common.extensions.ParserUtils

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
protected final SftpErrorDataHandler
private final SftpClient.Attributes
public static final int
private final AtomicReference<Map<String, Object>>
public static final Property<Duration>
SFTP_CLIENT_CMD_TIMEOUT

Property that can be used on the org.apache.sshd.common.FactoryManager to control the internal timeout used by the client to complete the buffer sending in send(int, Buffer).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public String
canonicalPath(String
The requested path - may be relative, and/or contain dots - e.g., ".", "..", "./foo", "../bar"
path
)

Implements org.apache.sshd.sftp.client.SftpClient.canonicalPath.

The effective "normalized" remote path

protected SftpClient.Attributes

Returns:

The decoded response Attributes
checkAttributes
(int
Command to be sent
cmd
,
Buffer
Request Buffer
request
)

protected SftpClient.Attributes
protected void
checkCommandStatus(int
The command to send
cmd
,
Buffer
The request Buffer
request
)

Sends the specified command, waits for the response and then invokes checkResponseStatus(SftpResponse)

protected Buffer

Returns:

a Buffer containing the data received (may be empty), or null if the response was an SSH_FXP_EOF status
checkDataResponse
(SftpAckData
describing the SSH_FXP_READ request
ack
,
SftpResponse
SFTP response received
response
,
AtomicReference<Boolean>
if non-null, set to true if an EOF was received
eofSignalled
)

Processes a response to an SSH_FXP_READ request.

protected List<SftpClient.DirEntry>
protected byte[]

Returns:

The received handle identifier
checkHandle
(int
Command to be sent
cmd
,
Buffer
The Buffer containing the request
request
)

protected byte[]
protected String

Returns:

The retrieved name
checkOneName
(int
Command to be sent
cmd
,
Buffer
The request Buffer
request
)

protected String
protected void
checkResponseStatus(SftpResponse
The received SftpResponse
response
)

Checks if the incoming response is an SSH_FXP_STATUS one, and if so whether the substatus is SSH_FX_OK.

protected void
checkResponseStatus(int
The sent command opcode
cmd
,
int
The request id
id
,
SftpStatus status)

public void
close(SftpClient.Handle
The Handle to close
handle
)

Implements org.apache.sshd.sftp.client.SftpClient.close.

Close the handle obtained from one of the open methods

public void
errorData(byte[]
The buffer of the incoming data
buf
,
int
Offset in buffer to read the data
start
,
int
Available data in buffer
len
)

Implements org.apache.sshd.sftp.client.SftpErrorDataHandler.errorData.

Receive binary data from server error stream

public Channel
public <E extends SftpClientExtension> E
getExtension(Class<? extends E>
The extension type
extensionType
)

Overrides default org.apache.sshd.sftp.client.SftpClient.getExtension.

public SftpClientExtension
protected Map<String, Object>
protected Map<String, Object>
getParsedServerExtensions(Map<String, byte[]> extensions)

protected int
protected String

Returns:

The decoded referenced name
getReferencedName
(int
The command that was sent whose response contains the name to be decoded
cmd
,
Buffer
The Buffer containing the encoded name
buf
,
int
The zero-based order of the requested names for the command - e.g.,
  • When listing a directory's contents each successive name will have an increasing index.
  • For SFTP version 3, when retrieving a single name, short name will have index=0 and the long one index=1.
nameIndex
)

protected int
protected SftpClient.Attributes
protected byte[]
protected IOException

Returns:

The exception to throw - if null then implementor assumed to handle the exception internal. Otherwise, the exception is re-thrown
handleUnexpectedPacket
(int
The expected packet type
expected
,
SftpResponse
The actual SftpResponse received
response
)

protected int
protected List<SftpClient.DirEntry>
protected String
public Iterable<SftpClient.DirEntry>
public void
lock(SftpClient.Handle handle, long offset, long length, int mask)

Implements org.apache.sshd.sftp.client.SftpClient.lock.

public SftpClient.Attributes
lstat(String
The remote path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.lstat.

Retrieve remote path meta-data - do not follow symbolic links

public void
mkdir(String
Remote directory path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.mkdir.

Create remote directory

public SftpClient.CloseableHandle
open(String
The remote path
path
,
Collection<SftpClient.OpenMode>
The desired mode - if none specified then OpenMode#Read is assumed
options
)

Implements org.apache.sshd.sftp.client.SftpClient.open.

Opens a remote file with the specified mode(s)

public SftpClient.CloseableHandle
openDir(String
Remote directory path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.openDir.

Obtain a handle for a directory

public FileChannel
openRemoteFileChannel(String
The remote path
path
,
Collection<SftpClient.OpenMode>
The access mode(s) - if null/empty then the DEFAULT_CHANNEL_MODES are used
modes
)

Implements org.apache.sshd.sftp.client.SftpClient.openRemoteFileChannel.

Opens an FileChannel on the specified remote path

public void
put(InputStream
InputStream to read from
stream
,
int
SFTP packet size; i.e., amount of data to send in a single SFTP request. Most servers have a limit of 256kB. If zero, a default buffer size is chosen depending on the peer's channel packet size; so typically about 32kB.
bufferSize
,
String
The remote file path
path
,
Collection<SftpClient.OpenMode> modes)

Implements org.apache.sshd.sftp.client.SftpClient.put.

Write data from an InputStream to a remote file.

protected <
Type of Buffer being updated
B extends Buffer
>
B

Returns:

The updated buffer
putReferencedName
(int
The command for which this name is being added
cmd
,
B
The buffer instance to update
buf
,
String
The name to place in the buffer
name
,
int
The zero-based order of the name for the specific command if more than one name required - e.g., rename, link/symbolic link
nameIndex
)

public int
read(SftpClient.Handle
The file Handle to read from
handle
,
long
The file offset to read from
fileOffset
,
byte[]
The destination buffer
dst
,
int
Offset in destination buffer to place the read data
dstOffset
,
int
Available destination buffer size to read
len
,
AtomicReference<Boolean>
If not null then upon return holds a value indicating whether EOF was reached due to the read. If null indicator value then this indication is not available
eofSignalled
)

Implements org.apache.sshd.sftp.client.SftpClient.read.

Reads data from the open (file) handle

public InputStream
read(String
The remote file path
path
,
int
The internal read buffer size
bufferSize
,
Collection<SftpClient.OpenMode>
The remote file OpenModes
mode
)

Implements org.apache.sshd.sftp.client.SftpClient.read.

Read a remote file's data via an input stream

protected SftpClient.Attributes
readAttributes(int cmd, Buffer buffer, AtomicInteger nameIndex)

public List<SftpClient.DirEntry>
readDir(SftpClient.Handle
Directory Handle to read from
handle
,
AtomicReference<Boolean>
An indicator that can be used to get information whether end of list has been reached - ignored if null. Upon return, set value indicates whether all entries have been exhausted - a null value means that this information cannot be provided and another call to readDir is necessary in order to verify that no more entries are pending
eolIndicator
)

Implements org.apache.sshd.sftp.client.SftpClient.readDir.

public Iterable<SftpClient.DirEntry>
readDir(String
The remote directory path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.readDir.

public void
remove(String
The remote path to remove
path
)

Implements org.apache.sshd.sftp.client.SftpClient.remove.

public void
protected SftpResponse

Returns:

the SftpResponse
response
(int
the command of the request the response is for
cmd
,
int
the id of the request
requestId
)

Receives a response buffer, validates and returns it as a SftpResponse.

public void
rmdir(String
Remote directory path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.rmdir.

Remove remote directory

protected SftpResponse

Returns:

the SftpResponse for the request
rpc
(int
the SFTP command code
cmd
,
Buffer
a Buffer containing the request data
request
)

Perform an SFTP request and wait until the response has been received.

public void
setStat(String
The remote path
path
,
SftpClient.Attributes
The Attributes to update
attributes
)

Implements org.apache.sshd.sftp.client.SftpClient.setStat.

Update remote node meta-data

public void
setStat(SftpClient.Handle
The Handle obtained via one of the open calls
handle
,
SftpClient.Attributes
The Attributes to update
attributes
)

Implements org.apache.sshd.sftp.client.SftpClient.setStat.

Update remote node meta-data

public SftpClient.Attributes
stat(String
The remote path
path
)

Implements org.apache.sshd.sftp.client.SftpClient.stat.

Retrieve remote path meta-data - follow symbolic links if encountered

public SftpClient.Attributes
stat(SftpClient.Handle
The Handle obtained via one of the open calls
handle
)

Implements org.apache.sshd.sftp.client.SftpClient.stat.

Retrieve file/directory handle meta-data

protected void
throwStatusException(int cmd, int id, SftpStatus status)

public void
unlock(SftpClient.Handle handle, long offset, long length)

Implements org.apache.sshd.sftp.client.SftpClient.unlock.

public void
write(SftpClient.Handle
The file Handle
handle
,
long
Zero-based offset to write in file
fileOffset
,
byte[]
Data buffer
src
,
int
Offset of valid data in buffer
srcOffset
,
int
Number of bytes to write
len
)

Implements org.apache.sshd.sftp.client.SftpClient.write.

Write data to (open) file handle

public SftpOutputStreamAsync
write(String
The remote file path
path
,
int
The internal write buffer size
bufferSize
,
Collection<SftpClient.OpenMode>
The remote file OpenModes
mode
)

Implements org.apache.sshd.sftp.client.SftpClient.write.

Write to a remote file via an output stream

protected <B extends Buffer> B
writeAttributes(int cmd, B buffer, SftpClient.Attributes attributes)

Inherited from org.apache.sshd.client.subsystem.AbstractSubsystemClient:
toString