Class BytesEncryptorCoordinator

java.lang.Object
com.axelor.common.crypto.BytesEncryptorCoordinator
All Implemented Interfaces:
Encryptor<byte[],byte[]>

public class BytesEncryptorCoordinator extends Object implements 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 Details

    • BytesEncryptorCoordinator

      public BytesEncryptorCoordinator(OperationMode mode, String password)
      Creates a coordinator with explicit modes for both the current (v1/v2) and legacy encryptors.
      Parameters:
      mode - the operation mode used by the encryptors
      password - the encryption password
  • Method Details

    • gcm

      public static BytesEncryptorCoordinator gcm(String password)
      Creates a coordinator using AES/GCM for current encryptions.
    • cbc

      public static BytesEncryptorCoordinator cbc(String password)
      Creates a coordinator using AES/CBC for current encryptions.
    • isEncrypted

      public boolean isEncrypted(byte[] bytes)
      Description copied from interface: Encryptor
      Check whether the given message is already encrypted or not.
      Specified by:
      isEncrypted in interface Encryptor<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.
      Specified by:
      encrypt in interface Encryptor<byte[],byte[]>
      Parameters:
      bytes - the message to encrypt
      Returns:
      encrypted message
    • decrypt

      public byte[] decrypt(byte[] bytes)
      Decrypts by dispatching to the appropriate bundle based on the version prefix.
      Specified by:
      decrypt in interface Encryptor<byte[],byte[]>
      Parameters:
      bytes - the encrypted message to decrypt
      Returns:
      decrypted message