Class XorCsrfTokenRequestAttributeHandler
- java.lang.Object
-
- org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler
-
- org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler
-
- All Implemented Interfaces:
CsrfTokenRequestHandler
,CsrfTokenRequestResolver
public final class XorCsrfTokenRequestAttributeHandler extends CsrfTokenRequestAttributeHandler
An implementation of theCsrfTokenRequestHandler
interface that is capable of masking the value of theCsrfToken
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
Constructors Constructor Description XorCsrfTokenRequestAttributeHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.function.Supplier<CsrfToken> deferredCsrfToken)
Handles a request using aCsrfToken
.java.lang.String
resolveCsrfTokenValue(javax.servlet.http.HttpServletRequest request, CsrfToken csrfToken)
Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.void
setSecureRandom(java.security.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
-
-
-
-
Method Detail
-
setSecureRandom
public void setSecureRandom(java.security.SecureRandom secureRandom)
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(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.function.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 java.lang.String resolveCsrfTokenValue(javax.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
-
-