Class InMemoryKeyStore

java.lang.Object
com.sshtools.agent.InMemoryKeyStore
All Implemented Interfaces:
KeyStore

public class InMemoryKeyStore extends Object implements KeyStore
A store for maintaining public keys in agent
  • Constructor Details

    • InMemoryKeyStore

      public InMemoryKeyStore()
      Creates a new KeyStore object.
  • Method Details

    • getPublicKeys

      public Map<com.sshtools.common.ssh.components.SshPublicKey,String> getPublicKeys()
      Description copied from interface: KeyStore
      Return a Map of all the installed keys.
      Specified by:
      getPublicKeys in interface KeyStore
      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

      public KeyConstraints getKeyConstraints(com.sshtools.common.ssh.components.SshPublicKey key)
      Description copied from interface: KeyStore
      Get the constraints for a key stored in this keystore.
      Specified by:
      getKeyConstraints in interface KeyStore
      Parameters:
      key - The public key.
      Returns:
    • size

      public int size()
      Description copied from interface: KeyStore
      How many keys are in this store?
      Specified by:
      size in interface KeyStore
      Returns:
      The number of keys in this store.
    • addKeyStoreListener

      public void addKeyStoreListener(KeyStoreListener listener)
      Add a listener.
      Parameters:
      listener -
    • removeKeyStoreListener

      public void removeKeyStoreListener(KeyStoreListener listener)
      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 interface KeyStore
      Parameters:
      prvkey - The private key
      pubkey - The public key
      description - 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 interface KeyStore
      Throws:
      IOException
    • deleteAllKeys

      public boolean deleteAllKeys()
      Description copied from interface: KeyStore
      Delete all the keys in this keystore.
      Specified by:
      deleteAllKeys in interface KeyStore
    • 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 interface KeyStore
      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

      public boolean deleteKey(com.sshtools.common.ssh.components.SshPublicKey pubkey) throws IOException
      Description copied from interface: KeyStore
      Delete a key from the keystore.
      Specified by:
      deleteKey in interface KeyStore
      Parameters:
      pubkey - The public key to delete.
      Returns:
      true if the key was deleted.
      Throws:
      IOException
    • lock

      public boolean lock(String password) throws IOException
      Description copied from interface: KeyStore
      Lock the keystore.
      Specified by:
      lock in interface KeyStore
      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

      public boolean unlock(String password) throws IOException
      Description copied from interface: KeyStore
      Unlock the keystore.
      Specified by:
      unlock in interface KeyStore
      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.
      Specified by:
      isLocked in interface KeyStore
      Returns: