public class PrefixBasedSwitchableEncryptor extends Object implements SwitchableEncryptor
Constructor and Description |
---|
PrefixBasedSwitchableEncryptor(EncryptionSettings encryptionSettings,
Map<String,Encryptor> encryptors) |
Modifier and Type | Method and Description |
---|---|
boolean |
changeEncryptionKey()
Generate new encryption key, which should be used to encrypt password in following calls to
Encryptor.encrypt(java.lang.String) . |
String |
decrypt(String encryptedPassword)
Decrypt encrypted password, and return its original value.
|
String |
encrypt(String password)
Encrypt plaintext password, and return encrypted value which can later be used in decrypt method to get plaintext password.
|
Collection<String> |
getAvailableEncryptorKeys() |
Optional<String> |
getCurrentEncryptorKey() |
protected Encryptor |
getEncryptor(String encryptorKey) |
void |
switchEncryptor(String encryptorKey)
Switches the
Encryptor to the one specified by encryptorKey or disable encryption when
encryptorKey is null. |
public PrefixBasedSwitchableEncryptor(EncryptionSettings encryptionSettings, Map<String,Encryptor> encryptors)
public String encrypt(String password)
Encryptor
public String decrypt(String encryptedPassword)
Encryptor
In case of any error during decryption (such as missing decryption key) return encryptedPassword
.
public void switchEncryptor(String encryptorKey)
SwitchableEncryptor
Encryptor
to the one specified by encryptorKey
or disable encryption when
encryptorKey
is null.switchEncryptor
in interface SwitchableEncryptor
encryptorKey
- identifies one of the Encryptor
or no encryption when null.public boolean changeEncryptionKey()
Encryptor
Encryptor.encrypt(java.lang.String)
.changeEncryptionKey
in interface Encryptor
public Collection<String> getAvailableEncryptorKeys()
getAvailableEncryptorKeys
in interface SwitchableEncryptor
public Optional<String> getCurrentEncryptorKey()
getCurrentEncryptorKey
in interface SwitchableEncryptor
Encryptor
or Optional.empty()
when encryption is disabledCopyright © 2021 Atlassian. All rights reserved.