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
errorDataHandler, INIT_COMMAND_SIZE
log
DEFAULT_CHANNEL_MODES, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZE
BY_NAME_COMPARATOR, NAME_EXTRACTOR
EMPTY
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() |
Charset |
getNameDecodingCharset() |
NavigableMap<String,byte[]> |
getServerExtensions() |
int |
getVersion() |
protected void |
handleInitResponse(Buffer buffer) |
protected void |
init(ClientSession session,
SftpVersionSelector initialVersionSelector,
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,
Duration idleTimeout) |
Buffer |
receive(int id,
long idleTimeout) |
int |
send(int cmd,
Buffer buffer) |
void |
setNameDecodingCharset(Charset nameDecodingCharset) |
protected Buffer |
waitForInitResponse(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, writeAttributes
toString
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
singleSessionInstance
getExtension, 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, write
getSession
getSessionContext
findByName, findFirstMatchByName, getNameList, getNames, ofName, removeByName, safeCompareByName
public DefaultSftpClient(ClientSession clientSession, SftpVersionSelector initialVersionSelector, SftpErrorDataHandler errorDataHandler) throws IOException
clientSession
- The ClientSession
initialVersionSelector
- 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 ignoredIOException
- If failed to initializepublic int getVersion()
public ClientSession getClientSession()
ClientSession
usedpublic ClientChannel getClientChannel()
ClientChannel
usedpublic NavigableMap<String,byte[]> getServerExtensions()
NavigableMap
of the reported server extensions. where key=extension name (case
insensitive)public Charset getNameDecodingCharset()
null
) Charset
used to decode referenced files/folders namesSftpModuleProperties.NAME_DECODING_CHARSET
public void setNameDecodingCharset(Charset nameDecodingCharset)
public boolean isClosing()
public boolean isOpen()
public void close() throws IOException
IOException
protected int data(byte[] buf, int start, int len) throws IOException
buf
- The buffer containing the incoming datastart
- Offset in buffer to read the datalen
- Available data in bufferIOException
- If failed to receive incoming dataprotected boolean receive(Buffer incoming) throws IOException
incoming
- The received Buffer
true
if data from incoming buffer was processedIOException
- if failed to process the bufferprocess(Buffer)
protected void process(Buffer incoming) throws IOException
incoming
- The received Buffer
IOException
- if failed to process the bufferpublic int send(int cmd, Buffer buffer) throws IOException
cmd
- Command to send - Note: only lower 8-bits are usedbuffer
- The Buffer
containing the command dataIOException
- if failed to send commandpublic Buffer receive(int id) throws IOException
id
- The expected request idBuffer
containing the request idIOException
- If connection closed or interruptedpublic Buffer receive(int id, long idleTimeout) throws IOException
id
- The expected request ididleTimeout
- The amount of time to wait for the responseBuffer
containing the request idIOException
- If connection closed or interruptedpublic Buffer receive(int id, Duration idleTimeout) throws IOException
id
- The expected request ididleTimeout
- The amount of time to wait for the responseBuffer
containing the request idIOException
- If connection closed or interruptedprotected void init(ClientSession session, SftpVersionSelector initialVersionSelector, Duration initializationTimeout) throws IOException
IOException
protected void handleInitResponse(Buffer buffer) throws IOException
IOException
protected Buffer waitForInitResponse(Duration initializationTimeout) throws IOException
IOException
public int negotiateVersion(SftpVersionSelector selector) throws IOException
selector
- The SftpVersionSelector
to use - ignored if null
IOException
- If failed to negotiateprotected ChannelSubsystem createSftpChannelSubsystem(ClientSession clientSession)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.