Class ClusterLockingEncryptor

java.lang.Object
com.atlassian.crowd.crypto.ClusterLockingEncryptor
All Implemented Interfaces:
Encryptor, SwitchableEncryptor

public class ClusterLockingEncryptor extends Object implements SwitchableEncryptor
Encryptor that synchronizes on given cluster lock when doing encryption.
  • Constructor Details

    • ClusterLockingEncryptor

      public ClusterLockingEncryptor(SwitchableEncryptor delegate, com.atlassian.beehive.ClusterLockService clusterLockService)
  • Method Details

    • encrypt

      public String encrypt(String password)
      Description copied from interface: Encryptor
      Encrypt plaintext password, and return encrypted value which can later be used in decrypt method to get plaintext password.
      Specified by:
      encrypt in interface Encryptor
      Returns:
      encrypted password.
    • decrypt

      public String decrypt(String encryptedPassword)
      Description copied from interface: Encryptor
      Decrypt encrypted password, and return its original value.

      In case of any error during decryption (such as missing decryption key) return encryptedPassword.

      Specified by:
      decrypt in interface Encryptor
      Returns:
      decrypted password or unchanged encryptedPassword in case of any error
    • changeEncryptionKey

      public boolean changeEncryptionKey()
      Description copied from interface: Encryptor
      Generate new encryption key, which should be used to encrypt password in following calls to Encryptor.encrypt(java.lang.String).
      Specified by:
      changeEncryptionKey in interface Encryptor
      Returns:
      true if generation was successful, or false when encryption key migration is not supported
    • switchEncryptor

      public void switchEncryptor(@Nullable String encryptorKey)
      Description copied from interface: SwitchableEncryptor
      Switches the Encryptor to the one specified by encryptorKey or disable encryption when encryptorKey is null.
      Specified by:
      switchEncryptor in interface SwitchableEncryptor
      Parameters:
      encryptorKey - identifies one of the Encryptor or no encryption when null.
    • getAvailableEncryptorKeys

      public Collection<String> getAvailableEncryptorKeys()
      Specified by:
      getAvailableEncryptorKeys in interface SwitchableEncryptor
      Returns:
      available encryptors' keys
    • getCurrentEncryptorKey

      public Optional<String> getCurrentEncryptorKey()
      Specified by:
      getCurrentEncryptorKey in interface SwitchableEncryptor
      Returns:
      key of the currently used Encryptor or Optional.empty() when encryption is disabled