java.lang.Object
io.lettuce.core.codec.CipherCodec
public abstract class CipherCodec extends Object
A crypto
RedisCodec that that allows transparent encryption/decryption of values. This codec uses Cipher
instances provided by CipherCodec.CipherSupplier to process encryption and decryption.
This codec supports various encryption keys by encoding the key name and used key version in the value that is stored in
Redis. The message format for encryption is:
$<key name>+<key version>$<cipher text>
Each value is prefixed with the key message that is enclosed with dollar ($) signs and using the plus sign
(+) to denote the key version. Decryption decodes the key name and requests a Cipher from
CipherCodec.CipherSupplier to decrypt values with an appropriate key/Cipher.
This codec does not provide re-wrapping or key rotation features.- Since:
- 5.2
- Author:
- Mark Paluch
- See Also:
CipherCodec.CipherSupplier,CipherCodec.KeyDescriptor
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCipherCodec.CipherSupplierRepresents a supplier ofCipher.static classCipherCodec.KeyDescriptorDescriptor to determine which crypto key to use. -
Method Summary
Modifier and Type Method Description static <K, V> RedisCodec<K,V>forValues(RedisCodec<K,V> delegate, CipherCodec.CipherSupplier encrypt, CipherCodec.CipherSupplier decrypt)ARedisCodecthat compresses values from a delegatingRedisCodec.
-
Method Details
-
forValues
public static <K, V> RedisCodec<K,V> forValues(RedisCodec<K,V> delegate, CipherCodec.CipherSupplier encrypt, CipherCodec.CipherSupplier decrypt)ARedisCodecthat compresses values from a delegatingRedisCodec.- Type Parameters:
K- Key type.V- Value type.- Parameters:
delegate- codec used for key-value encoding/decoding, must not benull.encrypt- theCipherCodec.CipherSupplierof encryptionCipherto use.decrypt- theCipherCodec.CipherSupplierof decryptionCipherto use.- Returns:
- Cipher codec.
-