Package com.sshtools.agent
Class InMemoryKeyStore
java.lang.Object
com.sshtools.agent.InMemoryKeyStore
- All Implemented Interfaces:
KeyStore
A store for maintaining public keys in agent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addKey
(com.sshtools.common.ssh.components.SshKeyPair pair, String description, KeyConstraints cs) boolean
addKey
(com.sshtools.common.ssh.components.SshPrivateKey prvkey, com.sshtools.common.ssh.components.SshPublicKey pubkey, String description, KeyConstraints cs) Add a key to this keystorevoid
addKeyStoreListener
(KeyStoreListener listener) Add a listener.boolean
Delete all the keys in this keystore.boolean
deleteKey
(com.sshtools.common.ssh.components.SshPublicKey pubkey) Delete a key from the keystore.com.sshtools.common.ssh.components.SshPublicKey
elementAt
(int i) Get the public key at the specified indexgetKeyConstraints
(com.sshtools.common.ssh.components.SshPublicKey key) Get the constraints for a key stored in this keystore.Return a Map of all the installed keys.int
indexOf
(com.sshtools.common.ssh.components.SshPublicKey key) Find the index of a key.boolean
isLocked()
Determine if the store is currently locked.boolean
Lock the keystore.byte[]
performHashAndSign
(com.sshtools.common.ssh.components.SshPublicKey pubkey, List<ForwardingNotice> forwardingNodes, byte[] data, int flags) Hash and sign some data using a key stored in this keystore.void
removeKeyStoreListener
(KeyStoreListener listener) Remove a listener.int
size()
How many keys are in this store?boolean
Unlock the keystore.
-
Constructor Details
-
InMemoryKeyStore
public InMemoryKeyStore()Creates a new KeyStore object.
-
-
Method Details
-
getPublicKeys
Description copied from interface:KeyStore
Return a Map of all the installed keys.- Specified by:
getPublicKeys
in interfaceKeyStore
- Returns:
-
indexOf
public int indexOf(com.sshtools.common.ssh.components.SshPublicKey key) Find the index of a key.- Parameters:
key
- The key to look for.- Returns:
-
elementAt
public com.sshtools.common.ssh.components.SshPublicKey elementAt(int i) Get the public key at the specified index- Parameters:
i
- The index of the key.- Returns:
-
getKeyConstraints
Description copied from interface:KeyStore
Get the constraints for a key stored in this keystore.- Specified by:
getKeyConstraints
in interfaceKeyStore
- Parameters:
key
- The public key.- Returns:
-
size
public int size()Description copied from interface:KeyStore
How many keys are in this store? -
addKeyStoreListener
Add a listener.- Parameters:
listener
-
-
removeKeyStoreListener
Remove a listener.- Parameters:
listener
-
-
addKey
public boolean addKey(com.sshtools.common.ssh.components.SshPrivateKey prvkey, com.sshtools.common.ssh.components.SshPublicKey pubkey, String description, KeyConstraints cs) throws IOException Description copied from interface:KeyStore
Add a key to this keystore- Specified by:
addKey
in interfaceKeyStore
- Parameters:
prvkey
- The private keypubkey
- The public keydescription
- A description for this key pair.cs
- Any constraints.- Returns:
true
if the key was added to the keystore.- Throws:
IOException
-
addKey
public boolean addKey(com.sshtools.common.ssh.components.SshKeyPair pair, String description, KeyConstraints cs) throws IOException - Specified by:
addKey
in interfaceKeyStore
- Throws:
IOException
-
deleteAllKeys
public boolean deleteAllKeys()Description copied from interface:KeyStore
Delete all the keys in this keystore.- Specified by:
deleteAllKeys
in interfaceKeyStore
-
performHashAndSign
public byte[] performHashAndSign(com.sshtools.common.ssh.components.SshPublicKey pubkey, List<ForwardingNotice> forwardingNodes, byte[] data, int flags) throws KeyTimeoutException, com.sshtools.common.ssh.SshException Description copied from interface:KeyStore
Hash and sign some data using a key stored in this keystore.- Specified by:
performHashAndSign
in interfaceKeyStore
- Parameters:
pubkey
- The public key for which the signing should be untaken.forwardingNodes
- A list of forwarding notices for this operation.data
- The data to sign.- Returns:
- Throws:
KeyTimeoutException
com.sshtools.common.ssh.SshException
-
deleteKey
Description copied from interface:KeyStore
Delete a key from the keystore.- Specified by:
deleteKey
in interfaceKeyStore
- Parameters:
pubkey
- The public key to delete.- Returns:
true
if the key was deleted.- Throws:
IOException
-
lock
Description copied from interface:KeyStore
Lock the keystore.- Specified by:
lock
in interfaceKeyStore
- Parameters:
password
- A password to secure the store. Only the same password will unlock the store.- Returns:
true
if the store was locked.- Throws:
IOException
-
unlock
Description copied from interface:KeyStore
Unlock the keystore.- Specified by:
unlock
in interfaceKeyStore
- Parameters:
password
- The password that was provided when locking the store.- Returns:
true if the store was unlocked.
- Throws:
IOException
-
isLocked
public boolean isLocked()Description copied from interface:KeyStore
Determine if the store is currently locked.
-