Class PooledConfigCryptoProvider

java.lang.Object
dev.orne.config.impl.AbstractConfigCryptoProvider
dev.orne.config.impl.PooledConfigCryptoProvider
All Implemented Interfaces:
ConfigCryptoProvider

@API(status=INTERNAL, since="1.0") public class PooledConfigCryptoProvider extends AbstractConfigCryptoProvider
Default implementation of ConfigCryptoProvider based on ConfigCryptoEngine with pooled Ciphers.
Since:
0.2
Version:
1.0, 2020-08
Author:
(w) Iker Hernaez
See Also:
  • Constructor Details

    • PooledConfigCryptoProvider

      public PooledConfigCryptoProvider(CryptoProviderOptions options)
      Creates a new instance with specified builder configuration options.
      Parameters:
      options - The configured builder options.
    • PooledConfigCryptoProvider

      protected PooledConfigCryptoProvider(ConfigCryptoEngine engine, boolean destroyEngine, SecretKey secretKey, org.apache.commons.pool2.ObjectPool<Cipher> pool)
      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.
      pool - The pool of Cipher instances to use.
  • Method Details

    • getCiphersPool

      protected org.apache.commons.pool2.ObjectPool<Cipher> getCiphersPool()
      Returns the pool of Ciphers to use during encryption and decryption.
      Returns:
      The pool of Ciphers to use during encryption and decryption
    • encrypt

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

      public String decrypt(@Nullable String value) throws ConfigCryptoProviderException
      Decrypts the specified encrypted configuration value.
      Parameters:
      value - The encrypted configuration value
      Returns:
      The plain configuration value
      Throws:
      ConfigCryptoProviderException - If an exception occurs during the decryption process
    • withCipher

      protected String withCipher(org.apache.commons.lang3.function.FailableFunction<Cipher,String,ConfigCryptoProviderException> operation)
      Performs the specified operation with a Cipher instance from the pool, returning the instance to the pool after the operation is completed.
      Parameters:
      operation - The operation to perform with the Cipher instance.
      Returns:
      The result of the operation.