Module com.erudika.para.server
Package com.erudika.para.server.security
Class CachedCsrfTokenRepository
java.lang.Object
com.erudika.para.server.security.CachedCsrfTokenRepository
- All Implemented Interfaces:
org.springframework.security.web.csrf.CsrfTokenRepository
public class CachedCsrfTokenRepository
extends Object
implements org.springframework.security.web.csrf.CsrfTokenRepository
- Author:
- Alex Bogdanovski [[email protected]]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.web.csrf.CsrfToken
generateToken
(javax.servlet.http.HttpServletRequest request) Generates a CSRF token string.getCache()
Returns the cache object.org.springframework.security.web.csrf.CsrfToken
loadToken
(javax.servlet.http.HttpServletRequest request) Loads a CSRF token from cache.void
saveToken
(org.springframework.security.web.csrf.CsrfToken t, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Saves a CSRF token in cache.void
Sets the cache object.void
setHeaderName
(String parameterName) Sets the header name that theCsrfToken
is expected to appear on and the header that the response will contain theCsrfToken
.void
setParameterName
(String parameterName) Sets theHttpServletRequest
parameter name that theCsrfToken
is expected to appear on.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.security.web.csrf.CsrfTokenRepository
loadDeferredToken
-
Constructor Details
-
CachedCsrfTokenRepository
public CachedCsrfTokenRepository()
-
-
Method Details
-
getCache
Returns the cache object.- Returns:
- the cache object
-
setCache
Sets the cache object.- Parameters:
cache
- a cache object
-
saveToken
public void saveToken(org.springframework.security.web.csrf.CsrfToken t, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Saves a CSRF token in cache.- Specified by:
saveToken
in interfaceorg.springframework.security.web.csrf.CsrfTokenRepository
- Parameters:
t
- (ignored)request
- HTTP requestresponse
- HTTP response
-
loadToken
public org.springframework.security.web.csrf.CsrfToken loadToken(javax.servlet.http.HttpServletRequest request) Loads a CSRF token from cache.- Specified by:
loadToken
in interfaceorg.springframework.security.web.csrf.CsrfTokenRepository
- Parameters:
request
- HTTP request- Returns:
- the token
-
generateToken
public org.springframework.security.web.csrf.CsrfToken generateToken(javax.servlet.http.HttpServletRequest request) Generates a CSRF token string.- Specified by:
generateToken
in interfaceorg.springframework.security.web.csrf.CsrfTokenRepository
- Parameters:
request
- HTTP request- Returns:
- a new token
-
setParameterName
Sets theHttpServletRequest
parameter name that theCsrfToken
is expected to appear on.- Parameters:
parameterName
- the new parameter name to use
-
setHeaderName
Sets the header name that theCsrfToken
is expected to appear on and the header that the response will contain theCsrfToken
.- Parameters:
parameterName
- the new parameter name to use
-