public class SshAgentClient
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HASH_AND_SIGN
The hash and sign private key operation
|
Modifier and Type | Method and Description |
---|---|
void |
addKey(SshPrivateKey prvkey,
SshPublicKey pubkey,
java.lang.String description,
KeyConstraints constraints)
Add a key to the agent
|
void |
close()
Close the agent
|
static java.net.Socket |
connectAgentSocket(java.lang.String location)
Connect a socket to the agent at the location specified.
|
static SshAgentClient |
connectLocalAgent(java.lang.String application,
java.lang.String location)
Connect to the local agent.
|
void |
deleteAllKeys()
Delete all the keys held by the agent.
|
void |
deleteKey(SshPublicKey key,
java.lang.String description)
Delete a key held by the agent
|
byte[] |
getRandomData(int count)
Request some random data from the remote side
|
byte[] |
hashAndSign(SshPublicKey key,
byte[] data)
Request a hash and sign operation be performed for a given public key.
|
java.util.Map |
listKeys()
List all the keys on the agent.
|
boolean |
lockAgent(java.lang.String password)
Lock the agent
|
void |
ping(byte[] padding)
Ping the remote side with some random padding data
|
protected SubsystemMessage |
readMessage()
Read a single message from the inputstream and convert into a valid
subsystem message
|
protected void |
registerMessages()
Register the subsystem messages
|
protected void |
sendForwardingNotice()
Send a forwarding notice.
|
protected void |
sendMessage(SubsystemMessage msg)
Send a subsystem message
|
protected void |
sendVersionRequest(java.lang.String application)
Request the agent version.
|
boolean |
unlockAgent(java.lang.String password)
Unlock the agent
|
public static final java.lang.String HASH_AND_SIGN
public static SshAgentClient connectLocalAgent(java.lang.String application, java.lang.String location) throws AgentNotAvailableException, java.io.IOException
application
- the application connectinglocation
- the location of the agent, in the form "localhost:port"AgentNotAvailableException
- if the agent is not available at the
location specifiedjava.io.IOException
- if an IO error occurspublic static java.net.Socket connectAgentSocket(java.lang.String location) throws AgentNotAvailableException, java.io.IOException
location
- the location of the agent, in the form "localhost:port"AgentNotAvailableException
- if an agent is not available at the
location specifiedjava.io.IOException
- if an IO error occurspublic void close()
protected void registerMessages()
protected void sendVersionRequest(java.lang.String application) throws java.io.IOException
application
- the application connectingjava.io.IOException
- if an IO error occurspublic void addKey(SshPrivateKey prvkey, SshPublicKey pubkey, java.lang.String description, KeyConstraints constraints) throws java.io.IOException
prvkey
- the private key to addpubkey
- the private keys public keydescription
- a description of the keyconstraints
- a set of contraints for key usejava.io.IOException
- if an IO error occurspublic byte[] hashAndSign(SshPublicKey key, byte[] data) throws java.io.IOException
key
- the public key of the required private keydata
- the data to has and signjava.io.IOException
- if an IO error occurspublic java.util.Map listKeys() throws java.io.IOException
java.io.IOException
- if an IO error occurspublic boolean lockAgent(java.lang.String password) throws java.io.IOException
password
- password that will be required to unlockjava.io.IOException
- if an IO error occurspublic boolean unlockAgent(java.lang.String password) throws java.io.IOException
password
- the password to unlockjava.io.IOException
- if an IO error occurspublic byte[] getRandomData(int count) throws java.io.IOException
count
- the number of bytes neededjava.io.IOException
- if an IO error occurspublic void ping(byte[] padding) throws java.io.IOException
padding
- the padding datajava.io.IOException
- if an IO error occurspublic void deleteKey(SshPublicKey key, java.lang.String description) throws java.io.IOException
key
- the public key of the private key to deletedescription
- the description of the keyjava.io.IOException
- if an IO error occurspublic void deleteAllKeys() throws java.io.IOException
java.io.IOException
- if an IO error occursprotected void sendForwardingNotice() throws java.io.IOException
java.io.IOException
- if an IO error occursprotected void sendMessage(SubsystemMessage msg) throws java.io.IOException
msg
- the message to sendjava.io.IOException
- if an IO error occursprotected SubsystemMessage readMessage() throws InvalidMessageException
InvalidMessageException
- if the message received is invalidCopyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.