Class AesGcmKeyCipher
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.AesGcmKeyCipher
Encrypts and decrypts the private half of signing keys with AES-256-GCM (Spring Security's
Encryptors.stronger). Every encryption uses a fresh random initialisation vector, so encrypting the same
text twice gives different results.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.security.crypto.encrypt.BytesEncryptorThe encryptor derived from the passphrase and the salt. -
Constructor Summary
ConstructorsConstructorDescriptionAesGcmKeyCipher(KeyEncryptionProperties properties) Derives the encryption key. -
Method Summary
-
Field Details
-
encryptor
private final org.springframework.security.crypto.encrypt.BytesEncryptor encryptorThe encryptor derived from the passphrase and the salt.
-
-
Constructor Details
-
AesGcmKeyCipher
Derives the encryption key.- Parameters:
properties- passphrase and salt.
-
-
Method Details
-
encrypt
Encrypts a text.- Parameters:
plain- the text.- Returns:
- the encrypted text, Base64 encoded.
-
decrypt
Decrypts a text produced byencrypt(String).- Parameters:
encrypted- the encrypted text.- Returns:
- the original text.
- Throws:
IllegalStateException- if the text was not encrypted with the same passphrase and salt, or was altered.
-