Saturday, 15 August 2015

java - Jersey: Pass value from ContainerRequestFilter to endpoint -



java - Jersey: Pass value from ContainerRequestFilter to endpoint -

i using bailiwick of jersey 2.9 , have created filter take encrypted header value, , decipher , pass along endpoint called on. have no thought of how this, , have been searching on net not found concrete illustration of want do. filter called, have issues passing value endpoint.

could guys help me!

here sample code:

public class myfilter implements containerrequestfilter { @override public void filter(containerrequestcontext requestcontext) throws webapplicationexception { string encryptedstring = requestcontext.getheaderstring("authentication"); /* doing methods remove encryption */ /* string want pass endpoint called on, in example: localhost:4883/rest/test */ } } @path("rest") public class resttest { @path("test") @get @produces(mediatype.application_json) public string testing(){ /* process value myfilter */ } }

you can modify header or add together one:

@override public void filter(containerrequestcontext requestcontext) throws ioexception { requestcontext.getheaders().add("x-authentication-decrypted", decryptedvalue); }

this value can injected in resource-method:

@get @produces(mediatype.application_json) public string testing(@headerparam("x-authentication-decrypted") string auth) { }

java rest servlets jersey

No comments:

Post a Comment