Class WebTestUtils


  • public abstract class WebTestUtils
    extends java.lang.Object
    A utility class for testing spring security
    Since:
    4.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.springframework.security.web.csrf.CsrfTokenRepository getCsrfTokenRepository​(javax.servlet.http.HttpServletRequest request)
      Gets the CsrfTokenRepository for the specified HttpServletRequest.
      static org.springframework.security.web.context.SecurityContextRepository getSecurityContextRepository​(javax.servlet.http.HttpServletRequest request)
      Gets the SecurityContextRepository for the specified HttpServletRequest.
      static void setCsrfTokenRepository​(javax.servlet.http.HttpServletRequest request, org.springframework.security.web.csrf.CsrfTokenRepository repository)
      Sets the CsrfTokenRepository for the specified HttpServletRequest.
      static void setSecurityContextRepository​(javax.servlet.http.HttpServletRequest request, org.springframework.security.web.context.SecurityContextRepository securityContextRepository)
      Sets the SecurityContextRepository for the specified HttpServletRequest.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSecurityContextRepository

        public static org.springframework.security.web.context.SecurityContextRepository getSecurityContextRepository​(javax.servlet.http.HttpServletRequest request)
        Gets the SecurityContextRepository for the specified HttpServletRequest. If one is not found, a default HttpSessionSecurityContextRepository is used.
        Parameters:
        request - the HttpServletRequest to obtain the SecurityContextRepository
        Returns:
        the SecurityContextRepository for the specified HttpServletRequest
      • setSecurityContextRepository

        public static void setSecurityContextRepository​(javax.servlet.http.HttpServletRequest request,
                                                        org.springframework.security.web.context.SecurityContextRepository securityContextRepository)
        Sets the SecurityContextRepository for the specified HttpServletRequest.
        Parameters:
        request - the HttpServletRequest to obtain the SecurityContextRepository
        securityContextRepository - the SecurityContextRepository to set
      • getCsrfTokenRepository

        public static org.springframework.security.web.csrf.CsrfTokenRepository getCsrfTokenRepository​(javax.servlet.http.HttpServletRequest request)
        Gets the CsrfTokenRepository for the specified HttpServletRequest. If one is not found, the default HttpSessionCsrfTokenRepository is used.
        Parameters:
        request - the HttpServletRequest to obtain the CsrfTokenRepository
        Returns:
        the CsrfTokenRepository for the specified HttpServletRequest
      • setCsrfTokenRepository

        public static void setCsrfTokenRepository​(javax.servlet.http.HttpServletRequest request,
                                                  org.springframework.security.web.csrf.CsrfTokenRepository repository)
        Sets the CsrfTokenRepository for the specified HttpServletRequest.
        Parameters:
        request - the HttpServletRequest to obtain the CsrfTokenRepository
        repository - the CsrfTokenRepository to set