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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation ofPooledObjectFactorythat creates new instances ofCipherusing an instance ofConfigCryptoEngine. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPooledConfigCryptoProvider(ConfigCryptoEngine engine, boolean destroyEngine, SecretKey secretKey, org.apache.commons.pool2.ObjectPool<Cipher> pool) Creates a new instance.Creates a new instance with specified builder configuration options. -
Method Summary
Modifier and TypeMethodDescriptionDecrypts the specified encrypted configuration value.Encrypts the specified plain configuration value.protected org.apache.commons.pool2.ObjectPool<Cipher>Returns the pool ofCiphers to use during encryption and decryption.protected StringwithCipher(org.apache.commons.lang3.function.FailableFunction<Cipher, String, ConfigCryptoProviderException> operation) Performs the specified operation with aCipherinstance from the pool, returning the instance to the pool after the operation is completed.Methods inherited from class dev.orne.config.impl.AbstractConfigCryptoProvider
checkDestroyed, decrypt, destroy, encrypt, getEngine, getSecretKey, isDestroyed, isDestroyEngine
-
Constructor Details
-
PooledConfigCryptoProvider
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 ofCipherinstances to use.
-
-
Method Details
-
getCiphersPool
Returns the pool ofCiphers to use during encryption and decryption.- Returns:
- The pool of
Ciphers to use during encryption and decryption
-
encrypt
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
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 aCipherinstance from the pool, returning the instance to the pool after the operation is completed.- Parameters:
operation- The operation to perform with theCipherinstance.- Returns:
- The result of the operation.
-