Package org.apache.sshd.agent.local
Class AgentImpl
java.lang.Object
org.apache.sshd.agent.local.AgentImpl
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,SshAgent
A local SSH agent implementation
-
Field Summary
Fields inherited from interface org.apache.sshd.agent.SshAgent
SSH_AUTHSOCKET_ENV_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addIdentity
(KeyPair key, String comment, SshAgentKeyConstraint... constraints) Adds a key to the agent.void
close()
getKeyPair
(Collection<? extends Map.Entry<KeyPair, String>> keys, PublicKey key) boolean
isOpen()
void
void
removeIdentity
(PublicKey key) Used for reporting client-side public key authentication via agentsign
(SessionContext session, PublicKey key, String algo, byte[] data)
-
Constructor Details
-
AgentImpl
public AgentImpl()
-
-
Method Details
-
isOpen
public boolean isOpen() -
getIdentities
- Specified by:
getIdentities
in interfaceSshAgent
- Throws:
IOException
-
sign
public Map.Entry<String,byte[]> sign(SessionContext session, PublicKey key, String algo, byte[] data) throws IOException - Specified by:
sign
in interfaceSshAgent
- Parameters:
session
- The currentSessionContext
key
- ThePublicKey
to use for signingalgo
- Recommended signature algorithm - ifnull
/empty then one will be selected based on the key type and/or signature factories. Note: even if specific algorithm specified, the implementation may disregard and choose anotherdata
- Data to sign- Returns:
- used algorithm + signed data - using the identity
- Throws:
IOException
- If failed to sign
-
addIdentity
public void addIdentity(KeyPair key, String comment, SshAgentKeyConstraint... constraints) throws IOException Description copied from interface:SshAgent
Adds a key to the agent.- Specified by:
addIdentity
in interfaceSshAgent
- Parameters:
key
-KeyPair
to addcomment
- to associate with the keyconstraints
-SshAgentKeyConstraint
s for this key to pass on to the agent- Throws:
IOException
- if an error in the communication with the agent occurred, or the agent did not return a reply indicating successful addition of the key
-
resolveLocalIdentity
Description copied from interface:SshAgent
Used for reporting client-side public key authentication via agent- Specified by:
resolveLocalIdentity
in interfaceSshAgent
- Parameters:
key
- ThePublicKey
that is going to be used- Returns:
- The
KeyPair
identity for it - if available -null
otherwise
-
removeIdentity
- Specified by:
removeIdentity
in interfaceSshAgent
- Throws:
IOException
-
removeAllIdentities
- Specified by:
removeAllIdentities
in interfaceSshAgent
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getKeyPair
-