Top Description Fields Constructors Methods
org.apache.sshd.agent.local

public Class AgentImpl

extends Object
implements SshAgent
Class Inheritance
All Implemented Interfaces
org.apache.sshd.agent.SshAgent, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.security.KeyPair, .PublicKey, java.security.spec.InvalidKeySpecException, java.util.AbstractMap.SimpleImmutableEntry, .ArrayList, .Collection, .List, .Map, .Objects, java.util.concurrent.atomic.AtomicBoolean, org.apache.sshd.agent.SshAgent, .SshAgentKeyConstraint, org.apache.sshd.common.NamedFactory, .SshException, org.apache.sshd.common.config.keys.KeyUtils, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.signature.Signature, .SignatureFactory, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.slf4j.Logger, .LoggerFactory

A local SSH agent implementation

Field Summary

Modifier and TypeField and Description
private final List<Map.Entry<KeyPair, String>>
private static final Logger
private final AtomicBoolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addIdentity(KeyPair
KeyPair to add
key
,
String
to associate with the key
comment
,
SshAgentKeyConstraint...
SshAgentKeyConstraints for this key to pass on to the agent
constraints
)

Implements org.apache.sshd.agent.SshAgent.addIdentity.

Adds a key to the agent.

public void
close()

Implements java.nio.channels.Channel.close.

Closes this channel.

public Iterable<? extends Map.Entry<PublicKey, String>>
protected static Map.Entry<KeyPair, String>
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public void
public void
public KeyPair
resolveLocalIdentity(PublicKey
The PublicKey that is going to be used
key
)

Overrides default org.apache.sshd.agent.SshAgent.resolveLocalIdentity.

Used for reporting client-side public key authentication via agent

public Map.Entry<String, byte[]>
sign(SessionContext
The current SessionContext
session
,
PublicKey
The PublicKey to use for signing
key
,
String
Recommended signature algorithm - if null/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 another

algo
,
byte[]
Data to sign
data
)

Implements org.apache.sshd.agent.SshAgent.sign.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keysback to summary
private final List<Map.Entry<KeyPair, String>> keys
LOGback to summary
private static final Logger LOG
openback to summary
private final AtomicBoolean open

Constructor Detail

AgentImplback to summary
public AgentImpl()

Method Detail

addIdentityback to summary
public void addIdentity(KeyPair key, String comment, SshAgentKeyConstraint... constraints) throws IOException

Implements org.apache.sshd.agent.SshAgent.addIdentity.

Doc from org.apache.sshd.agent.SshAgent.addIdentity.

Adds a key to the agent.

Parameters
key:KeyPair

KeyPair to add

comment:String

to associate with the key

constraints:SshAgentKeyConstraint[]

SshAgentKeyConstraints for this key to pass on to the agent

Annotations
@Override
Exceptions
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
closeback to summary
public void close() throws IOException

Implements java.nio.channels.Channel.close.

Doc from java.nio.channels.Channel.close.

Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
getIdentitiesback to summary
public Iterable<? extends Map.Entry<PublicKey, String>> getIdentities() throws IOException

Implements org.apache.sshd.agent.SshAgent.getIdentities.

Annotations
@Override
getKeyPairback to summary
protected static Map.Entry<KeyPair, String> getKeyPair(Collection<? extends Map.Entry<KeyPair, String>> keys, PublicKey key)
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
removeAllIdentitiesback to summary
public void removeAllIdentities() throws IOException

Implements org.apache.sshd.agent.SshAgent.removeAllIdentities.

Annotations
@Override
removeIdentityback to summary
public void removeIdentity(PublicKey key) throws IOException

Implements org.apache.sshd.agent.SshAgent.removeIdentity.

Annotations
@Override
resolveLocalIdentityback to summary
public KeyPair resolveLocalIdentity(PublicKey key)

Overrides default org.apache.sshd.agent.SshAgent.resolveLocalIdentity.

Doc from org.apache.sshd.agent.SshAgent.resolveLocalIdentity.

Used for reporting client-side public key authentication via agent

Parameters
key:PublicKey

The PublicKey that is going to be used

Returns:KeyPair

The KeyPair identity for it - if available - null otherwise

Annotations
@Override
signback to summary
public Map.Entry<String, byte[]> sign(SessionContext session, PublicKey key, String algo, byte[] data) throws IOException

Implements org.apache.sshd.agent.SshAgent.sign.

Parameters
session:SessionContext

Doc from org.apache.sshd.agent.SshAgent.sign.

The current SessionContext

key:PublicKey

Doc from org.apache.sshd.agent.SshAgent.sign.

The PublicKey to use for signing

algo:String

Doc from org.apache.sshd.agent.SshAgent.sign.

Recommended signature algorithm - if null/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 another

data:byte[]

Doc from org.apache.sshd.agent.SshAgent.sign.

Data to sign

Returns:Map.Entry<String, byte[]>

Doc from org.apache.sshd.agent.SshAgent.sign.

used algorithm + signed data - using the identity

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.agent.SshAgent.sign.

If failed to sign