Class StringEncryptorCoordinator

java.lang.Object
com.axelor.common.crypto.StringEncryptorCoordinator
All Implemented Interfaces:
Encryptor<String,String>

public class StringEncryptorCoordinator extends Object implements Encryptor<String,String>
Coordinator that routes encrypt/decrypt operations between the legacy StringEncryptor ($AES$), StringEncryptorPbkdf2Sha256 ($AESv1$), and StringEncryptorPbkdf2Sha512 ($AESv2$).

All new encryptions always use the $AESv1$ format. Decryption automatically dispatches based on the version prefix embedded in the base64 payload.

  • Constructor Details

    • StringEncryptorCoordinator

      public StringEncryptorCoordinator(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 StringEncryptorCoordinator gcm(String password)
      Creates a coordinator using AES/GCM for current encryptions.
    • cbc

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

      public boolean isEncrypted(String message)
      Description copied from interface: Encryptor
      Check whether the given message is already encrypted or not.
      Specified by:
      isEncrypted in interface Encryptor<String,String>
      Parameters:
      message - the message to check
      Returns:
      true if encrypted
    • encrypt

      public String encrypt(String message)
      Always encrypts using the current $AESv1$ format.
      Specified by:
      encrypt in interface Encryptor<String,String>
      Parameters:
      message - the message to encrypt
      Returns:
      encrypted message
    • decrypt

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