Class HttpSessionCsrfTokenRepository
java.lang.Object
org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository
- All Implemented Interfaces:
CsrfTokenRepository
- Since:
- 3.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateToken(jakarta.servlet.http.HttpServletRequest request) Generates aCsrfToken@Nullable CsrfTokenloadToken(jakarta.servlet.http.HttpServletRequest request) Loads the expectedCsrfTokenfrom theHttpServletRequestvoidsaveToken(@Nullable CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) voidsetHeaderName(String headerName) voidsetParameterName(String parameterName) Sets theHttpServletRequestparameter name that theCsrfTokenis expected to appear onvoidsetSessionAttributeName(String sessionAttributeName) Sets theHttpSessionattribute name that theCsrfTokenis stored inMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CsrfTokenRepository
loadDeferredToken
-
Constructor Details
-
HttpSessionCsrfTokenRepository
public HttpSessionCsrfTokenRepository()
-
-
Method Details
-
saveToken
public void saveToken(@Nullable CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:CsrfTokenRepositorySaves theCsrfTokenusing theHttpServletRequestandHttpServletResponse. If theCsrfTokenis null, it is the same as deleting it.- Specified by:
saveTokenin interfaceCsrfTokenRepository- Parameters:
token- theCsrfTokento save or null to deleterequest- theHttpServletRequestto useresponse- theHttpServletResponseto use
-
loadToken
Description copied from interface:CsrfTokenRepositoryLoads the expectedCsrfTokenfrom theHttpServletRequest- Specified by:
loadTokenin interfaceCsrfTokenRepository- Parameters:
request- theHttpServletRequestto use- Returns:
- the
CsrfTokenor null if none exists
-
generateToken
Description copied from interface:CsrfTokenRepositoryGenerates aCsrfToken- Specified by:
generateTokenin interfaceCsrfTokenRepository- Parameters:
request- theHttpServletRequestto use- Returns:
- the
CsrfTokenthat was generated. Cannot be null.
-
setParameterName
-
setHeaderName
-
setSessionAttributeName
-