public class SshAgentClient
extends java.lang.Object
implements com.sshtools.common.publickey.SignatureGenerator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HASH_AND_SIGN |
static java.lang.String |
WINDOWS_SSH_AGENT_SERVICE |
Constructor and Description |
---|
SshAgentClient(boolean isForwarded,
java.lang.String application,
java.io.Closeable socket,
java.io.InputStream in,
java.io.OutputStream out,
boolean isRFC) |
SshAgentClient(boolean isForwarded,
java.lang.String application,
java.net.Socket socket) |
Modifier and Type | Method and Description |
---|---|
void |
addKey(com.sshtools.common.ssh.components.SshPrivateKey prvkey,
com.sshtools.common.ssh.components.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,
AgentSocketType type)
Connect a socket to the agent at the location specified.
|
static SshAgentClient |
connectLocalAgent(java.lang.String application,
java.lang.String location,
AgentSocketType type,
boolean RFCAgent)
Connect to the local agent.
|
static SshAgentClient |
connectOpenSSHAgent(java.lang.String application) |
static SshAgentClient |
connectOpenSSHAgent(java.lang.String application,
java.lang.String location)
Determines operating system type (windows or not) and connects using the appropriate
socket type for the platform.
|
void |
deleteAllKeys()
Delete all the keys held by the agent.
|
void |
deleteKey(com.sshtools.common.ssh.components.SshPublicKey key,
java.lang.String description)
Delete a key held by the agent
|
java.util.Collection<com.sshtools.common.ssh.components.SshPublicKey> |
getPublicKeys() |
byte[] |
getRandomData(int count)
Request some random data from the remote side
|
byte[] |
hashAndSign(com.sshtools.common.ssh.components.SshPublicKey key,
java.lang.String signingAlgorithm,
byte[] data)
Request a hash and sign operation be performed for a given public key.
|
boolean |
isRFCAgent() |
java.util.Map<com.sshtools.common.ssh.components.SshPublicKey,java.lang.String> |
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 AgentMessage |
readMessage()
Read a single message from the inputstream and convert into a valid
subsystem message
|
protected void |
registerMessages() |
protected void |
sendForwardingNotice()
Send a forwarding notice.
|
protected void |
sendMessage(AgentMessage msg)
Send a subsystem message
|
protected void |
sendVersionRequest(java.lang.String application)
Request the agent version.
|
byte[] |
sign(com.sshtools.common.ssh.components.SshPublicKey key,
java.lang.String signingAlgorithm,
byte[] data) |
boolean |
unlockAgent(java.lang.String password)
Unlock the agent
|
public static final java.lang.String HASH_AND_SIGN
public static java.lang.String WINDOWS_SSH_AGENT_SERVICE
public SshAgentClient(boolean isForwarded, java.lang.String application, java.net.Socket socket) throws java.io.IOException
java.io.IOException
public SshAgentClient(boolean isForwarded, java.lang.String application, java.io.Closeable socket, java.io.InputStream in, java.io.OutputStream out, boolean isRFC) throws java.io.IOException
java.io.IOException
public boolean isRFCAgent()
public static SshAgentClient connectOpenSSHAgent(java.lang.String application) throws AgentNotAvailableException, java.io.IOException
AgentNotAvailableException
java.io.IOException
public static SshAgentClient connectOpenSSHAgent(java.lang.String application, java.lang.String location) throws AgentNotAvailableException, java.io.IOException
application
- location
- AgentNotAvailableException
java.io.IOException
public static SshAgentClient connectLocalAgent(java.lang.String application, java.lang.String location, AgentSocketType type, boolean RFCAgent) 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, AgentSocketType type) 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()
public void ping(byte[] padding) throws java.io.IOException
padding
- the padding datajava.io.IOException
- if an IO error occursprotected void registerMessages()
protected void sendForwardingNotice() throws java.io.IOException
java.io.IOException
- if an IO error occursprotected void sendMessage(AgentMessage msg) throws java.io.IOException
msg
- the message to sendjava.io.IOException
- if an IO error occursprotected void sendVersionRequest(java.lang.String application) throws java.io.IOException
application
- the application connectingjava.io.IOException
- if an IO error occurspublic void deleteAllKeys() throws java.io.IOException
java.io.IOException
- if an IO error occursprotected AgentMessage readMessage() throws InvalidMessageException
InvalidMessageException
- if the message received is invalidpublic void addKey(com.sshtools.common.ssh.components.SshPrivateKey prvkey, com.sshtools.common.ssh.components.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 java.util.Map<com.sshtools.common.ssh.components.SshPublicKey,java.lang.String> 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 deleteKey(com.sshtools.common.ssh.components.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 byte[] hashAndSign(com.sshtools.common.ssh.components.SshPublicKey key, java.lang.String signingAlgorithm, 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 byte[] sign(com.sshtools.common.ssh.components.SshPublicKey key, java.lang.String signingAlgorithm, byte[] data) throws com.sshtools.common.ssh.SshException
sign
in interface com.sshtools.common.publickey.SignatureGenerator
com.sshtools.common.ssh.SshException
public java.util.Collection<com.sshtools.common.ssh.components.SshPublicKey> getPublicKeys() throws java.io.IOException
getPublicKeys
in interface com.sshtools.common.publickey.SignatureGenerator
java.io.IOException
Copyright © 2024. All rights reserved.