Class | Description |
---|---|
CsrfProtectionFilter |
Simple server-side request filter that implements CSRF protection as per the
Guidelines for Implementation of REST
by NSA (section IV.F) and
section 4.3 of this paper.
|
GZIPContentEncodingFilter |
A GZIP content encoding filter.
|
LoggingFilter |
A logging filter.
|
PostReplaceFilter |
A filter to support HTTP method replacing of a POST request to a request
utilizing another HTTP method for the case where proxies or HTTP
servers would otherwise block that HTTP method.
|
ResourceDebuggingFilterFactory |
A
ResourceFilterFactory provides tracking of resource
matching. |
RolesAllowedResourceFilterFactory |
A
ResourceFilterFactory supporting the RolesAllowed ,
PermitAll and DenyAll on resource methods sub-resource methods,
and sub-resource locators. |
UriConnegFilter |
A URI-based content negotiation filter mapping a dot-declared suffix in
URI to media type that is the value of the
Accept header
or a language that is the value of the Accept-Language header. |
Enum | Description |
---|---|
PostReplaceFilter.ConfigFlag |
Enum representing configuration flags that can be set on the filter.
|
There are two types of filter that may be registered with Jersey:
Container filters are registered as properties of the ResourceConfig
.
Container request filters, of the class ContainerRequestFilter
, are
registered using the property ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS
.
Container response filters, of the class ContainerResponseFilter
, are
registered using the property ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS
.
For example, to log requests and responses when an application is deployed
as a Servlet or Filter a LoggingFilter
can be registered using
the following initialization parameters:
Note that two or more request or response filters may be registered as a ';' separated list of fully qualified class names.<init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value> </init-param>
Resource filters are registered using two mechanisms:
ResourceFilterFactory
, are registered using the
property ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES
.ResourceFilter
, declared using the
annotation ResourceFilters
, which may
occur on a resource class, resource method, sub-resource method or sub-resource locator.
For example, to support RolesAllowed
on resource classes when an application
is deployed as a Servlet or Filter a
RolesAllowedResourceFilterFactory
can be registered using the following initialization parameter:
Note that two or more resource filter factories may be registered as a ';' separated list of fully qualified class names.<init-param> <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name> <param-value>com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory</param-value> </init-param>
The use of resource filter factories allow the application of filters to any
method of a resource class that conforms to a certain pattern as defined by
a resource filter factory implementation. For example, the support for the
annotation ResourceFilters
is implemented
as a resource filter factory, that is registered after all user-registered
resource filter factories.
If an exception is thrown by a request filter (registered using any mechanism) then:
Copyright © 2016 Oracle Corporation. All Rights Reserved.