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
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate final AtomicBooleanFields inherited from interface org.apache.sshd.agent.SshAgent
SSH_AUTHSOCKET_ENV_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIdentity(KeyPair key, String comment, SshAgentKeyConstraint... constraints) Adds a key to the agent.voidclose()getKeyPair(Collection<? extends Map.Entry<KeyPair, String>> keys, PublicKey key) booleanisOpen()voidvoidremoveIdentity(PublicKey key) Used for reporting client-side public key authentication via agentsign(SessionContext session, PublicKey key, String algo, byte[] data)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
keys
-
open
-
-
Constructor Details
-
AgentImpl
public AgentImpl()
-
-
Method Details
-
isOpen
public boolean isOpen() -
getIdentities
- Specified by:
getIdentitiesin interfaceSshAgent- Throws:
IOException
-
sign
public Map.Entry<String,byte[]> sign(SessionContext session, PublicKey key, String algo, byte[] data) throws IOException - Specified by:
signin interfaceSshAgent- Parameters:
session- The currentSessionContextkey- ThePublicKeyto 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:SshAgentAdds a key to the agent.- Specified by:
addIdentityin interfaceSshAgent- Parameters:
key-KeyPairto addcomment- to associate with the keyconstraints-SshAgentKeyConstraints 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:SshAgentUsed for reporting client-side public key authentication via agent- Specified by:
resolveLocalIdentityin interfaceSshAgent- Parameters:
key- ThePublicKeythat is going to be used- Returns:
- The
KeyPairidentity for it - if available -nullotherwise
-
removeIdentity
- Specified by:
removeIdentityin interfaceSshAgent- Throws:
IOException
-
removeAllIdentities
- Specified by:
removeAllIdentitiesin interfaceSshAgent- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getKeyPair
-