users@jersey.java.net

Re: [Jersey] ContainerRequestFilter and Resources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 19 Jan 2010 13:43:32 +0000

On Jan 19, 2010, at 1:26 PM, Cemo Koc wrote:

>
> Hi,
>
> As a security precaution we have implemented a login interceptor to
> for our
> resources. But now I have another case that I have to bypass login
> filter.
>
> My login interceptor is simply like this:
>
> public class LoginResourceFilter implements ResourceFilter,
> ContainerRequestFilter {
>
> @Context
> HttpServletRequest servletRequest;
>
> //
>
> @Override
> public ContainerRequest filter(ContainerRequest req) {
> //
> //
> //
> return isSecure;
>
> }
> }
>
>
>
> For now I am considering an annotation on my resource classes and
> methods
> results in bypassing my login filter.
>
> Ok, my question is how can I reach targeted resource and its
> annotations in
> my login interceptor?
>

See the ResourceFilterFactory#create method:

https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/container/ResourceFilterFactory.html
#create%28com.sun.jersey.api.model.AbstractMethod%29

For an example see the RolesAllowedResourceFilterFactory:

http://fisheye4.atlassian.com/browse/jersey/trunk/jersey/jersey-server/src/main/java/com/sun/jersey/api/container/filter/RolesAllowedResourceFilterFactory.java?r=HEAD


Paul.