Class LazyCsrfTokenRepository
java.lang.Object
org.springframework.security.web.csrf.LazyCsrfTokenRepository
- All Implemented Interfaces:
- CsrfTokenRepository
@Deprecated
public final class LazyCsrfTokenRepository
extends Object
implements CsrfTokenRepository
Deprecated.
A 
CsrfTokenRepository that delays saving new CsrfToken until the
 attributes of the CsrfToken that were generated are accessed.- Since:
- 4.1
- 
Constructor SummaryConstructorsConstructorDescriptionLazyCsrfTokenRepository(CsrfTokenRepository delegate) Deprecated.Creates a new instance
- 
Method SummaryModifier and TypeMethodDescriptiongenerateToken(jakarta.servlet.http.HttpServletRequest request) Deprecated.Generates a new tokenloadToken(jakarta.servlet.http.HttpServletRequest request) Deprecated.Delegates to the injectedCsrfTokenRepositoryvoidsaveToken(CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Deprecated.Does nothing if theCsrfTokenis not null.voidsetDeferLoadToken(boolean deferLoadToken) Deprecated.Determines ifloadToken(HttpServletRequest)should be lazily loaded.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.web.csrf.CsrfTokenRepositoryloadDeferredToken
- 
Constructor Details- 
LazyCsrfTokenRepositoryDeprecated.Creates a new instance- Parameters:
- delegate- the- CsrfTokenRepositoryto use. Cannot be null
- Throws:
- IllegalArgumentException- if delegate is null.
 
 
- 
- 
Method Details- 
setDeferLoadTokenpublic void setDeferLoadToken(boolean deferLoadToken) Deprecated.Determines ifloadToken(HttpServletRequest)should be lazily loaded.- Parameters:
- deferLoadToken- true if should lazily load- loadToken(HttpServletRequest). Default false.
 
- 
generateTokenDeprecated.Generates a new token- Specified by:
- generateTokenin interface- CsrfTokenRepository
- Parameters:
- request- the- HttpServletRequestto use. The- HttpServletRequestmust have the- HttpServletResponseas an attribute with the name of- HttpServletResponse.class.getName()
- Returns:
- the CsrfTokenthat was generated. Cannot be null.
 
- 
saveTokenpublic void saveToken(CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Deprecated.Does nothing if theCsrfTokenis not null. Saving is done only when theCsrfToken.getToken()is accessed fromgenerateToken(HttpServletRequest). If it is null, then the save is performed immediately.- Specified by:
- saveTokenin interface- CsrfTokenRepository
- Parameters:
- token- the- CsrfTokento save or null to delete
- request- the- HttpServletRequestto use
- response- the- HttpServletResponseto use
 
- 
loadTokenDeprecated.Delegates to the injectedCsrfTokenRepository- Specified by:
- loadTokenin interface- CsrfTokenRepository
- Parameters:
- request- the- HttpServletRequestto use
- Returns:
- the CsrfTokenor null if none exists
 
 
- 
CsrfTokenRepository.loadDeferredToken(HttpServletRequest, HttpServletResponse)which returns aDeferredCsrfToken