Package org.apache.sshd.agent.local
Class AgentImpl
- java.lang.Object
-
- org.apache.sshd.agent.local.AgentImpl
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.util.Map.Entry<java.security.KeyPair,java.lang.String>>
keys
private static org.slf4j.Logger
LOG
private java.util.concurrent.atomic.AtomicBoolean
open
-
Fields inherited from interface org.apache.sshd.agent.SshAgent
SSH_AUTHSOCKET_ENV_NAME
-
-
Constructor Summary
Constructors Constructor Description AgentImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIdentity(java.security.KeyPair key, java.lang.String comment, SshAgentKeyConstraint... constraints)
Adds a key to the agent.void
close()
java.lang.Iterable<? extends java.util.Map.Entry<java.security.PublicKey,java.lang.String>>
getIdentities()
protected static java.util.Map.Entry<java.security.KeyPair,java.lang.String>
getKeyPair(java.util.Collection<? extends java.util.Map.Entry<java.security.KeyPair,java.lang.String>> keys, java.security.PublicKey key)
boolean
isOpen()
void
removeAllIdentities()
void
removeIdentity(java.security.PublicKey key)
java.security.KeyPair
resolveLocalIdentity(java.security.PublicKey key)
Used for reporting client-side public key authentication via agentjava.util.Map.Entry<java.lang.String,byte[]>
sign(SessionContext session, java.security.PublicKey key, java.lang.String algo, byte[] data)
-
-
-
Method Detail
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejava.nio.channels.Channel
-
getIdentities
public java.lang.Iterable<? extends java.util.Map.Entry<java.security.PublicKey,java.lang.String>> getIdentities() throws java.io.IOException
- Specified by:
getIdentities
in interfaceSshAgent
- Throws:
java.io.IOException
-
sign
public java.util.Map.Entry<java.lang.String,byte[]> sign(SessionContext session, java.security.PublicKey key, java.lang.String algo, byte[] data) throws java.io.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:
java.io.IOException
- If failed to sign
-
addIdentity
public void addIdentity(java.security.KeyPair key, java.lang.String comment, SshAgentKeyConstraint... constraints) throws java.io.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:
java.io.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
public java.security.KeyPair resolveLocalIdentity(java.security.PublicKey key)
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
public void removeIdentity(java.security.PublicKey key) throws java.io.IOException
- Specified by:
removeIdentity
in interfaceSshAgent
- Throws:
java.io.IOException
-
removeAllIdentities
public void removeAllIdentities() throws java.io.IOException
- Specified by:
removeAllIdentities
in interfaceSshAgent
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getKeyPair
protected static java.util.Map.Entry<java.security.KeyPair,java.lang.String> getKeyPair(java.util.Collection<? extends java.util.Map.Entry<java.security.KeyPair,java.lang.String>> keys, java.security.PublicKey key)
-
-