T - public class CryptoDeserializer<T> extends Object implements org.apache.kafka.common.serialization.ExtendedDeserializer<T>
Deserializer for encrypted data
If the data to deserialize starts with the magic bytes KafkaCryptoConstants.ENCRYPTED_PREFIX,
then the data is decrypted using the Decryptor.The result is then deserialized using the underlying Deserializer.
If the data where not successfully decrypted, the result of the deserialization will be null
If the data to deserialize does not starts with the magic bytes, it is directly deserialized using the underlying Deserializer
Please note that this Deserializer has no default constructor, so it can not be configured via properties.
So if you want to use it into a Consumer, you will have to use org.apache.kafka.clients.consumer.KafkaConsumer#KafkaConsumer(Properties, Deserializer, Deserializer)
or org.apache.kafka.clients.consumer.KafkaConsumer#KafkaConsumer(Map, Deserializer, Deserializer) with your
instance of CryptoDeserializer
CryptoSerializer,
Decryptor| Constructor and Description |
|---|
CryptoDeserializer(org.apache.kafka.common.serialization.ExtendedDeserializer<? extends T> rawDeserializer,
Decryptor decryptor) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
configure(Map<String,?> configs,
boolean isKey) |
T |
deserialize(String topic,
byte[] data)
deserialize the data (with decryption if needed)
It is equivalent to:
|
T |
deserialize(String topic,
org.apache.kafka.common.header.Headers headers,
byte[] data)
deserialize the data (with decryption if needed)
The keyref used to deserialize the data will be added to the header
KafkaCryptoConstants.KEY_REF_HEADER (may be null) |
public T deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
KafkaCryptoConstants.KEY_REF_HEADER (may be null)deserialize in interface org.apache.kafka.common.serialization.ExtendedDeserializer<T>topic - headers - they will be enriched with header KafkaCryptoConstants.KEY_REF_HEADERdata - public void configure(Map<String,?> configs, boolean isKey)
configure in interface org.apache.kafka.common.serialization.Deserializer<T>public T deserialize(String topic, byte[] data)
deserialize(topic, new RecordHeaders(), data);
deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>topic - data - deserialize(String, Headers, byte[])public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface org.apache.kafka.common.serialization.Deserializer<T>Copyright © 2018. All rights reserved.