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

public Class DefaultSftpClient

extends AbstractSftpClient
Class Inheritance
Imports
java.io.EOFException, .IOException, .InterruptedIOException, .OutputStream, .StreamCorruptedException, java.net.SocketTimeoutException, java.nio.charset.Charset, java.time.Duration, .Instant, java.util.Collection, .Collections, .Iterator, .List, .Map, .NavigableMap, .Objects, .TreeMap, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, org.apache.sshd.client.channel.ChannelSubsystem, .ClientChannel, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.SshConstants, .SshException, org.apache.sshd.common.channel.Channel, .ChannelAsyncOutputStream, org.apache.sshd.common.future.CloseFuture, .DefaultCloseFuture, org.apache.sshd.common.io.IoOutputStream, .IoWriteFuture, org.apache.sshd.common.session.ConnectionService, .Session, org.apache.sshd.common.util.GenericUtils, .MapEntryUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.Buffer, .ByteArrayBuffer, org.apache.sshd.core.CoreModuleProperties, org.apache.sshd.sftp.SftpModuleProperties, org.apache.sshd.sftp.client.SftpErrorDataHandler, .SftpMessage, .SftpVersionSelector, org.apache.sshd.sftp.common.SftpConstants, org.apache.sshd.sftp.common.extensions.ParserUtils, .VersionsParser.Versions, org.apache.sshd.sftp.server.SftpSubsystemEnvironment

Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class

Field Summary

Modifier and TypeField and Description
private final ChannelSubsystem
private final ClientSession
private final AtomicBoolean
private final AtomicInteger
private final NavigableMap<String, byte[]>
private final NavigableMap<String, byte[]>
private final Map<Integer, Buffer>
private Charset
private final Buffer
private final AtomicInteger
Inherited from org.apache.sshd.sftp.client.impl.AbstractSftpClient:
errorDataHandlerINIT_COMMAND_SIZESFTP_CLIENT_CMD_TIMEOUT

Constructor Summary

AccessConstructor and Description
public
DefaultSftpClient(ClientSession clientSession, SftpVersionSelector
The initial SftpVersionSelector - if null then version 6 is assumed.
initialVersionSelector
,
SftpErrorDataHandler
The SftpErrorDataHandler to handle incoming data through the error stream - if null the data is silently ignored
errorDataHandler
)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.nio.channels.Channel.close.

Closes this channel.

protected ChannelSubsystem
protected int

Returns:

Actual size of received data
data
(byte[]
The buffer containing the incoming data
buf
,
int
Offset in buffer to read the data
start
,
int
Available data in buffer
len
)

Receive binary data from server main stream

public ClientChannel
public ClientSession
public Charset
public NavigableMap<String, byte[]>
public int
protected void
protected void
init(ClientSession session, SftpVersionSelector initialVersionSelector, Duration initializationTimeout)

public boolean
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public int

Returns:

The selected version (may be same as current)
negotiateVersion
(SftpVersionSelector
The SftpVersionSelector to use - ignored if null
selector
)

protected void
process(Buffer
The received Buffer
incoming
)

Process an SFTP packet

protected boolean

Returns:

true if data from incoming buffer was processed
receive
(Buffer
The received Buffer
incoming
)

Read SFTP packets from buffer

public Buffer
receive(int
The expected request id
id
)

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

public Buffer
receive(int
The expected request id
id
,
long
The amount of time to wait for the response
idleTimeout
)

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

public Buffer
receive(int
The expected request id
id
,
Duration
The amount of time to wait for the response
idleTimeout
)

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

public int
send(int
Command to send - Note: only lower 8-bits are used
cmd
,
Buffer
The Buffer containing the command data
buffer
)

Implements org.apache.sshd.sftp.client.RawSftpClient.send.

public void
protected Buffer
waitForInitResponse(Duration initializationTimeout)

