Class OpenSSHAgentConnection

java.lang.Object
com.sshtools.agent.openssh.OpenSSHAgentConnection
All Implemented Interfaces:
SshAgentConnection, Runnable

public class OpenSSHAgentConnection extends Object implements Runnable, SshAgentConnection
Represents a single connection on the agent server.
  • Constructor Details

  • Method Details

    • sendAgentSuccess

      protected void sendAgentSuccess() throws IOException
      Send a success message.
      Throws:
      IOException - if an IO error occurs
    • sendAgentFailure

      protected void sendAgentFailure() throws IOException
      Send a failure message
      Parameters:
      errorcode - the error code of the failure
      Throws:
      IOException - if an IO error occurs
    • sendAgentKeyList

      protected void sendAgentKeyList() throws IOException
      Send the agents key list to the remote side. This supplies all the public keys.
      Throws:
      IOException - if an IO error occurs
    • sendOperationComplete

      protected void sendOperationComplete(byte[] data) throws IOException
      Send the completed signing operation data.
      Parameters:
      data - the data generating from the signing operation
      Throws:
      IOException - if an IO error occurs
    • sendMessage

      protected void sendMessage(AgentMessage msg) throws IOException
      Sends a subsystem message.
      Parameters:
      msg - the subsystem message to send
      Throws:
      IOException - if an IO error occurs
    • onAddKey

      protected void onAddKey(SshAgentAddKey msg) throws IOException
      Called when the remote side adds a key the agent.
      Parameters:
      msg - the message containing the key
      Throws:
      IOException - if an IO error occurs
    • onDeleteAllKeys

      protected void onDeleteAllKeys(AgentMessage msg) throws IOException
      Called when the remote side requests that all keys be removed from the agent.
      Parameters:
      msg - the delete all keys message
      Throws:
      IOException - if an IO error occurs
    • onListKeys

      protected void onListKeys(AgentMessage msg) throws IOException
      Called by the remote side when a list of the agents keys is required
      Parameters:
      msg - the list all keys message
      Throws:
      IOException - if an IO error occurs
    • onPrivateKeyOp

      protected void onPrivateKeyOp(SshAgentPrivateKeyOp msg) throws IOException
      Called by the remote side to initiate a private key operation.
      Parameters:
      msg - the private key operation message
      Throws:
      IOException - if an IO error occurs
    • encodeSignature

      protected byte[] encodeSignature(com.sshtools.common.ssh.components.SshPublicKey key, int flags, byte[] signature) throws IOException
      Throws:
      IOException
    • onDeleteKey

      protected void onDeleteKey(SshAgentDeleteKey msg) throws IOException
      Called by the remote side to delete a key from the agent
      Parameters:
      msg - the message containin the key to delete
      Throws:
      IOException - if an IO error occurs
    • onLock

      protected void onLock(SshAgentLock msg) throws IOException
      Called by the remote side when the agent is to be locked
      Parameters:
      msg - the message containing a password
      Throws:
      IOException - if an IO error occurs
    • onUnlock

      protected void onUnlock(SshAgentUnlock msg) throws IOException
      Called by the remote side when the agent is to be unlocked
      Parameters:
      msg - the message containin the password
      Throws:
      IOException - if an IO error occurs
    • run

      public void run()
      The connection thread
      Specified by:
      run in interface Runnable
    • onMessageReceived

      protected void onMessageReceived(byte[] msgdata) throws IOException
      Process a message and route to the handler method
      Parameters:
      msgdata - the raw message received
      Throws:
      IOException - if an IO error occurs