Class HttpSessionCsrfTokenRepository
- java.lang.Object
- 
- org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository
 
- 
- All Implemented Interfaces:
- CsrfTokenRepository
 
 public final class HttpSessionCsrfTokenRepository extends java.lang.Object implements CsrfTokenRepository - Since:
- 3.2
 
- 
- 
Constructor SummaryConstructors Constructor Description HttpSessionCsrfTokenRepository()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CsrfTokengenerateToken(javax.servlet.http.HttpServletRequest request)Generates aCsrfTokenCsrfTokenloadToken(javax.servlet.http.HttpServletRequest request)Loads the expectedCsrfTokenfrom theHttpServletRequestvoidsaveToken(CsrfToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)voidsetHeaderName(java.lang.String headerName)voidsetParameterName(java.lang.String parameterName)Sets theHttpServletRequestparameter name that theCsrfTokenis expected to appear onvoidsetSessionAttributeName(java.lang.String sessionAttributeName)Sets theHttpSessionattribute name that theCsrfTokenis stored in
 
- 
- 
- 
Method Detail- 
saveTokenpublic void saveToken(CsrfToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Description copied from interface:CsrfTokenRepositorySaves theCsrfTokenusing theHttpServletRequestandHttpServletResponse. If theCsrfTokenis null, it is the same as deleting it.- Specified by:
- saveTokenin interface- CsrfTokenRepository
- Parameters:
- token- the- CsrfTokento save or null to delete
- request- the- HttpServletRequestto use
- response- the- HttpServletResponseto use
 
 - 
loadTokenpublic CsrfToken loadToken(javax.servlet.http.HttpServletRequest request) Description copied from interface:CsrfTokenRepositoryLoads the expectedCsrfTokenfrom theHttpServletRequest- Specified by:
- loadTokenin interface- CsrfTokenRepository
- Parameters:
- request- the- HttpServletRequestto use
- Returns:
- the CsrfTokenor null if none exists
 
 - 
generateTokenpublic CsrfToken generateToken(javax.servlet.http.HttpServletRequest request) Description copied from interface:CsrfTokenRepositoryGenerates aCsrfToken- Specified by:
- generateTokenin interface- CsrfTokenRepository
- Parameters:
- request- the- HttpServletRequestto use
- Returns:
- the CsrfTokenthat was generated. Cannot be null.
 
 - 
setParameterNamepublic void setParameterName(java.lang.String parameterName) Sets theHttpServletRequestparameter name that theCsrfTokenis expected to appear on- Parameters:
- parameterName- the new parameter name to use
 
 - 
setHeaderNamepublic void setHeaderName(java.lang.String headerName) Sets the header name that theCsrfTokenis expected to appear on and the header that the response will contain theCsrfToken.- Parameters:
- headerName- the new header name to use
 
 - 
setSessionAttributeNamepublic void setSessionAttributeName(java.lang.String sessionAttributeName) Sets theHttpSessionattribute name that theCsrfTokenis stored in- Parameters:
- sessionAttributeName- the new attribute name to use
 
 
- 
 
-