public SftpMessage
Inherited from org.apache.sshd.sftp.client.impl.AbstractSftpClient:
canonicalPathcheckAttributescheckAttributesResponsecheckCommandStatuscheckDataResponsecheckDirResponsecheckHandlecheckHandleResponsecheckOneNamecheckOneNameResponsecheckResponseStatuscheckResponseStatuscloseerrorDatagetChannelgetExtensiongetExtensiongetParsedServerExtensionsgetParsedServerExtensionsgetReadBufferSizegetReferencedNamegetWriteBufferSizehandleUnexpectedAttributesPackethandleUnexpectedHandlePackethandleUnexpectedPackethandleUnknownDataPackethandleUnknownDirListingPackethandleUnknownOneNamePacketlinklistDirlocklstatmkdiropenopenDiropenRemoteFileChannelputputReferencedNamereadreadreadAttributesreadDirreadDirreadLinkremoverenameresponsermdirrpcsetStatsetStatstatstatthrowStatusExceptionunlockwritewritewriteAttributes

Field Detail

channelback to summary
private final ChannelSubsystem channel
clientSessionback to summary
private final ClientSession clientSession
closingback to summary
private final AtomicBoolean closing
cmdIdback to summary
private final AtomicInteger cmdId
exposedExtensionsback to summary
private final NavigableMap<String, byte[]> exposedExtensions
extensionsback to summary
private final NavigableMap<String, byte[]> extensions
messagesback to summary
private final Map<Integer, Buffer> messages
nameDecodingCharsetback to summary
private Charset nameDecodingCharset
receiveBufferback to summary
private final Buffer receiveBuffer
versionHolderback to summary
private final AtomicInteger versionHolder

Constructor Detail

DefaultSftpClientback to summary
public DefaultSftpClient(ClientSession clientSession, SftpVersionSelector initialVersionSelector, SftpErrorDataHandler errorDataHandler) throws IOException
Parameters
clientSession:ClientSession

The ClientSession

initialVersionSelector:SftpVersionSelector

The initial SftpVersionSelector - if null then version 6 is assumed.

errorDataHandler:SftpErrorDataHandler

The SftpErrorDataHandler to handle incoming data through the error stream - if null the data is silently ignored

Exceptions
IOException:
If failed to initialize

Method Detail

closeback to summary
public void close() throws IOException

Implements java.nio.channels.Channel.close.

Doc from java.nio.channels.Channel.close.

Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
createSftpChannelSubsystemback to summary
protected ChannelSubsystem createSftpChannelSubsystem(ClientSession clientSession)
databack to summary
protected int data(byte[] buf, int start, int len) throws IOException

Receive binary data from server main stream

Parameters
buf:byte[]

The buffer containing the incoming data

start:int

Offset in buffer to read the data

len:int

Available data in buffer

Returns:int

Actual size of received data

Exceptions
IOException:
If failed to receive incoming data
getClientChannelback to summary
public ClientChannel getClientChannel()

Implements org.apache.sshd.client.channel.ClientChannelHolder.getClientChannel.

Returns:ClientChannel

Doc from org.apache.sshd.client.channel.ClientChannelHolder.getClientChannel.

The underlying ClientChannel used

Annotations
@Override
getClientSessionback to summary
public ClientSession getClientSession()

Implements org.apache.sshd.client.session.ClientSessionHolder.getClientSession.

Returns:ClientSession

Doc from org.apache.sshd.client.session.ClientSessionHolder.getClientSession.

The underlying ClientSession used

Annotations
@Override
getNameDecodingCharsetback to summary
public Charset getNameDecodingCharset()

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

Returns:Charset

Doc from org.apache.sshd.sftp.client.SftpClient.getNameDecodingCharset.

The (never null) Charset used to decode referenced files/folders names

Annotations
@Override
getServerExtensionsback to summary
public NavigableMap<String, byte[]> getServerExtensions()

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

Returns:NavigableMap<String, byte[]>

Doc from org.apache.sshd.sftp.client.SftpClient.getServerExtensions.

An (unmodifiable) NavigableMap of the reported server extensions. where key=extension name (case insensitive)

Annotations
@Override
getVersionback to summary
public int getVersion()

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

Returns:int

