public class CsrfPreventionFilter extends FilterBase
HttpServletResponse.encodeRedirectURL(String) and
HttpServletResponse.encodeURL(String) are used to encode all URLs
returned to the client
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CsrfPreventionFilter.CsrfResponseWrapper |
protected static class |
CsrfPreventionFilter.LruCache<T> |
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
log |
rb| Constructor and Description |
|---|
CsrfPreventionFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected String |
generateNonce()
Generate a once time token (nonce) for authenticating subsequent
requests.
|
protected Logger |
getLogger() |
void |
init(javax.servlet.FilterConfig filterConfig) |
protected boolean |
isConfigProblemFatal()
Determines if an exception when calling a setter or an unknown
configuration attribute triggers the failure of the this filter which in
turn will prevent the web application from starting.
|
void |
setEntryPoints(String entryPoints)
Entry points are URLs that will not be tested for the presence of a valid
nonce.
|
void |
setNonceCacheSize(int nonceCacheSize)
Sets the number of previously issued nonces that will be cached on a LRU
basis to support parallel requests, limited use of the refresh and back
in the browser and similar behaviors that may result in the submission
of a previous nonce rather than the current one.
|
void |
setRandomClass(String randomClass)
Specify the class to use to generate the nonces.
|
destroyprotected static final Logger log
protected Logger getLogger()
getLogger in class FilterBasepublic void setEntryPoints(String entryPoints)
entryPoints - Comma separated list of URLs to be configured as
entry points.public void setNonceCacheSize(int nonceCacheSize)
nonceCacheSize - The number of nonces to cachepublic void setRandomClass(String randomClass)
Random.randomClass - The name of the class to usepublic void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterinit in class FilterBasejavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
IOExceptionjavax.servlet.ServletExceptionprotected boolean isConfigProblemFatal()
FilterBaseisConfigProblemFatal in class FilterBasetrue if a problem should trigger the failure of this
filter, else falseprotected String generateNonce()
Copyright © 2017. All rights reserved.