Class AbstractConfigCryptoEngine

java.lang.Object
dev.orne.config.impl.AbstractConfigCryptoEngine
All Implemented Interfaces:
ConfigCryptoEngine
Direct Known Subclasses:
ConfigCryptoAesGcmEngine

@API(status=INTERNAL, since="1.0") public abstract class AbstractConfigCryptoEngine extends Object implements ConfigCryptoEngine
Abstract base implementation of ConfigCryptoEngine.
Since:
0.2
Version:
1.0, 2020-08
Author:
(w) Iker Hernaez
  • Field Details

    • DEFAULT_SECRET_KEY_SALT_SIZE

      public static final int DEFAULT_SECRET_KEY_SALT_SIZE
      The default secret key salt length.
      See Also:
  • Constructor Details

    • AbstractConfigCryptoEngine

      protected AbstractConfigCryptoEngine()
      Creates new instance.
  • Method Details

    • getSecureRandom

      @NotNull public @NotNull SecureRandom getSecureRandom() throws ConfigCryptoProviderException
      Returns the SecureRandom instance of this instance.
      Returns:
      The SecureRandom instance
      Throws:
      ConfigCryptoProviderException - If an error occurs creating the SecureRandom instance
    • setSecureRandom

      @NotNull public void setSecureRandom(SecureRandom secureRandom)
      Sets the SecureRandom instance of this instance.
      Parameters:
      secureRandom - The SecureRandom instance
    • createSecureRandom

      @NotNull public @NotNull SecureRandom createSecureRandom() throws ConfigCryptoProviderException
      Creates a new SecureRandom instance.
      Returns:
      The new SecureRandom instance
      Throws:
      ConfigCryptoProviderException - If an error occurs creating the SecureRandom instance
    • getSecretKeyFactory

      @NotNull public @NotNull SecretKeyFactory getSecretKeyFactory(@NotNull @NotNull String algorithm) throws ConfigCryptoProviderException
      Gets a SecretKeyFactory for the specified algorithm.
      Parameters:
      algorithm - The algorithm to use
      Returns:
      The SecretKeyFactory for the algorithm
      Throws:
      ConfigCryptoProviderException - If an error occurs retrieving the SecretKeyFactory
    • createCipher

      @NotNull public @NotNull Cipher createCipher(@NotNull @NotNull String algorithm) throws ConfigCryptoProviderException
      Creates a Cipher for the specified algorithm.
      Parameters:
      algorithm - The encryption algorithm to use
      Returns:
      The created Cipher
      Throws:
      ConfigCryptoProviderException - If an error occurs creating the Cipher
    • destroy

      public void destroy()
      Destroys all secret information. Any further call to the instance will throw an IllegalStateException.
      Specified by:
      destroy in interface ConfigCryptoEngine
    • isDestroyed

      public boolean isDestroyed()
      Returns true if the cryptographic engine has been destroyed.
      Returns:
      If the cryptographic engine has been destroyed.
    • checkDestroyed

      protected void checkDestroyed()
      Checks if the cryptographic engine has been destroyed.
      Throws:
      IllegalStateException - If the cryptographic engine has been destroyed.