Class KeyStoreFile

java.lang.Object
org.codice.ddf.security.certificate.generator.KeyStoreFile

public class KeyStoreFile extends Object
Facade class for a Java Keystore (JKS) file. Exposes a few high-level behaviors to abstract away the complexity of JCA/JCE, as well as file I/O operations.
  • Field Details

    • keyStore

      protected KeyStore keyStore
    • file

      protected File file
  • Constructor Details

    • KeyStoreFile

      public KeyStoreFile()
  • Method Details

    • aliases

      public List<String> aliases()
      Return the aliases of the items in the key store. Return null if there is an error.
      Returns:
      List of aliases or throw an exception
    • isKey

      public boolean isKey(String alias)
    • getEntry

      public KeyStore.Entry getEntry(String alias)
      Retrieve keystore entry, given the entry's alias. If the entry is encrypted, this method tries to decrypt it using the keystore's password.
      Parameters:
      alias - of the entry to retrieve
      Returns:
      concrete subclass of Keystore.Entry
    • setEntry

      public void setEntry(String alias, KeyStore.Entry entry)
      Add a new entry to the keystore. Use the given alias.
      Parameters:
      alias - of keystore entry
      entry - instance
    • deleteEntry

      public boolean deleteEntry(String alias)
      Remove the key store entry at the given alias. If the alias does not exist, log that it does not exist.
      Parameters:
      alias - the name of the entry in the keystore
      Returns:
      true if entry is not in the keystore false otherwise
    • save

      public void save()
      Save the keyStore to the original file and encrypt it with the original password.