public class DefaultSftpClient extends AbstractSftpClient
| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultSftpClient.SftpChannelSubsystem |
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenMode| Modifier and Type | Field and Description |
|---|---|
private ChannelSubsystem |
channel |
private ClientSession |
clientSession |
private java.util.concurrent.atomic.AtomicBoolean |
closing |
private java.util.concurrent.atomic.AtomicInteger |
cmdId |
private java.util.NavigableMap<java.lang.String,byte[]> |
exposedExtensions |
private java.util.NavigableMap<java.lang.String,byte[]> |
extensions |
private java.util.Map<java.lang.Integer,Buffer> |
messages |
private java.nio.charset.Charset |
nameDecodingCharset |
private Buffer |
receiveBuffer |
private java.util.concurrent.atomic.AtomicInteger |
versionHolder |
errorDataHandler, INIT_COMMAND_SIZElogDEFAULT_CHANNEL_MODES, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZEBY_NAME_COMPARATOR, NAME_EXTRACTOREMPTY| Constructor and Description |
|---|
DefaultSftpClient(ClientSession clientSession,
SftpVersionSelector initialVersionSelector,
SftpErrorDataHandler errorDataHandler) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected ChannelSubsystem |
createSftpChannelSubsystem(ClientSession clientSession) |
protected int |
data(byte[] buf,
int start,
int len)
Receive binary data from server main stream
|
ClientChannel |
getClientChannel() |
ClientSession |
getClientSession() |
java.nio.charset.Charset |
getNameDecodingCharset() |
java.util.NavigableMap<java.lang.String,byte[]> |
getServerExtensions() |
int |
getVersion() |
protected void |
handleInitResponse(Buffer buffer) |
protected void |
init(ClientSession session,
SftpVersionSelector initialVersionSelector,
java.time.Duration initializationTimeout) |
boolean |
isClosing() |
boolean |
isOpen() |
int |
negotiateVersion(SftpVersionSelector selector) |
protected void |
process(Buffer incoming)
Process an SFTP packet
|
protected boolean |
receive(Buffer incoming)
Read SFTP packets from buffer
|
Buffer |
receive(int id) |
Buffer |
receive(int id,
java.time.Duration idleTimeout) |
Buffer |
receive(int id,
long idleTimeout) |
int |
send(int cmd,
Buffer buffer) |
void |
setNameDecodingCharset(java.nio.charset.Charset nameDecodingCharset) |
protected Buffer |
waitForInitResponse(java.time.Duration initializationTimeout) |
canonicalPath, checkAttributes, checkAttributesResponse, checkCommandStatus, checkData, checkDataResponse, checkDirResponse, checkHandle, checkHandleResponse, checkOneName, checkOneNameResponse, checkResponseStatus, checkResponseStatus, close, errorData, getChannel, getExtension, getExtension, getParsedServerExtensions, getParsedServerExtensions, getReadBufferSize, getReferencedName, getWriteBufferSize, handleUnexpectedAttributesPacket, handleUnexpectedHandlePacket, handleUnexpectedPacket, handleUnknownDataPacket, handleUnknownDirListingPacket, handleUnknownOneNamePacket, link, listDir, lock, lstat, mkdir, open, openDir, openRemoteFileChannel, putReferencedName, read, read, readAttributes, readDir, readDir, readLink, remove, rename, rmdir, setStat, setStat, stat, stat, throwStatusException, unlock, validateIncomingResponse, write, write, writeAttributestoStringdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsingleSessionInstancegetExtension, getName, open, open, openRemoteFileChannel, openRemotePathChannel, openRemotePathChannel, read, read, read, read, read, read, read, read, readDir, readEntries, rename, rename, singleSessionInstance, symLink, write, write, write, write, write, writegetSessiongetSessionContextfindByName, findFirstMatchByName, getNameList, getNames, ofName, removeByName, safeCompareByNameprivate final ClientSession clientSession
private final ChannelSubsystem channel
private final java.util.Map<java.lang.Integer,Buffer> messages
private final java.util.concurrent.atomic.AtomicInteger cmdId
private final Buffer receiveBuffer
private final java.util.concurrent.atomic.AtomicInteger versionHolder
private final java.util.concurrent.atomic.AtomicBoolean closing
private final java.util.NavigableMap<java.lang.String,byte[]> extensions
private final java.util.NavigableMap<java.lang.String,byte[]> exposedExtensions
private java.nio.charset.Charset nameDecodingCharset
public DefaultSftpClient(ClientSession clientSession, SftpVersionSelector initialVersionSelector, SftpErrorDataHandler errorDataHandler) throws java.io.IOException
clientSession - The ClientSessioninitialVersionSelector - The initial SftpVersionSelector - if null then version 6 is
assumed.errorDataHandler - The SftpErrorDataHandler to handle incoming data through the error stream
- if null the data is silently ignoredjava.io.IOException - If failed to initializepublic int getVersion()
public ClientSession getClientSession()
ClientSession usedpublic ClientChannel getClientChannel()
ClientChannel usedpublic java.util.NavigableMap<java.lang.String,byte[]> getServerExtensions()
NavigableMap of the reported server extensions. where key=extension name (case
insensitive)public java.nio.charset.Charset getNameDecodingCharset()
null) Charset used to decode referenced files/folders namesSftpModuleProperties.NAME_DECODING_CHARSETpublic void setNameDecodingCharset(java.nio.charset.Charset nameDecodingCharset)
public boolean isClosing()
public boolean isOpen()
public void close()
throws java.io.IOException
java.io.IOExceptionprotected int data(byte[] buf,
int start,
int len)
throws java.io.IOException
buf - The buffer containing the incoming datastart - Offset in buffer to read the datalen - Available data in bufferjava.io.IOException - If failed to receive incoming dataprotected boolean receive(Buffer incoming) throws java.io.IOException
incoming - The received Buffertrue if data from incoming buffer was processedjava.io.IOException - if failed to process the bufferprocess(Buffer)protected void process(Buffer incoming) throws java.io.IOException
incoming - The received Bufferjava.io.IOException - if failed to process the bufferpublic int send(int cmd,
Buffer buffer)
throws java.io.IOException
cmd - Command to send - Note: only lower 8-bits are usedbuffer - The Buffer containing the command datajava.io.IOException - if failed to send commandpublic Buffer receive(int id) throws java.io.IOException
id - The expected request idBuffer containing the request idjava.io.IOException - If connection closed or interruptedpublic Buffer receive(int id, long idleTimeout) throws java.io.IOException
id - The expected request ididleTimeout - The amount of time to wait for the responseBuffer containing the request idjava.io.IOException - If connection closed or interruptedpublic Buffer receive(int id, java.time.Duration idleTimeout) throws java.io.IOException
id - The expected request ididleTimeout - The amount of time to wait for the responseBuffer containing the request idjava.io.IOException - If connection closed or interruptedprotected void init(ClientSession session, SftpVersionSelector initialVersionSelector, java.time.Duration initializationTimeout) throws java.io.IOException
java.io.IOExceptionprotected void handleInitResponse(Buffer buffer) throws java.io.IOException
java.io.IOExceptionprotected Buffer waitForInitResponse(java.time.Duration initializationTimeout) throws java.io.IOException
java.io.IOExceptionpublic int negotiateVersion(SftpVersionSelector selector) throws java.io.IOException
selector - The SftpVersionSelector to use - ignored if nulljava.io.IOException - If failed to negotiateprotected ChannelSubsystem createSftpChannelSubsystem(ClientSession clientSession)