Package org.confng.encryption
Interface EncryptionProvider
-
- All Known Implementing Classes:
AesEncryptionProvider
public interface EncryptionProviderInterface for encryption/decryption providers.Implement this interface to provide custom encryption/decryption logic for configuration values marked with
Encrypted.Example Implementation:
{@code public class MyEncryptionProvider implements EncryptionProvider { private final SecretKey key; public MyEncryptionProvider(String keyBase64) { byte[] keyBytes = Base64.getDecoder().decode(keyBase64); this.key = new SecretKeySpec(keyBytes, "AES"); }- Since:
- 1.1.0
- Author:
- Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
- See Also:
Encrypted,AesEncryptionProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Stringdecrypt(String encryptedValue)Decrypts an encrypted value.Stringencrypt(String plainValue)Encrypts a plain text value.default StringextractPayload(String wrappedValue)Extracts the encrypted payload from a wrapped value.default StringgetName()Gets the name of this encryption provider.default booleanisEncrypted(String value)Checks if a value appears to be encrypted.
-
-
-
Method Detail
-
decrypt
String decrypt(String encryptedValue) throws EncryptionException
Decrypts an encrypted value.- Parameters:
encryptedValue- the encrypted value (typically Base64 encoded)- Returns:
- the decrypted plain text value
- Throws:
EncryptionException- if decryption fails
-
encrypt
String encrypt(String plainValue) throws EncryptionException
Encrypts a plain text value.- Parameters:
plainValue- the plain text value to encrypt- Returns:
- the encrypted value (typically Base64 encoded)
- Throws:
EncryptionException- if encryption fails
-
getName
default String getName()
Gets the name of this encryption provider.- Returns:
- the provider name
-
isEncrypted
default boolean isEncrypted(String value)
Checks if a value appears to be encrypted.The default implementation checks for common encrypted value prefixes like "ENC(" or "{cipher}".
- Parameters:
value- the value to check- Returns:
- true if the value appears to be encrypted
-
-