java.lang.Object
dev.orne.config.impl.AbstractConfigCryptoEngine
- All Implemented Interfaces:
ConfigCryptoEngine
- Direct Known Subclasses:
ConfigCryptoAesGcmEngine
@API(status=INTERNAL,
since="1.0")
public abstract class AbstractConfigCryptoEngine
extends Object
implements ConfigCryptoEngine
Abstract base implementation of
ConfigCryptoEngine.- Since:
- 0.2
- Version:
- 1.0, 2020-08
- Author:
- (w) Iker Hernaez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default secret key salt length. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if the cryptographic engine has been destroyed.@NotNull CiphercreateCipher(@NotNull String algorithm) Creates aCipherfor the specified algorithm.@NotNull SecureRandomCreates a newSecureRandominstance.voiddestroy()Destroys all secret information.@NotNull SecretKeyFactorygetSecretKeyFactory(@NotNull String algorithm) Gets aSecretKeyFactoryfor the specified algorithm.@NotNull SecureRandomReturns theSecureRandominstance of this instance.booleanReturnstrueif the cryptographic engine has been destroyed.voidsetSecureRandom(SecureRandom secureRandom) Sets theSecureRandominstance of this instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.orne.config.ConfigCryptoEngine
createCipher, createSecretKey, decrypt, encrypt
-
Field Details
-
DEFAULT_SECRET_KEY_SALT_SIZE
public static final int DEFAULT_SECRET_KEY_SALT_SIZEThe default secret key salt length.- See Also:
-
-
Constructor Details
-
AbstractConfigCryptoEngine
protected AbstractConfigCryptoEngine()Creates new instance.
-
-
Method Details
-
getSecureRandom
Returns theSecureRandominstance of this instance.- Returns:
- The
SecureRandominstance - Throws:
ConfigCryptoProviderException- If an error occurs creating theSecureRandominstance
-
setSecureRandom
Sets theSecureRandominstance of this instance.- Parameters:
secureRandom- TheSecureRandominstance
-
createSecureRandom
Creates a newSecureRandominstance.- Returns:
- The new
SecureRandominstance - Throws:
ConfigCryptoProviderException- If an error occurs creating theSecureRandominstance
-
getSecretKeyFactory
@NotNull public @NotNull SecretKeyFactory getSecretKeyFactory(@NotNull @NotNull String algorithm) throws ConfigCryptoProviderException Gets aSecretKeyFactoryfor the specified algorithm.- Parameters:
algorithm- The algorithm to use- Returns:
- The
SecretKeyFactoryfor the algorithm - Throws:
ConfigCryptoProviderException- If an error occurs retrieving theSecretKeyFactory
-
createCipher
@NotNull public @NotNull Cipher createCipher(@NotNull @NotNull String algorithm) throws ConfigCryptoProviderException Creates aCipherfor the specified algorithm.- Parameters:
algorithm- The encryption algorithm to use- Returns:
- The created
Cipher - Throws:
ConfigCryptoProviderException- If an error occurs creating theCipher
-
destroy
public void destroy()Destroys all secret information. Any further call to the instance will throw anIllegalStateException.- Specified by:
destroyin interfaceConfigCryptoEngine
-
isDestroyed
public boolean isDestroyed()Returnstrueif the cryptographic engine has been destroyed.- Returns:
- If the cryptographic engine has been destroyed.
-
checkDestroyed
protected void checkDestroyed()Checks if the cryptographic engine has been destroyed.- Throws:
IllegalStateException- If the cryptographic engine has been destroyed.
-