Class CachedCsrfTokenRepository

java.lang.Object
com.erudika.para.server.security.CachedCsrfTokenRepository
All Implemented Interfaces:
org.springframework.security.web.csrf.CsrfTokenRepository

public class CachedCsrfTokenRepository extends Object implements org.springframework.security.web.csrf.CsrfTokenRepository
A CsrfTokenRepository that stores the CsrfToken in Cache.
Author:
Alex Bogdanovski [[email protected]]
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.web.csrf.CsrfToken
    generateToken(javax.servlet.http.HttpServletRequest request)
    Generates a CSRF token string.
    Returns the cache object.
    org.springframework.security.web.csrf.CsrfToken
    loadToken(javax.servlet.http.HttpServletRequest request)
    Loads a CSRF token from cache.
    void
    saveToken(org.springframework.security.web.csrf.CsrfToken t, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Saves a CSRF token in cache.
    void
    setCache(Cache cache)
    Sets the cache object.
    void
    setHeaderName(String parameterName)
    Sets the header name that the CsrfToken is expected to appear on and the header that the response will contain the CsrfToken.
    void
    setParameterName(String parameterName)
    Sets the HttpServletRequest parameter name that the CsrfToken is expected to appear on.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.security.web.csrf.CsrfTokenRepository

    loadDeferredToken
  • Constructor Details

    • CachedCsrfTokenRepository

      public CachedCsrfTokenRepository()
  • Method Details

    • getCache

      public Cache getCache()
      Returns the cache object.
      Returns:
      the cache object
    • setCache

      @Inject public void setCache(Cache cache)
      Sets the cache object.
      Parameters:
      cache - a cache object
    • saveToken

      public void saveToken(org.springframework.security.web.csrf.CsrfToken t, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Saves a CSRF token in cache.
      Specified by:
      saveToken in interface org.springframework.security.web.csrf.CsrfTokenRepository
      Parameters:
      t - (ignored)
      request - HTTP request
      response - HTTP response
    • loadToken

      public org.springframework.security.web.csrf.CsrfToken loadToken(javax.servlet.http.HttpServletRequest request)
      Loads a CSRF token from cache.
      Specified by:
      loadToken in interface org.springframework.security.web.csrf.CsrfTokenRepository
      Parameters:
      request - HTTP request
      Returns:
      the token
    • generateToken

      public org.springframework.security.web.csrf.CsrfToken generateToken(javax.servlet.http.HttpServletRequest request)
      Generates a CSRF token string.
      Specified by:
      generateToken in interface org.springframework.security.web.csrf.CsrfTokenRepository
      Parameters:
      request - HTTP request
      Returns:
      a new token
    • setParameterName

      public void setParameterName(String parameterName)
      Sets the HttpServletRequest parameter name that the CsrfToken is expected to appear on.
      Parameters:
      parameterName - the new parameter name to use
    • setHeaderName

      public void setHeaderName(String parameterName)
      Sets the header name that the CsrfToken is expected to appear on and the header that the response will contain the CsrfToken.
      Parameters:
      parameterName - the new parameter name to use