Class DefaultSftpClient

    • Field Detail

      • messages

        private final java.util.Map<java.lang.Integer,​Buffer> messages
      • cmdId

        private final java.util.concurrent.atomic.AtomicInteger cmdId
      • receiveBuffer

        private final Buffer receiveBuffer
      • workBuf

        private final byte[] workBuf
      • versionHolder

        private final java.util.concurrent.atomic.AtomicInteger versionHolder
      • closing

        private final java.util.concurrent.atomic.AtomicBoolean closing
      • extensions

        private final java.util.NavigableMap<java.lang.String,​byte[]> extensions
      • exposedExtensions

        private final java.util.NavigableMap<java.lang.String,​byte[]> exposedExtensions
      • nameDecodingCharset

        private java.nio.charset.Charset nameDecodingCharset
    • Constructor Detail

      • DefaultSftpClient

        public DefaultSftpClient​(ClientSession clientSession)
                          throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getVersion

        public int getVersion()
        Returns:
        The negotiated SFTP protocol version
      • getServerExtensions

        public java.util.NavigableMap<java.lang.String,​byte[]> getServerExtensions()
        Returns:
        An (unmodifiable) NavigableMap of the reported server extensions. where key=extension name (case insensitive)
      • getNameDecodingCharset

        public java.nio.charset.Charset getNameDecodingCharset()
        Returns:
        The (never null) Charset used to decode referenced files/folders names
        See Also:
        SftpClient.NAME_DECODING_CHARSET
      • setNameDecodingCharset

        public void setNameDecodingCharset​(java.nio.charset.Charset nameDecodingCharset)
      • isClosing

        public boolean isClosing()
      • isOpen

        public boolean isOpen()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • data

        protected int data​(byte[] buf,
                           int start,
                           int len)
                    throws java.io.IOException
        Receive binary data
        Parameters:
        buf - The buffer for the incoming data
        start - Offset in buffer to place the data
        len - Available space in buffer for the data
        Returns:
        Actual size of received data
        Throws:
        java.io.IOException - If failed to receive incoming data
      • receive

        protected boolean receive​(Buffer incoming)
                           throws java.io.IOException
        Read SFTP packets from buffer
        Parameters:
        incoming - The received Buffer
        Returns:
        true if data from incoming buffer was processed
        Throws:
        java.io.IOException - if failed to process the buffer
        See Also:
        process(Buffer)
      • process

        protected void process​(Buffer incoming)
                        throws java.io.IOException
        Process an SFTP packet
        Parameters:
        incoming - The received Buffer
        Throws:
        java.io.IOException - if failed to process the buffer
      • send

        public int send​(int cmd,
                        Buffer buffer)
                 throws java.io.IOException
        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:
        java.io.IOException - if failed to send command
      • receive

        public Buffer receive​(int id)
                       throws java.io.IOException
        Parameters:
        id - The expected request id
        Returns:
        The received response Buffer containing the request id
        Throws:
        java.io.IOException - If connection closed or interrupted
      • read

        protected Buffer read()
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • init

        protected void init​(long initializationTimeout)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • negotiateVersion

        public int negotiateVersion​(SftpVersionSelector selector)
                             throws java.io.IOException
        Parameters:
        selector - The SftpVersionSelector to use - ignored if null
        Returns:
        The selected version (may be same as current)
        Throws:
        java.io.IOException - If failed to negotiate