@Override public RequestPostProcessor beforeMockMvcCreated( ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) { return SecurityMockMvcRequestPostProcessors.testSecurityContext(); }
@Override public RequestPostProcessor beforeMockMvcCreated( ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) { String securityBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN; if (this.springSecurityFilterChain == null && context.containsBean(securityBeanId)) { this.springSecurityFilterChain = context.getBean(securityBeanId, Filter.class); } if (this.springSecurityFilterChain == null) { throw new IllegalStateException( "springSecurityFilterChain cannot be null. Ensure a Bean with the name " + securityBeanId + " implementing Filter is present or inject the Filter to be used."); } builder.addFilters(this.springSecurityFilterChain); context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, this.springSecurityFilterChain); return testSecurityContext(); } }
@Override public RequestPostProcessor beforeMockMvcCreated( ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) { String securityBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN; if (this.springSecurityFilterChain == null && context.containsBean(securityBeanId)) { this.springSecurityFilterChain = context.getBean(securityBeanId, Filter.class); } if (this.springSecurityFilterChain == null) { throw new IllegalStateException( "springSecurityFilterChain cannot be null. Ensure a Bean with the name " + securityBeanId + " implementing Filter is present or inject the Filter to be used."); } builder.addFilters(this.springSecurityFilterChain); context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, this.springSecurityFilterChain); return testSecurityContext(); } }
@Override public RequestPostProcessor beforeMockMvcCreated( ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) { String stormpathFilterBeanId = "stormpathFilter"; String springSecurityFilterBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN; if (this.springSecurityFilter == null && context.containsBean(springSecurityFilterBeanId)) { this.springSecurityFilter = context.getBean(springSecurityFilterBeanId, Filter.class); } if (this.stormpathFilter == null && context.containsBean(stormpathFilterBeanId)) { this.stormpathFilter = context.getBean(stormpathFilterBeanId, Filter.class); } if (this.springSecurityFilter == null) { throw new IllegalStateException( "springSecurityFilter cannot be null. Ensure a Bean with the name " + springSecurityFilterBeanId + " implementing Filter is present or inject the Filter to be used."); } if (this.stormpathFilter == null) { throw new IllegalStateException( "stormpathFilter cannot be null. Ensure a Bean with the name " + stormpathFilterBeanId + " implementing Filter is present or inject the Filter to be used."); } builder.addFilters(this.springSecurityFilter); builder.addFilters(this.stormpathFilter); //Let's put Stormpath behind Spring Security context.getServletContext().setAttribute(StormpathFilter.class.getName(), this.stormpathFilter.getClass().getName()); context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, this.springSecurityFilter); return testSecurityContext(); }