Class ConnectionProtocol<T extends SshContext>

java.lang.Object
com.sshtools.common.ssh.ExecutorOperationSupport<SshContext>
com.sshtools.synergy.ssh.ConnectionProtocol<T>
All Implemented Interfaces:
Service

public abstract class ConnectionProtocol<T extends SshContext> extends ExecutorOperationSupport<SshContext> implements Service
This class implements the SSH Connection Protocol as an SSH Transport Protocol service.
  • Field Details

  • Constructor Details

  • Method Details

    • addGlobalRequestHandler

      public void addGlobalRequestHandler(GlobalRequestHandler<T> handler)
    • getRemoteAddress

      public SocketAddress getRemoteAddress()
      Get the address of the remote client.
      Returns:
      SocketAddress
    • getLocalAddress

      public SocketAddress getLocalAddress()
      Get the local address to which the remote socket is connected.
      Returns:
      InetAddress
    • getLocalPort

      public int getLocalPort()
      Get the local port ro which the remote socket is connected.
      Returns:
      int
    • getUsername

      public String getUsername()
      Get the username for the connected user.
      Returns:
      String
    • onStop

      protected abstract void onStop()
    • stop

      public void stop()
      Description copied from interface: Service
      Stop the service
      Specified by:
      stop in interface Service
    • getSessionIdentifier

      public String getSessionIdentifier()
    • openChannel

      public void openChannel(ChannelNG<T> channel)
    • getActiveChannels

      public List<ChannelNG<T>> getActiveChannels()
    • getMaxChannels

      public int getMaxChannels()
    • disconnect

      public void disconnect()
      Disconnect the current connection.
    • processMessage

      public boolean processMessage(byte[] msg) throws IOException
      Description copied from interface: Service
      Process a transport message. When a message is received by the TransportProtocol that is not a transport level message the message is passed onto the active service using this method. The service processes the message and returns a value to indicate whether the message was used.
      Specified by:
      processMessage in interface Service
      Returns:
      true if the message was processed, otherwise false
      Throws:
      IOException
    • processGlobalRequestSuccess

      protected void processGlobalRequestSuccess(byte[] m)
      Process a global request success response.
    • processGlobalRequestFailure

      protected void processGlobalRequestFailure(byte[] msg)
      Process a global request failure
    • processTCPIPCancel

      protected abstract boolean processTCPIPCancel(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter msg) throws IOException
      Throws:
      IOException
    • processTCPIPForward

      protected abstract boolean processTCPIPForward(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter response) throws IOException
      Throws:
      IOException
    • createChannel

      protected abstract ChannelNG<T> createChannel(String channeltype, Connection<T> con) throws UnsupportedChannelException, PermissionDeniedException, ChannelOpenException
      Throws:
      UnsupportedChannelException
      PermissionDeniedException
      ChannelOpenException
    • sendGlobalRequest

      public void sendGlobalRequest(GlobalRequest request, boolean wantReply)
    • getQueueSize

      public int getQueueSize()
    • sendChannelOpenConfirmation

      public void sendChannelOpenConfirmation(ChannelNG<T> channel, byte[] responsedata)
    • sendChannelOpenFailure

      public void sendChannelOpenFailure(ChannelNG<T> channel, int reason, String desc)
    • getContext

      public T getContext()
      Get the connections ConfigurationContext.
      Specified by:
      getContext in class ExecutorOperationSupport<SshContext>
      Returns:
      SshContext
    • getTransport

      public TransportProtocol<T> getTransport()
      Get the underlying transport. Use with Caution.
      Returns:
      TransportProtocol
    • start

      public void start()
      Description copied from interface: Service
      Start the service.
      Specified by:
      start in interface Service
    • onStart

      protected abstract void onStart()
    • getUUID

      public String getUUID()
    • getIdleTimeoutSeconds

      public int getIdleTimeoutSeconds()
      Description copied from interface: Service
      How long does the service allow idle for?
      Specified by:
      getIdleTimeoutSeconds in interface Service
      Returns:
    • idle

      public boolean idle()
      Description copied from interface: Service
      The service has reached idle timeout seconds
      Specified by:
      idle in interface Service
      Returns:
    • isClient

      protected abstract boolean isClient()
    • getConnection

      public Connection<T> getConnection()
    • getIdleLog

      public String getIdleLog()
      Description copied from interface: Service
      Information for logging purposes when an ignore message is sent during idle.
      Specified by:
      getIdleLog in interface Service
      Returns: