grizzly - Jersey not triggering ContainerRequestFilter -
i'm trying use containerrequestfilter enforce authentication on grizzly based jersey application.
i create own resource config extending packagesresourceconfig:
public class mainresourceconfig extends packagesresourceconfig { public mainresourceconfig() { super("za.co.quinn.ws"); map<string, object> properties = getproperties(); properties.put( "com.sun.jersey.spi.container.containerrequestfilter", "com.sun.jersey.api.container.filter.loggingfilter;" + mainrequestfilter.class.getname() ); properties.put( "com.sun.jersey.spi.container.containerresponsefilters", "com.sun.jersey.api.container.filter.loggingfilter;" + mainresponsefilter.class.getname() ); } }
the request filter authentication:
@inject authorization authorization; @override public containerrequest filter(containerrequest request) { if (!request.getrequesturi().getpath().endswith(".wadl")) authorization.authorize(request); return request; }
the response filter headers:
@override public containerresponse filter(containerrequest request, containerresponse response) { response.gethttpheaders().add("access-control-allow-origin", "*"); response.gethttpheaders().add("access-control-allow-methods", "get, head, post, delete, put"); response.gethttpheaders().add("access-control-allow-headers", "authorization, content-type"); return response; }
the mainresponsefilter triggered not containerrequestfilter.
"the mainresponsefilter triggered not containerrequestfilter."
look @ properties, send of it, , compare them
...container.containerrequestfilter" ...container.containerresponsefilters"
you're missing s
request filters. avoid misspellings this, can use constants
resourceconfig.property_container_request_filters
resourceconfig.property_container_response_filters
you do
getcontainerrequestfilters().add(new yourrequestfilter()); getcontainerresponsefilters().add(new yourresponsefilter());
Comments
Post a Comment