Package com.sshtools.j2ssh.agent
Class SshAgentConnection
- java.lang.Object
-
- com.sshtools.j2ssh.agent.SshAgentConnection
-
- All Implemented Interfaces:
java.lang.Runnable
public class SshAgentConnection extends java.lang.Object implements java.lang.RunnableThis class provides a connection using the SSH agent protocol.- Version:
- $Revision: 1.14 $
- Author:
- $author$
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidonAddKey(com.sshtools.j2ssh.agent.SshAgentAddKey msg)Called when the remote side adds a key the agent.protected voidonDeleteAllKeys(com.sshtools.j2ssh.agent.SshAgentDeleteAllKeys msg)Called when the remote side requests that all keys be removed from the agent.protected voidonDeleteKey(com.sshtools.j2ssh.agent.SshAgentDeleteKey msg)Called by the remote side to delete a key from the agentprotected voidonForwardingNotice(com.sshtools.j2ssh.agent.SshAgentForwardingNotice msg)Called when a forwarding notice is recceived from the remote side.protected voidonListKeys(com.sshtools.j2ssh.agent.SshAgentListKeys msg)Called by the remote side when a list of the agents keys is requiredprotected voidonLock(com.sshtools.j2ssh.agent.SshAgentLock msg)Called by the remote side when the agent is to be lockedprotected voidonMessageReceived(byte[] msgdata)Process a message and route to the handler methodprotected voidonPing(com.sshtools.j2ssh.agent.SshAgentPing msg)Called when a ping message is receivedprotected voidonPrivateKeyOp(com.sshtools.j2ssh.agent.SshAgentPrivateKeyOp msg)Called by the remote side to initiate a private key operation.protected voidonRandom(com.sshtools.j2ssh.agent.SshAgentRandom msg)Called when the remote side sends a random messageprotected voidonRequestVersion(com.sshtools.j2ssh.agent.SshAgentRequestVersion msg)Called when the remote side requests the version number of this protocol.protected voidonUnlock(com.sshtools.j2ssh.agent.SshAgentUnlock msg)Called by the remote side when the agent is to be unlockedvoidrun()The connection threadprotected voidsendAgentAlive(byte[] padding)Send the agent alive message.protected voidsendAgentFailure(int errorcode)Send a failure messageprotected voidsendAgentKeyList()Send the agents key list to the remote side.protected voidsendAgentSuccess()Send a success message.protected voidsendMessage(SubsystemMessage msg)Sends a subsystem message.protected voidsendOperationComplete(byte[] data)Send the completed signing operation data.protected voidsendRandomData(byte[] data)Send some random data to the remote side.protected voidsendVersionResponse()Send the version response; this class currently implements version 2
-
-
-
Method Detail
-
sendAgentSuccess
protected void sendAgentSuccess() throws java.io.IOExceptionSend a success message.- Throws:
java.io.IOException- if an IO error occurs
-
sendAgentFailure
protected void sendAgentFailure(int errorcode) throws java.io.IOExceptionSend a failure message- Parameters:
errorcode- the error code of the failure- Throws:
java.io.IOException- if an IO error occurs
-
sendVersionResponse
protected void sendVersionResponse() throws java.io.IOExceptionSend the version response; this class currently implements version 2- Throws:
java.io.IOException- if an IO error occurs
-
sendAgentKeyList
protected void sendAgentKeyList() throws java.io.IOExceptionSend the agents key list to the remote side. This supplies all the public keys.- Throws:
java.io.IOException- if an IO error occurs
-
sendOperationComplete
protected void sendOperationComplete(byte[] data) throws java.io.IOExceptionSend the completed signing operation data.- Parameters:
data- the data generating from the signing operation- Throws:
java.io.IOException- if an IO error occurs
-
sendRandomData
protected void sendRandomData(byte[] data) throws java.io.IOExceptionSend some random data to the remote side.- Parameters:
data- some random data- Throws:
java.io.IOException- if an IO error occurs
-
sendAgentAlive
protected void sendAgentAlive(byte[] padding) throws java.io.IOExceptionSend the agent alive message. This is sent to test whether the agent is still active- Parameters:
padding- some random padding for the message- Throws:
java.io.IOException- if an IO error occurs
-
sendMessage
protected void sendMessage(SubsystemMessage msg) throws java.io.IOException
Sends a subsystem message.- Parameters:
msg- the subsystem message to send- Throws:
java.io.IOException- if an IO error occurs
-
onForwardingNotice
protected void onForwardingNotice(com.sshtools.j2ssh.agent.SshAgentForwardingNotice msg)
Called when a forwarding notice is recceived from the remote side.- Parameters:
msg- the forwarding notice
-
onRequestVersion
protected void onRequestVersion(com.sshtools.j2ssh.agent.SshAgentRequestVersion msg) throws java.io.IOExceptionCalled when the remote side requests the version number of this protocol.- Parameters:
msg- the version request message- Throws:
java.io.IOException- if an IO error occurs
-
onAddKey
protected void onAddKey(com.sshtools.j2ssh.agent.SshAgentAddKey msg) throws java.io.IOExceptionCalled when the remote side adds a key the agent.- Parameters:
msg- the message containing the key- Throws:
java.io.IOException- if an IO error occurs
-
onDeleteAllKeys
protected void onDeleteAllKeys(com.sshtools.j2ssh.agent.SshAgentDeleteAllKeys msg) throws java.io.IOExceptionCalled when the remote side requests that all keys be removed from the agent.- Parameters:
msg- the delete all keys message- Throws:
java.io.IOException- if an IO error occurs
-
onListKeys
protected void onListKeys(com.sshtools.j2ssh.agent.SshAgentListKeys msg) throws java.io.IOExceptionCalled by the remote side when a list of the agents keys is required- Parameters:
msg- the list all keys message- Throws:
java.io.IOException- if an IO error occurs
-
onPrivateKeyOp
protected void onPrivateKeyOp(com.sshtools.j2ssh.agent.SshAgentPrivateKeyOp msg) throws java.io.IOExceptionCalled by the remote side to initiate a private key operation.- Parameters:
msg- the private key operation message- Throws:
java.io.IOException- if an IO error occurs
-
onDeleteKey
protected void onDeleteKey(com.sshtools.j2ssh.agent.SshAgentDeleteKey msg) throws java.io.IOExceptionCalled by the remote side to delete a key from the agent- Parameters:
msg- the message containin the key to delete- Throws:
java.io.IOException- if an IO error occurs
-
onLock
protected void onLock(com.sshtools.j2ssh.agent.SshAgentLock msg) throws java.io.IOExceptionCalled by the remote side when the agent is to be locked- Parameters:
msg- the message containing a password- Throws:
java.io.IOException- if an IO error occurs
-
onUnlock
protected void onUnlock(com.sshtools.j2ssh.agent.SshAgentUnlock msg) throws java.io.IOExceptionCalled by the remote side when the agent is to be unlocked- Parameters:
msg- the message containin the password- Throws:
java.io.IOException- if an IO error occurs
-
onPing
protected void onPing(com.sshtools.j2ssh.agent.SshAgentPing msg) throws java.io.IOExceptionCalled when a ping message is received- Parameters:
msg- the ping message containing some padding- Throws:
java.io.IOException- if an IO error occurs
-
onRandom
protected void onRandom(com.sshtools.j2ssh.agent.SshAgentRandom msg) throws java.io.IOExceptionCalled when the remote side sends a random message- Parameters:
msg- the random message- Throws:
java.io.IOException- if an IO error occurs
-
run
public void run()
The connection thread- Specified by:
runin interfacejava.lang.Runnable
-
onMessageReceived
protected void onMessageReceived(byte[] msgdata) throws java.io.IOExceptionProcess a message and route to the handler method- Parameters:
msgdata- the raw message received- Throws:
java.io.IOException- if an IO error occurs
-
-