You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Enrico Agnoli <en...@workday.com> on 2018/03/11 13:02:36 UTC

Hook to Encrypt after serialization

Hi!

We use Avro to compile our schema files and serialize/deserialize the data in a distributed environment for streaming processing (client-kafka-flink).
In the project we have the need to encrypt some data both at transmission and in some phases of the processing (as example when serialized as checkpoints for Flink states).

I would like to have AVRO delegate the “close” of a serialized byte[] to a class that I define so I can define some logic that via a keyProvider retrieves the keys and encrypt/decrypt the data.

My idea is to fork and modify the AVRO project to add a new encoder the first times this is entered:
https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java#L61
and then, if the datum object extends an interface with two methods: `afterSerialization(...)  and beforeDeserialization(...)` delegates to these the encryption/decryption.

Is there a way to achieve this without modifying AVRO code nor the caller (creator of the Encoder code)?

Thanks a lot for any help.
-Enrico