Hi JP,

If I understand correctly, your scenario would be:
1. extract the encrypted data item from json (into a flowfile attribute)
2. decrypt the data
3. replace the encrypted data item with the decrypted one in json

Unfortunately, there is no EncryptAttribute processor at the moment which
would be more suitable for this scenario (though there is an open issue
<https://issues.apache.org/jira/browse/NIFI-2961> for it).

You can do it with EncryptContent too but it is a bit complicated because
you need to put the encrypted data into the flowfile content and decrypt it
there.

A possible scenario:
- back up the original json into an attribute** with ExtractText
- extract the encrypted data item from the json into an attribute with
EvaluateJsonPath
- replace the whole flowfile content to the encrypted data with ReplaceText
- base64 decode the encrypted data in the flowfile content with
Base64EncodeContent (I supposed your json contains the password as base64
encoded string)
- decrypt the flowfile content with EncryptContent
- copy the decrypted password from the content into an attribute with
ExtractText
- restore the original json into the content (from the attribute where it
was saved) with ReplaceText
- replace the encrypted data item with the decrypted one in the json with
ReplaceText

**The drawback is (beyond the complexity) that the flowfile content (the
original json) needs to be stored in an attribute which is not really
recommended (or only in case of small files).

It could be avoided by splitting the flow into 2 branches, one for the
original json (in the conient, not in an attribute) and one for the data
decryption, then merge the two branches with MergeContent. However, it
would be more complicated than the previous one because you need to handle
the merging of the two branches.

If there won't be better suggestions to solve your scenario, I can share
the sample flow I described above.


Regards,
Peter

On Tue, Apr 16, 2019 at 1:34 AM jpconver <jpcon...@gmail.com> wrote:

> Dear all!
>
> I'm a Nifi Newbie and I'd like some guidance to solve this problem.
>
> I have a use case where I receive a JSON with one field encrypted. What I'd
> like to do is to process this JSON with NiFi and return the original JSON
> but with the field decrypted. I'd like to use the processor EncryptContent
> if that's possible.
> I know the name of the encrypted field in advance.
>
> For example if a Receive the following json
>
> {"id":"1","name":"paul","password":"encryptedPassword"}
>
> I'd like to return (or have an some point of the flow)
>
> {"id":"1","name":"paul","password":"decryptedPassword"}
>
> What would be the best strategy to achieve this without developing a custom
> processor?
>
> Thanks!
>   JP
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>

Reply via email to