Package com.axelor.common.crypto
Class BytesEncryptorCoordinator
java.lang.Object
com.axelor.common.crypto.BytesEncryptorCoordinator
- All Implemented Interfaces:
Encryptor<byte[],byte[]>
Coordinator that routes encrypt/decrypt operations between the legacy
BytesEncryptor
($AES$), BytesEncryptorPbkdf2Sha256 ($AESv1$), and BytesEncryptorPbkdf2Sha512 ($AESv2$).
All new encryptions always use the $AESv1$ format. Decryption automatically dispatches
based on the version prefix embedded in the payload.
-
Constructor Summary
ConstructorsConstructorDescriptionBytesEncryptorCoordinator(OperationMode mode, String password) Creates a coordinator with explicit modes for both the current (v1/v2) and legacy encryptors. -
Method Summary
Modifier and TypeMethodDescriptionstatic BytesEncryptorCoordinatorCreates a coordinator using AES/CBC for current encryptions.byte[]decrypt(byte[] bytes) Decrypts by dispatching to the appropriate bundle based on the version prefix.byte[]encrypt(byte[] bytes) Always encrypts using the current$AESv1$format.static BytesEncryptorCoordinatorCreates a coordinator using AES/GCM for current encryptions.booleanisEncrypted(byte[] bytes) Check whether the given message is already encrypted or not.
-
Constructor Details
-
BytesEncryptorCoordinator
Creates a coordinator with explicit modes for both the current (v1/v2) and legacy encryptors.- Parameters:
mode- the operation mode used by the encryptorspassword- the encryption password
-
-
Method Details
-
gcm
Creates a coordinator using AES/GCM for current encryptions. -
cbc
Creates a coordinator using AES/CBC for current encryptions. -
isEncrypted
public boolean isEncrypted(byte[] bytes) Description copied from interface:EncryptorCheck whether the given message is already encrypted or not.- Specified by:
isEncryptedin interfaceEncryptor<byte[],byte[]> - Parameters:
bytes- the message to check- Returns:
- true if encrypted
-
encrypt
public byte[] encrypt(byte[] bytes) Always encrypts using the current$AESv1$format. -
decrypt
public byte[] decrypt(byte[] bytes) Decrypts by dispatching to the appropriate bundle based on the version prefix.
-