public class EncryptionService
extends java.lang.Object
| Constructor and Description |
|---|
EncryptionService()
Creates a new EncryptionService instance.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
decrypt(byte[] encryptedValue,
byte[] dataKey,
byte[] hmacKey,
java.lang.String algorithm,
java.lang.Class<?> targetType)
Decrypts encrypted data using the specified data key and algorithm.
|
byte[] |
encrypt(java.lang.Object value,
byte[] dataKey,
byte[] hmacKey,
java.lang.String algorithm)
Encrypts a value using the specified data key and algorithm.
|
java.lang.String |
getDefaultAlgorithm()
Returns the default encryption algorithm.
|
boolean |
isAlgorithmSupported(java.lang.String algorithm)
Checks if the specified algorithm is supported.
|
boolean |
verifyEncryptedData(byte[] encryptedValue,
byte[] hmacKey)
Verifies that encrypted data has not been tampered with, without decrypting it.
|
public EncryptionService()
public byte[] encrypt(java.lang.Object value,
byte[] dataKey,
byte[] hmacKey,
java.lang.String algorithm)
throws EncryptionException
value - the value to encryptdataKey - the encryption keyhmacKey - the HMAC verification keyalgorithm - the encryption algorithm to useEncryptionException - if encryption failspublic java.lang.Object decrypt(byte[] encryptedValue,
byte[] dataKey,
byte[] hmacKey,
java.lang.String algorithm,
java.lang.Class<?> targetType)
throws EncryptionException
encryptedValue - the encrypted data with HMAC prependeddataKey - the decryption keyhmacKey - the HMAC verification keyalgorithm - the encryption algorithm usedtargetType - the expected type of the decrypted valueEncryptionException - if decryption fails or HMAC verification failspublic java.lang.String getDefaultAlgorithm()
public boolean isAlgorithmSupported(java.lang.String algorithm)
algorithm - the algorithm to checkpublic boolean verifyEncryptedData(byte[] encryptedValue,
byte[] hmacKey)
encryptedValue - the encrypted data with HMAC prependedhmacKey - the HMAC verification key