Patricio Téllez
Patricio Téllez

Reputation: 141

Include message hash in Metadata using grpc-java on ClientInterceptor?

I am using grpc-java for a PoC and one of the main objectives of this test is to validate Metadata/Message integrity; basically I am trying to hash some call properties (user, time, traceId, etc.) and the data sent to the server into a single JWT token that's sent as Metadata.

The problem I am facing is that using ClientInterceptor and SimpleForwardingClientCall the "sendMessage" method, from where I would get the message hash, is called after the "start" method where the Metadata is available... and it seems that by design Metadata is sent while executing the "start" method so I would have to calculate the hash of the data sent before that...

Has anyone done something like this? Am I missing some functionality?

Thanks for any help or advice...

Upvotes: 0

Views: 588

Answers (1)

Eric Anderson
Eric Anderson

Reputation: 26414

You can delay calling next.newCall() or calling clientCall.start() until your interceptor's sendMessage() is called. You would need to save the values in fields and then play them back when sendMessage() is called.

Upvotes: 1

Related Questions