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 Summary
Constructors Constructor Description HttpSessionCsrfTokenRepository()
-
Method Summary
All 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
-
saveToken
public 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 interfaceCsrfTokenRepository- Parameters:
token- theCsrfTokento save or null to deleterequest- theHttpServletRequestto useresponse- theHttpServletResponseto use
-
loadToken
public CsrfToken loadToken(javax.servlet.http.HttpServletRequest request)
Description copied from interface:CsrfTokenRepositoryLoads the expectedCsrfTokenfrom theHttpServletRequest- Specified by:
loadTokenin interfaceCsrfTokenRepository- Parameters:
request- theHttpServletRequestto use- Returns:
- the
CsrfTokenor null if none exists
-
generateToken
public CsrfToken generateToken(javax.servlet.http.HttpServletRequest request)
Description copied from interface:CsrfTokenRepositoryGenerates aCsrfToken- Specified by:
generateTokenin interfaceCsrfTokenRepository- Parameters:
request- theHttpServletRequestto use- Returns:
- the
CsrfTokenthat was generated. Cannot be null.
-
setParameterName
public void setParameterName(java.lang.String parameterName)
Sets theHttpServletRequestparameter name that theCsrfTokenis expected to appear on- Parameters:
parameterName- the new parameter name to use
-
setHeaderName
public 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
-
setSessionAttributeName
public void setSessionAttributeName(java.lang.String sessionAttributeName)
Sets theHttpSessionattribute name that theCsrfTokenis stored in- Parameters:
sessionAttributeName- the new attribute name to use
-
-