Class SpringSecurityMVCWebProcessingContextBuilder

Object
org.thymeleaf.testing.templateengine.context.web.WebProcessingContextBuilder
org.thymeleaf.testing.templateengine.spring6.context.web.SpringMVCWebProcessingContextBuilder
org.thymeleaf.testing.templateengine.spring6.context.web.SpringSecurityMVCWebProcessingContextBuilder
All Implemented Interfaces:
org.thymeleaf.testing.templateengine.context.IProcessingContextBuilder

public class SpringSecurityMVCWebProcessingContextBuilder extends SpringMVCWebProcessingContextBuilder
  • Field Details

  • Constructor Details

    • SpringSecurityMVCWebProcessingContextBuilder

      public SpringSecurityMVCWebProcessingContextBuilder(org.thymeleaf.testing.templateengine.context.web.ITestWebExchangeBuilder testWebExchangeBuilder)
    • SpringSecurityMVCWebProcessingContextBuilder

      public SpringSecurityMVCWebProcessingContextBuilder()
  • Method Details

    • getAuthenticationManagerBeanName

      public String getAuthenticationManagerBeanName()
    • setAuthenticationManagerBeanName

      public void setAuthenticationManagerBeanName(String authenticationManagerBeanName)
    • initSpring

      protected final void initSpring(org.springframework.context.ApplicationContext applicationContext, org.thymeleaf.testing.templateengine.testable.ITest test, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.ServletContext servletContext, Locale locale, Map<String,Object> variables)
      Overrides:
      initSpring in class SpringMVCWebProcessingContextBuilder
    • getAuthentication

      protected org.springframework.security.core.Authentication getAuthentication(org.springframework.context.ApplicationContext applicationContext, org.thymeleaf.testing.templateengine.testable.ITest test, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.ServletContext servletContext, Locale locale, Map<String,Object> variables)

      Computes and returns a Spring Security Authentication object to be used for authenticating the desired user for testing purposes.

      By default, an UsernamePasswordAuthenticationToken object is returned, built with the values of two context variables:

      • j_username for the user name.
      • j_password for the user password.

      If one or both of these variables are not present, null is returned and therefore no user will be considered to be authenticated.

      Parameters:
      applicationContext - the application context, already initialized
      test - the ITest object
      request - the HTTP request object
      response - the HTTP response object
      servletContext - the ServletContext object
      locale - the locale being used for this test
      variables - the context variables
      Returns:
      the Authentication object, null if no user is to be considered authenticated.