Class WebTestUtils


  • public abstract class WebTestUtils
    extends Object
    A utility class for testing spring security
    Since:
    4.0
    Author:
    Rob Winch
    • 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 setSecurityContextRepository​(javax.servlet.http.HttpServletRequest request, org.springframework.security.web.context.SecurityContextRepository securityContextRepository)
      Sets the SecurityContextRepository for the specified HttpServletRequest.
    • 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