users@jersey.java.net

[Jersey] Re: ResourceFilterFactory and resource method

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 16 Dec 2010 15:36:22 +0100

Hi,

You can determine the entity type information required by the resource
method from the abstract model. Your filter can place decrypted
information in the request properties or else where if using DI.
Specific MessageBodyReaders can be registered for a set of types that
knows about such properties.

The key here is to use some form of marker type or annotation
associated with the entity to signal decryption processing if the
entity is found to be in encrypted form, otherwise it can just be
transparent or result in some automatic 400 response.

Paul.

On Dec 16, 2010, at 9:06 AM, John Lister wrote:

> 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]