users@jersey.java.net

[Jersey] Re: ResourceFilterFactory and resource method

From: John Lister <john.lister_at_kickstone.com>
Date: Thu, 16 Dec 2010 08:06:20 +0000

A possible way is that your filter may have access to resource method
object allowing you to store the unencrypted data directly - although
this is plucking info from my memory. The other option which should work
is to pass the unencrypted data via a request scoped bean or other
request associated mechanism and access it within the resource method.
Either way you would need to pass some other data to the resource method
to prevent it unmarshalling the xml again and probably alter the media
type such that an alternative handler is used?

John

On 19:59, DaHoopster wrote:
> Hi,
>
> In order to implement seamless encryption and decryption, I created a
> resource filter that unmarshal the incoming XML stream into java objects,
> call the getter method to get the encrypted value, decrypt the value and
> pass it onto the resource method. In this manner, developers of individual
> resources can work with integers or unencrypted strings directly.
>
> Currently my implementation is inefficient that after decrypting the values,
> I am marshaling the java objects into XML again and forward the request onto
> the resource methods. Is there a way to skip the marshaling?
>
> Thanks,
>
> Here is some sudo code:
>
> in the resource filter:
>
> [code]
> MyObject javaObject =
> unmarshal(containerRequest.getEntityInputStream());
> decrypt(javaObject);
> InputStream is = marshal(javaObject);
> containerRequest.setEntityInputStream(is);
>
> return containerRequest;
> [code]
>
>
> In the resource method:
>
> [code]
> public void getInventoryItem(MyObject myObject)
> {
> ...
> ...
> }
> [code]