javax.servlet.Filter@Public
@Evolving
public class RestCsrfPreventionFilter
extends java.lang.Object
implements javax.servlet.Filter
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
RestCsrfPreventionFilter.HttpInteraction |
Defines the minimal API requirements for the filter to execute its
filtering logic.
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
BROWSER_USER_AGENT_PARAM |
|
static java.lang.String |
CUSTOM_HEADER_PARAM |
|
static java.lang.String |
CUSTOM_METHODS_TO_IGNORE_PARAM |
|
static java.lang.String |
HEADER_DEFAULT |
|
static java.lang.String |
HEADER_USER_AGENT |
| Constructor | Description |
|---|---|
RestCsrfPreventionFilter() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
destroy() |
|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
|
static java.util.Map<java.lang.String,java.lang.String> |
getFilterParams(Configuration conf,
java.lang.String confPrefix) |
Constructs a mapping of configuration properties to be used for filter
initialization.
|
void |
handleHttpInteraction(RestCsrfPreventionFilter.HttpInteraction httpInteraction) |
Handles an
RestCsrfPreventionFilter.HttpInteraction by applying the filtering logic. |
void |
init(javax.servlet.FilterConfig filterConfig) |
|
protected boolean |
isBrowser(java.lang.String userAgent) |
This method interrogates the User-Agent String and returns whether it
refers to a browser.
|
public static final java.lang.String HEADER_USER_AGENT
public static final java.lang.String BROWSER_USER_AGENT_PARAM
public static final java.lang.String CUSTOM_HEADER_PARAM
public static final java.lang.String CUSTOM_METHODS_TO_IGNORE_PARAM
public static final java.lang.String HEADER_DEFAULT
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionprotected boolean isBrowser(java.lang.String userAgent)
A User-Agent String is considered to be a browser if it matches any of the regex patterns from browser-useragent-regex; the default behavior is to consider everything a browser that matches the following: "^Mozilla.*,^Opera.*". Subclasses can optionally override this method to use different behavior.
userAgent - The User-Agent String, or null if there isn't onepublic void handleHttpInteraction(RestCsrfPreventionFilter.HttpInteraction httpInteraction) throws java.io.IOException, javax.servlet.ServletException
RestCsrfPreventionFilter.HttpInteraction by applying the filtering logic.httpInteraction - caller's HTTP interactionjava.io.IOException - if there is an I/O errorjavax.servlet.ServletException - if the implementation relies on the servlet API
and a servlet API call has failedpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws java.io.IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.Filterjava.io.IOExceptionjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.Filterpublic static java.util.Map<java.lang.String,java.lang.String> getFilterParams(Configuration conf, java.lang.String confPrefix)
conf - configuration to readconfPrefix - configuration prefixCopyright © 2008–2025 Apache Software Foundation. All rights reserved.