Package org.apache.sshd.sftp.client.impl
Class DefaultSftpClient
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.client.subsystem.AbstractSubsystemClient
org.apache.sshd.sftp.client.impl.AbstractSftpClient
org.apache.sshd.sftp.client.impl.DefaultSftpClient
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ClientChannelHolder,ClientSessionHolder,SubsystemClient,ChannelHolder,NamedResource,SessionContextHolder,SessionHolder<ClientSession>,FullAccessSftpClient,RawSftpClient,SftpClient,SftpErrorDataHandler
- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.sshd.sftp.client.SftpClient
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenMode -
Field Summary
Fields inherited from class org.apache.sshd.sftp.client.impl.AbstractSftpClient
errorDataHandler, INIT_COMMAND_SIZE, SFTP_CLIENT_CMD_TIMEOUTFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTORFields inherited from interface org.apache.sshd.sftp.client.SftpClient
DEFAULT_CHANNEL_MODES, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZEFields inherited from interface org.apache.sshd.sftp.client.SftpErrorDataHandler
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSftpClient(ClientSession clientSession, SftpVersionSelector initialVersionSelector, SftpErrorDataHandler errorDataHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected ChannelSubsystemcreateSftpChannelSubsystem(ClientSession clientSession) protected intdata(byte[] buf, int start, int len) Receive binary data from server main streamNavigableMap<String, byte[]> intprotected voidhandleInitResponse(org.apache.sshd.common.util.buffer.Buffer buffer) protected voidinit(ClientSession session, SftpVersionSelector initialVersionSelector, Duration initializationTimeout) booleanbooleanisOpen()intnegotiateVersion(SftpVersionSelector selector) protected voidprocess(org.apache.sshd.common.util.buffer.Buffer incoming) Process an SFTP packetorg.apache.sshd.common.util.buffer.Bufferreceive(int id) org.apache.sshd.common.util.buffer.Bufferreceive(int id, long idleTimeout) org.apache.sshd.common.util.buffer.Bufferprotected booleanreceive(org.apache.sshd.common.util.buffer.Buffer incoming) Read SFTP packets from bufferintsend(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) voidsetNameDecodingCharset(Charset nameDecodingCharset) protected org.apache.sshd.common.util.buffer.BufferwaitForInitResponse(Duration initializationTimeout) write(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) Methods inherited from class org.apache.sshd.sftp.client.impl.AbstractSftpClient
canonicalPath, checkAttributes, checkAttributesResponse, checkCommandStatus, 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, put, putReferencedName, read, read, readAttributes, readDir, readDir, readLink, remove, rename, response, rmdir, rpc, setStat, setStat, stat, stat, throwStatusException, unlock, write, write, writeAttributesMethods inherited from class org.apache.sshd.client.subsystem.AbstractSubsystemClient
toStringMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContextMethods inherited from interface org.apache.sshd.sftp.client.SftpClient
getExtension, getName, open, open, openRemoteFileChannel, openRemotePathChannel, openRemotePathChannel, put, put, put, put, put, put, put, put, put, put, put, read, read, read, read, read, read, read, read, readDir, readEntries, rename, rename, singleSessionInstance, symLink, write, write, write, write, write, writeMethods inherited from interface org.apache.sshd.client.subsystem.SubsystemClient
getSession
-
Constructor Details
-
DefaultSftpClient
public DefaultSftpClient(ClientSession clientSession, SftpVersionSelector initialVersionSelector, SftpErrorDataHandler errorDataHandler) throws IOException - Parameters:
clientSession- TheClientSessioninitialVersionSelector- The initialSftpVersionSelector- ifnullthen version 6 is assumed.errorDataHandler- TheSftpErrorDataHandlerto handle incoming data through the error stream - ifnullthe data is silently ignored- Throws:
IOException- If failed to initialize
-
-
Method Details
-
getVersion
public int getVersion()- Returns:
- The negotiated SFTP protocol version
-
getClientSession
-
getClientChannel
-
getServerExtensions
- Returns:
- An (unmodifiable)
NavigableMapof the reported server extensions. where key=extension name (case insensitive)
-
getNameDecodingCharset
- Returns:
- The (never
null)Charsetused to decode referenced files/folders names - See Also:
-
setNameDecodingCharset
-
isClosing
public boolean isClosing() -
isOpen
public boolean isOpen() -
close
- Throws:
IOException
-
data
Receive binary data from server main stream- Parameters:
buf- The buffer containing the incoming datastart- Offset in buffer to read the datalen- Available data in buffer- Returns:
- Actual size of received data
- Throws:
IOException- If failed to receive incoming data
-
receive
Read SFTP packets from buffer- Parameters:
incoming- The receivedBuffer- Returns:
trueif data from incoming buffer was processed- Throws:
IOException- if failed to process the buffer- See Also:
-
process
Process an SFTP packet- Parameters:
incoming- The receivedBuffer- Throws:
IOException- if failed to process the buffer
-
send
- Parameters:
cmd- Command to send - Note: only lower 8-bits are usedbuffer- TheBuffercontaining the command data- Returns:
- The assigned request id
- Throws:
IOException- if failed to send command
-
write
public SftpMessage write(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException - Throws:
IOException
-
receive
- Parameters:
id- The expected request id- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
receive
public org.apache.sshd.common.util.buffer.Buffer receive(int id, long idleTimeout) throws IOException - Parameters:
id- The expected request ididleTimeout- The amount of time to wait for the response- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
receive
public org.apache.sshd.common.util.buffer.Buffer receive(int id, Duration idleTimeout) throws IOException - Parameters:
id- The expected request ididleTimeout- The amount of time to wait for the response- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
init
protected void init(ClientSession session, SftpVersionSelector initialVersionSelector, Duration initializationTimeout) throws IOException - Throws:
IOException
-
handleInitResponse
protected void handleInitResponse(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException - Throws:
IOException
-
waitForInitResponse
protected org.apache.sshd.common.util.buffer.Buffer waitForInitResponse(Duration initializationTimeout) throws IOException - Throws:
IOException
-
negotiateVersion
- Parameters:
selector- TheSftpVersionSelectorto use - ignored ifnull- Returns:
- The selected version (may be same as current)
- Throws:
IOException- If failed to negotiate
-
createSftpChannelSubsystem
-