Class AbstractSftpClientExtension

java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.sftp.client.extensions.helpers.AbstractSftpClientExtension
All Implemented Interfaces:
NamedResource, OptionalFeature, SftpClientExtension, RawSftpClient, SftpClientHolder
Direct Known Subclasses:
AbstractCheckFileExtension, AbstractMD5HashExtension, AbstractOpenSSHStatCommandExtension, CopyDataExtensionImpl, CopyFileExtensionImpl, FilenameTranslationControlExtensionImpl, OpenSSHFsyncExtensionImpl, OpenSSHLimitsExtensionImpl, OpenSSHPosixRenameExtensionImpl, SpaceAvailableExtensionImpl

public abstract class AbstractSftpClientExtension extends org.apache.sshd.common.util.logging.AbstractLoggingBean implements SftpClientExtension, RawSftpClient
Author:
Apache MINA SSHD Project
  • Constructor Details

  • Method Details

    • getName

      public final String getName()
      Specified by:
      getName in interface NamedResource
    • getClient

      public final SftpClient getClient()
      Specified by:
      getClient in interface SftpClientHolder
    • sendAndCheckExtendedCommandStatus

      protected void sendAndCheckExtendedCommandStatus(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Throws:
      IOException
    • sendExtendedCommand

      protected int sendExtendedCommand(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Throws:
      IOException
    • send

      public int send(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Specified by:
      send in interface RawSftpClient
      Parameters:
      cmd - Command to send - Note: only lower 8-bits are used
      buffer - The Buffer containing 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
      Specified by:
      write in interface RawSftpClient
      Throws:
      IOException
    • receive

      public org.apache.sshd.common.util.buffer.Buffer receive(int id) throws IOException
      Specified by:
      receive in interface RawSftpClient
      Parameters:
      id - The expected request id
      Returns:
      The received response Buffer containing the request id
      Throws:
      IOException - If connection closed or interrupted
    • receive

      public org.apache.sshd.common.util.buffer.Buffer receive(int id, long timeout) throws IOException
      Specified by:
      receive in interface RawSftpClient
      Parameters:
      id - The expected request id
      timeout - The amount of time to wait for the response
      Returns:
      The received response Buffer containing the request id
      Throws:
      IOException - If connection closed or interrupted
    • receive

      public org.apache.sshd.common.util.buffer.Buffer receive(int id, Duration timeout) throws IOException
      Specified by:
      receive in interface RawSftpClient
      Parameters:
      id - The expected request id
      timeout - The amount of time to wait for the response
      Returns:
      The received response Buffer containing the request id
      Throws:
      IOException - If connection closed or interrupted
    • isSupported

      public final boolean isSupported()
      Specified by:
      isSupported in interface OptionalFeature
    • checkStatus

      protected void checkStatus(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Throws:
      IOException
    • putTarget

      public org.apache.sshd.common.util.buffer.Buffer putTarget(org.apache.sshd.common.util.buffer.Buffer buffer, Object target)
      Parameters:
      buffer - The Buffer
      target - A target path String or SftpClient.Handle or byte[] to be encoded in the buffer
      Returns:
      The updated buffer
      Throws:
      UnsupportedOperationException - If target is not one of the above supported types
    • getCommandBuffer

      protected org.apache.sshd.common.util.buffer.Buffer getCommandBuffer(Object target)
      Parameters:
      target - A target path String or SftpClient.Handle or byte[] to be encoded in the buffer
      Returns:
      A Buffer with the extension name set
      See Also:
    • getCommandBuffer

      protected org.apache.sshd.common.util.buffer.Buffer getCommandBuffer(Object target, int extraSize)
      Parameters:
      target - A target path String or SftpClient.Handle or byte[] to be encoded in the buffer
      extraSize - Extra size - beyond the path/handle to be allocated
      Returns:
      A Buffer with the extension name set
      See Also:
    • getCommandBuffer

      protected org.apache.sshd.common.util.buffer.Buffer getCommandBuffer(int extraSize)
      Parameters:
      extraSize - Extra size - besides the extension name
      Returns:
      A Buffer with the extension name set
    • checkExtendedReplyBuffer

      protected org.apache.sshd.common.util.buffer.Buffer checkExtendedReplyBuffer(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Parameters:
      buffer - The Buffer to check
      Returns:
      The Buffer if this is an SftpConstants.SSH_FXP_EXTENDED_REPLY, or null if this is a SftpConstants.SSH_FXP_STATUS carrying an SftpConstants.SSH_FX_OK result
      Throws:
      IOException - If a non-SftpConstants.SSH_FX_OK result or not a SftpConstants.SSH_FXP_EXTENDED_REPLY buffer
    • throwStatusException

      protected void throwStatusException(int id, SftpStatus status) throws IOException
      Throws:
      IOException