Provides a client connection to the ssh agent.
addKey
public void addKey(SshPrivateKey prvkey,
SshPublicKey pubkey,
String description,
KeyConstraints constraints)
throws IOException Add a key to the agent
prvkey - the private key to addpubkey - the private keys public keydescription - a description of the keyconstraints - a set of contraints for key use
close
public void close()
Close the agent
connectAgentSocket
public static Socket connectAgentSocket(String location)
throws AgentNotAvailableException,
IOException Connect a socket to the agent at the location specified.
location - the location of the agent, in the form "localhost:port"
connectLocalAgent
public static SshAgentClient connectLocalAgent(String application,
String location)
throws AgentNotAvailableException,
IOException Connect to the local agent.
application - the application connectinglocation - the location of the agent, in the form "localhost:port"
deleteAllKeys
public void deleteAllKeys()
throws IOException Delete all the keys held by the agent.
deleteKey
public void deleteKey(SshPublicKey key,
String description)
throws IOException Delete a key held by the agent
key - the public key of the private key to deletedescription - the description of the key
getRandomData
public byte[] getRandomData(int count)
throws IOException Request some random data from the remote side
count - the number of bytes needed
hashAndSign
public byte[] hashAndSign(SshPublicKey key,
byte[] data)
throws IOException Request a hash and sign operation be performed for a given public key.
key - the public key of the required private keydata - the data to has and sign
- the hashed and signed data
listKeys
public Map listKeys()
throws IOException List all the keys on the agent.
- a map of public keys and descriptions
lockAgent
public boolean lockAgent(String password)
throws IOException Lock the agent
password - password that will be required to unlock
- true if the agent was locked, otherwise false
ping
public void ping(byte[] padding)
throws IOException Ping the remote side with some random padding data
padding - the padding data
readMessage
protected SubsystemMessage readMessage()
throws InvalidMessageException Read a single message from the inputstream and convert into a valid
subsystem message
- the next available subsystem message
registerMessages
protected void registerMessages()
Register the subsystem messages
sendForwardingNotice
protected void sendForwardingNotice()
throws IOException Send a forwarding notice.
sendMessage
protected void sendMessage(SubsystemMessage msg)
throws IOException Send a subsystem message
msg - the message to send
sendVersionRequest
protected void sendVersionRequest(String application)
throws IOException Request the agent version.
application - the application connecting
unlockAgent
public boolean unlockAgent(String password)
throws IOException Unlock the agent
password - the password to unlock
- true if the agent was unlocked, otherwise false