Class AbstractConfigCryptoProvider

java.lang.Object
dev.orne.config.impl.AbstractConfigCryptoProvider
All Implemented Interfaces:
ConfigCryptoProvider
Direct Known Subclasses:
DefaultConfigCryptoProvider, PooledConfigCryptoProvider

@API(status=INTERNAL, since="1.0") public abstract class AbstractConfigCryptoProvider extends Object implements ConfigCryptoProvider
Base abstract implementation of ConfigCryptoProvider based on ConfigCryptoEngine.
Since:
1.0
Version:
1.0, 2025-05
Author:
(w) Iker Hernaez
See Also:
  • Constructor Details

    • AbstractConfigCryptoProvider

      @API(status=INTERNAL, since="1.0") protected AbstractConfigCryptoProvider(@NotNull @NotNull CryptoProviderOptions options)
      Creates a new instance with specified builder configuration options.
      Parameters:
      options - The configured builder options.
    • AbstractConfigCryptoProvider

      protected AbstractConfigCryptoProvider(@NotNull @NotNull ConfigCryptoEngine engine, boolean destroyEngine, @NotNull @NotNull SecretKey secretKey)
      Creates a new instance.
      Parameters:
      engine - The cryptographic engine to use.
      destroyEngine - If the engine must be destroyed with provider.
      secretKey - The secret key to use.
  • Method Details

    • getEngine

      @NotNull protected @NotNull ConfigCryptoEngine getEngine()
      Returns the cryptographic engine.
      Returns:
      The cryptographic engine.
    • getSecretKey

      @NotNull protected @NotNull SecretKey getSecretKey()
      Returns the secret key to use during encryption and decryption.
      Returns:
      The secret key.
    • isDestroyEngine

      protected boolean isDestroyEngine()
      Returns true if the engine must be destroyed with provider.
      Returns:
      If the engine must be destroyed with provider.
    • encrypt

      public String encrypt(String value, Cipher cipher) throws ConfigCryptoProviderException
      Encrypts the specified plain configuration value.
      Parameters:
      value - The plain configuration value
      cipher - The cipher to use.
      Returns:
      The encrypted configuration value
      Throws:
      ConfigCryptoProviderException - If an exception occurs during the encryption process
    • decrypt

      public String decrypt(String value, Cipher cipher) throws ConfigCryptoProviderException
      Decrypts the specified encrypted configuration value.
      Parameters:
      value - The encrypted configuration value
      cipher - The cipher to use.
      Returns:
      The plain configuration value
      Throws:
      ConfigCryptoProviderException - If an exception occurs during the decryption process
    • destroy

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

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

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