Class LazyCsrfTokenRepository

    • Constructor Detail

      • LazyCsrfTokenRepository

        public LazyCsrfTokenRepository​(CsrfTokenRepository delegate)
        Creates a new instance
        Parameters:
        delegate - the CsrfTokenRepository to use. Cannot be null
        Throws:
        java.lang.IllegalArgumentException - if delegate is null.
    • Method Detail

      • generateToken

        public CsrfToken generateToken​(javax.servlet.http.HttpServletRequest request)
        Generates a new token
        Specified by:
        generateToken in interface CsrfTokenRepository
        Parameters:
        request - the HttpServletRequest to use. The HttpServletRequest must have the HttpServletResponse as an attribute with the name of HttpServletResponse.class.getName()
        Returns:
        the CsrfToken that was generated. Cannot be null.
      • saveToken

        public void saveToken​(CsrfToken token,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
        Does nothing if the CsrfToken is not null. Saving is done only when the CsrfToken.getToken() is accessed from generateToken(HttpServletRequest). If it is null, then the save is performed immediately.
        Specified by:
        saveToken in interface CsrfTokenRepository
        Parameters:
        token - the CsrfToken to save or null to delete
        request - the HttpServletRequest to use
        response - the HttpServletResponse to use