Getting request entity in Jersey's ClientRequestFilter

79 Views Asked by At

My application is using Jersey client and I want to deploy it on AWS and access resources that require request authentication using AWS SigV4.

I have looked at client code examples specific to the Neptune DB (which is the service I'm planning to use). They depend on getting the request entity content, which is one of the things used for SigV4 signing, together with the request URI and headers.

I was planning to implement the Jersey version as ClientRequestFilter, but I realized that while the entity object is set (it can be retrieved using ClientRequestContext::getEntity), it is not yet written at that stage. Serialization happens later in the lifecycle in the MessageBodyWriter.

Any ideas how to implement it? One caveat is that signing has to be applied even when the request has no entity (empty string is used as the entity in that case).

In the meanwhile I will try to inject Providers into the ClientRequestFilter and serialize the entity there, or split this implementation over the ClientRequestFilter and the MessageBodyWriter, which would not be ideal.

0

There are 0 best solutions below