Did you try using @HeaderParam and @DefaultValue?
On Tue, Mar 5, 2019 at 1:40 AM Pablo Caballero <[email protected]> wrote:

> Hi folks!
>
> I'm writing a REST client to interact with a service exposed by my home
> router (*1).
>
> The service consist of a set of operations exposed in a unique URI (
> https://xxx.xxx.xxx.xxx/JNAP/). The operation being called depends on the
> value of a special http header (X-JNAP-Action). Some operations require
> authentication and some don't (authentication works as http basic auth but
> using a custom header called X-JNAP-Authorization). You can read about this
> API in https://github.com/reujab/linksys.
>
> My idea is to use two custom annotations to:
> - map the interface method to the correlated X-JNAP-Action value
> - mark operations that need authentication
>
> and use an/two interceptor/interceptors to implement the logic.
>
> Something like this:
>
> @Path("/JNAP/")
> @Consumes({ "application/json" })
> @Produces({ "application/json" })
> public interface JNAPClient {
>
>     @POST
>     @Path("")
>     @JNAPAction(value="router/GetWANStatus3")
>     @JNAPAuthorization
>     public WanStatus3 getWanStatus3();
>
>     @POST
>     @Path("")
>     @JNAPAction(value="router/blah")
>     @JNAPAuthorization
>     public BlahResponse doBlah();
>
> and so on...
>
> I read about using message.getExchange().get(OperationResourceInfo.class)
> (*2) to get access to the target method inside an interceptor and I wrote a
> bit of code to test it but I couldn't make it work (I get a null value as a
> result of calling message.getExchange()... ). So, I decided to take a
> deeper look at the Message parameter inspecting its value and I figured out
> that there was a OperationResourceInfo element in the MessageImpl's
> "contents" member. At this point I'm wondering if it's ok to cast the
> "message" parameter to MessageImpl and use the getContent method to access
> the ori's info or if should find another solution.
>
> Thank you very much!
>
> Best regards
>
> (*1) https://www.linksys.com/us/p/P-EA9300/
> (*2)
>
> https://stackoverflow.com/questions/4219093/determine-target-service-method-from-cxf-interceptor
>

Reply via email to