Class XorCsrfTokenRequestAttributeHandler
java.lang.Object
org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler
org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler
- All Implemented Interfaces:
CsrfTokenRequestHandler
,CsrfTokenRequestResolver
An implementation of the
CsrfTokenRequestHandler
interface that is capable of
masking the value of the CsrfToken
on each request and resolving the raw token
value from the masked value as either a header or parameter value of the request.- Since:
- 5.8
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Supplier<CsrfToken> deferredCsrfToken) Handles a request using aCsrfToken
.resolveCsrfTokenValue
(jakarta.servlet.http.HttpServletRequest request, CsrfToken csrfToken) Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.void
setSecureRandom
(SecureRandom secureRandom) Specifies theSecureRandom
used to generate random bytes that are used to mask the value of theCsrfToken
on each request.Methods inherited from class org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler
setCsrfRequestAttributeName
-
Constructor Details
-
XorCsrfTokenRequestAttributeHandler
public XorCsrfTokenRequestAttributeHandler()
-
-
Method Details
-
setSecureRandom
Specifies theSecureRandom
used to generate random bytes that are used to mask the value of theCsrfToken
on each request.- Parameters:
secureRandom
- theSecureRandom
to use to generate random bytes
-
handle
public void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Supplier<CsrfToken> deferredCsrfToken) Description copied from interface:CsrfTokenRequestHandler
Handles a request using aCsrfToken
.- Specified by:
handle
in interfaceCsrfTokenRequestHandler
- Overrides:
handle
in classCsrfTokenRequestAttributeHandler
- Parameters:
request
- theHttpServletRequest
being handledresponse
- theHttpServletResponse
being handleddeferredCsrfToken
- theCsrfToken
created by theCsrfTokenRepository
-
resolveCsrfTokenValue
public String resolveCsrfTokenValue(jakarta.servlet.http.HttpServletRequest request, CsrfToken csrfToken) Description copied from interface:CsrfTokenRequestResolver
Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.- Parameters:
request
- theHttpServletRequest
being processedcsrfToken
- theCsrfToken
created by theCsrfTokenRepository
- Returns:
- the token value resolved from the request
-