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 Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConfigCryptoProvider(@NotNull ConfigCryptoEngine engine, boolean destroyEngine, @NotNull SecretKey secretKey) Creates a new instance.protectedAbstractConfigCryptoProvider(@NotNull CryptoProviderOptions options) Creates a new instance with specified builder configuration options. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if the cryptographic provider has been destroyed.Decrypts the specified encrypted configuration value.voiddestroy()Destroys all secret information.Encrypts the specified plain configuration value.protected @NotNull ConfigCryptoEngineReturns the cryptographic engine.protected @NotNull SecretKeyReturns the secret key to use during encryption and decryption.booleanReturnstrueif the cryptographic provider has been destroyed.protected booleanReturnstrueif the engine must be destroyed with provider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.orne.config.ConfigCryptoProvider
decrypt, encrypt
-
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
Returns the cryptographic engine.- Returns:
- The cryptographic engine.
-
getSecretKey
Returns the secret key to use during encryption and decryption.- Returns:
- The secret key.
-
isDestroyEngine
protected boolean isDestroyEngine()Returnstrueif the engine must be destroyed with provider.- Returns:
- If the engine must be destroyed with provider.
-
encrypt
Encrypts the specified plain configuration value.- Parameters:
value- The plain configuration valuecipher- The cipher to use.- 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 valuecipher- 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 anIllegalStateException.- Specified by:
destroyin interfaceConfigCryptoProvider
-
isDestroyed
public boolean isDestroyed()Returnstrueif 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.
-