Class TransportImpl

    • Constructor Detail

      • TransportImpl

        public TransportImpl​(Config config)
    • Method Detail

      • init

        public void init​(java.lang.String remoteHost,
                         int remotePort,
                         java.io.InputStream in,
                         java.io.OutputStream out)
                  throws TransportException
        Description copied from interface: Transport
        Sets the host information and the streams to be used by this transport. Identification information is exchanged with the server. A TransportException is thrown in case of SSH protocol version incompatibility.
        Specified by:
        init in interface Transport
        Parameters:
        remoteHost - server's hostname
        remotePort - server's port
        in - input stream for the connection
        out - output stream for the connection
        Throws:
        TransportException - if there is an error during exchange of identification information
      • getRemoteSocketAddress

        public java.net.InetSocketAddress getRemoteSocketAddress()
        Get Remote Socket Address using Connection Information
        Specified by:
        getRemoteSocketAddress in interface RemoteAddressProvider
        Returns:
        Remote Socket Address or null when not connected
      • addAlgorithmsVerifier

        public void addAlgorithmsVerifier​(AlgorithmsVerifier verifier)
        Description copied from interface: Transport
        Adds the specified verifier.
        Specified by:
        addAlgorithmsVerifier in interface Transport
        Parameters:
        verifier - The verifier to call with negotiated algorithms
      • doKex

        public void doKex()
                   throws TransportException
        Description copied from interface: Transport
        Do key exchange and algorithm negotiation. This can be the initial one or for algorithm renegotiation.
        Specified by:
        doKex in interface Transport
        Throws:
        TransportException - if there was an error during key exchange
      • isKexDone

        public boolean isKexDone()
      • getTimeoutMs

        public int getTimeoutMs()
        Specified by:
        getTimeoutMs in interface Transport
        Returns:
        the timeout that is currently set for blocking operations.
      • setTimeoutMs

        public void setTimeoutMs​(int timeoutMs)
        Description copied from interface: Transport
        Set a timeout for methods that may block.
        Specified by:
        setTimeoutMs in interface Transport
        Parameters:
        timeoutMs - the timeout in milliseconds
      • getRemoteHost

        public java.lang.String getRemoteHost()
        Specified by:
        getRemoteHost in interface Transport
        Returns:
        the hostname to which this transport is connected.
      • getRemotePort

        public int getRemotePort()
        Specified by:
        getRemotePort in interface Transport
        Returns:
        the port number on the remote host to which this transport is connected.
      • getClientVersion

        public java.lang.String getClientVersion()
        Specified by:
        getClientVersion in interface Transport
        Returns:
        the version string used by this client to identify itself to an SSH server, e.g. "SSHJ_3_0"
      • getSessionID

        public byte[] getSessionID()
        Specified by:
        getSessionID in interface Transport
        Returns:
        the session identifier assigned by server
      • setAuthenticated

        public void setAuthenticated()
        Description copied from interface: Transport
        Informs this transport that authentication has been completed. This method must be called after successful authentication, so that delayed compression may become effective if applicable.
        Specified by:
        setAuthenticated in interface Transport
      • isAuthenticated

        public boolean isAuthenticated()
        Specified by:
        isAuthenticated in interface Transport
        Returns:
        whether the transport thinks it is authenticated.
      • sendUnimplemented

        public long sendUnimplemented()
                               throws TransportException
        Description copied from interface: Transport
        Sends SSH_MSG_UNIMPLEMENTED in response to the last packet received.
        Specified by:
        sendUnimplemented in interface Transport
        Returns:
        the sequence number of the packet sent
        Throws:
        TransportException - if an error occurred sending the packet
      • join

        public void join​(int timeout,
                         java.util.concurrent.TimeUnit unit)
                  throws TransportException
        Description copied from interface: Transport
        Joins the thread calling this method to the transport's death.
        Specified by:
        join in interface Transport
        Throws:
        TransportException - if the transport dies of an exception
      • disconnect

        public void disconnect​(DisconnectReason reason)
        Description copied from interface: Transport
        Send a disconnect packet with the given reason, and closes this transport.
        Specified by:
        disconnect in interface Transport
        Parameters:
        reason - reason for disconnecting
      • disconnect

        public void disconnect​(DisconnectReason reason,
                               java.lang.String message)
        Description copied from interface: Transport
        Send a disconnect packet with the given reason and message, and closes this transport.
        Specified by:
        disconnect in interface Transport
        Parameters:
        reason - the reason code for this disconnect
        message - the text message
      • setDisconnectListener

        public void setDisconnectListener​(DisconnectListener listener)
        Description copied from interface: Transport
        Specify a listener that will be notified upon disconnection.
        Specified by:
        setDisconnectListener in interface Transport
        Parameters:
        listener - Disconnect Listener to be configured
      • write

        public long write​(SSHPacket payload)
                   throws TransportException
        Description copied from interface: Transport
        Write a packet over this transport.

        The payload SSHPacket should have 5 bytes free at the beginning to avoid a performance penalty associated with making space for header bytes (packet length, padding length).

        Specified by:
        write in interface Transport
        Parameters:
        payload - the SSHPacket containing data to send
        Returns:
        sequence number of the sent packet
        Throws:
        TransportException - if an error occurred sending the packet
      • die

        public void die​(java.lang.Exception ex)
        Description copied from interface: Transport
        Kill the transport in an exceptional way.
        Specified by:
        die in interface Transport
        Parameters:
        ex - The exception that occurred.
      • setHostKeyAlgorithm

        public void setHostKeyAlgorithm​(KeyAlgorithm keyAlgorithm)