Package com.atlassian.crowd.crypto
Class PrefixBasedSwitchableEncryptor
java.lang.Object
com.atlassian.crowd.crypto.PrefixBasedSwitchableEncryptor
- All Implemented Interfaces:
Encryptor,SwitchableEncryptor
-
Constructor Summary
ConstructorsConstructorDescriptionPrefixBasedSwitchableEncryptor(EncryptionSettings encryptionSettings, Map<String, Encryptor> encryptors) -
Method Summary
Modifier and TypeMethodDescriptionbooleanGenerate new encryption key, which should be used to encrypt password in following calls toEncryptor.encrypt(java.lang.String).Decrypt encrypted password, and return its original value.Encrypt plaintext password, and return encrypted value which can later be used in decrypt method to get plaintext password.protected EncryptorgetEncryptor(String encryptorKey) voidswitchEncryptor(String encryptorKey) Switches theEncryptorto the one specified byencryptorKeyor disable encryption whenencryptorKeyis null.
-
Constructor Details
-
PrefixBasedSwitchableEncryptor
public PrefixBasedSwitchableEncryptor(EncryptionSettings encryptionSettings, Map<String, Encryptor> encryptors)
-
-
Method Details
-
encrypt
Description copied from interface:EncryptorEncrypt plaintext password, and return encrypted value which can later be used in decrypt method to get plaintext password. -
getEncryptor
-
decrypt
Description copied from interface:EncryptorDecrypt encrypted password, and return its original value.In case of any error during decryption (such as missing decryption key) return
encryptedPassword. -
switchEncryptor
Description copied from interface:SwitchableEncryptorSwitches theEncryptorto the one specified byencryptorKeyor disable encryption whenencryptorKeyis null.- Specified by:
switchEncryptorin interfaceSwitchableEncryptor- Parameters:
encryptorKey- identifies one of theEncryptoror no encryption when null.
-
changeEncryptionKey
public boolean changeEncryptionKey()Description copied from interface:EncryptorGenerate new encryption key, which should be used to encrypt password in following calls toEncryptor.encrypt(java.lang.String).- Specified by:
changeEncryptionKeyin interfaceEncryptor- Returns:
- true if generation was successful, or false when encryption key migration is not supported
-
getAvailableEncryptorKeys
- Specified by:
getAvailableEncryptorKeysin interfaceSwitchableEncryptor- Returns:
- available encryptors' keys
-
getCurrentEncryptorKey
- Specified by:
getCurrentEncryptorKeyin interfaceSwitchableEncryptor- Returns:
- key of the currently used
EncryptororOptional.empty()when encryption is disabled
-