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(@NotNull ConfigCryptoEngine engine, boolean destroyEngine, @NotNull SecretKey secretKey, @NotNull org.apache.commons.pool2.ObjectPool<Cipher> pool) Creates a new instance.PooledConfigCryptoProvider(@NotNull CryptoProviderOptions options) Creates a new instance with specified builder configuration options. -
Method Summary
Modifier and TypeMethodDescription@NotNull StringDecrypts the specified encrypted configuration value.@NotNull StringEncrypts the specified plain configuration value.protected @NotNull org.apache.commons.pool2.ObjectPool<Cipher>Returns the pool ofCiphers to use during encryption and decryption.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(@NotNull @NotNull ConfigCryptoEngine engine, boolean destroyEngine, @NotNull @NotNull SecretKey secretKey, @NotNull @NotNull 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
@NotNull public @NotNull String encrypt(@NotNull @NotNull 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
@NotNull public @NotNull String decrypt(@NotNull @NotNull 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
-