Doc from org.apache.sshd.sftp.client.SftpClient.getVersion.

The negotiated SFTP protocol version

Annotations
@Override
handleInitResponseback to summary
protected void handleInitResponse(Buffer buffer) throws IOException
initback to summary
protected void init(ClientSession session, SftpVersionSelector initialVersionSelector, Duration initializationTimeout) throws IOException
isClosingback to summary
public boolean isClosing()

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

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
negotiateVersionback to summary
public int negotiateVersion(SftpVersionSelector selector) throws IOException
Parameters
selector:SftpVersionSelector

The SftpVersionSelector to use - ignored if null

Returns:int

The selected version (may be same as current)

Exceptions
IOException:
If failed to negotiate
processback to summary
protected void process(Buffer incoming) throws IOException

Process an SFTP packet

Parameters
incoming:Buffer

The received Buffer

Exceptions
IOException:
if failed to process the buffer
receiveback to summary
protected boolean receive(Buffer incoming) throws IOException

Read SFTP packets from buffer

Parameters
incoming:Buffer

The received Buffer

Returns:boolean

true if data from incoming buffer was processed

Exceptions
IOException:
if failed to process the buffer
See Also
process(Buffer)
receiveback to summary
public Buffer receive(int id) throws IOException

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

Parameters
id:int

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The expected request id

Returns:Buffer

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The received response Buffer containing the request id

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

If connection closed or interrupted

receiveback to summary
public Buffer receive(int id, long idleTimeout) throws IOException

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

Parameters
id:int

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The expected request id

idleTimeout:long

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The amount of time to wait for the response

Returns:Buffer

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The received response Buffer containing the request id

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

If connection closed or interrupted

receiveback to summary
public Buffer receive(int id, Duration idleTimeout) throws IOException

Implements org.apache.sshd.sftp.client.RawSftpClient.receive.

Parameters
id:int

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The expected request id

idleTimeout:Duration

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The amount of time to wait for the response

Returns:Buffer

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

The received response Buffer containing the request id

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.sftp.client.RawSftpClient.receive.

If connection closed or interrupted

sendback to summary
public int send(int cmd, Buffer buffer) throws IOException

Implements org.apache.sshd.sftp.client.RawSftpClient.send.

Parameters
cmd:int

Doc from org.apache.sshd.sftp.client.RawSftpClient.send.

Command to send - Note: only lower 8-bits are used

buffer:Buffer

Doc from org.apache.sshd.sftp.client.RawSftpClient.send.

The Buffer containing the command data

Returns:int

Doc from org.apache.sshd.sftp.client.RawSftpClient.send.

The assigned request id

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.sftp.client.RawSftpClient.send.

if failed to send command

setNameDecodingCharsetback to summary
public void setNameDecodingCharset(Charset nameDecodingCharset)

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

Annotations
@Override
waitForInitResponseback to summary
protected Buffer waitForInitResponse(Duration initializationTimeout) throws IOException
writeback to summary
public SftpMessage write(int cmd, Buffer buffer) throws IOException

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

Annotations
@Override
org.apache.sshd.sftp.client.impl back to summary

protected Class DefaultSftpClient.SftpChannelSubsystem

extends ChannelSubsystem
Class Inheritance

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected ChannelAsyncOutputStream
protected OutputStream
protected OutputStream
protected void
Inherited from org.apache.sshd.client.channel.ChannelSubsystem:
getSubsystemhandleFailurehandleSuccessonClosetoString

Constructor Detail

SftpChannelSubsystemback to summary
protected SftpChannelSubsystem()

Method Detail

createAsyncInputback to summary
protected ChannelAsyncOutputStream createAsyncInput(Session session)
createErrOutputStreamback to summary
protected OutputStream createErrOutputStream(Session session)
createStdOutputStreamback to summary
protected OutputStream createStdOutputStream(Session session)
doOpenback to summary
protected void doOpen() throws IOException

Overrides org.apache.sshd.client.channel.ChannelSubsystem.doOpen.

Annotations
@Override