下面列出了org.springframework.boot.test.context.FilteredClassLoader#org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void withMissingGlobalAuthenticationConfigurerAdapter() {
contextRunner
.withConfiguration(IDM_CONFIGURATION)
.withClassLoader(new FilteredClassLoader(GlobalAuthenticationConfigurerAdapter.class))
.run(context -> assertThat(context)
.hasSingleBean(IdmIdentityService.class)
.doesNotHaveBean(FlowableSecurityAutoConfiguration.class));
}
protected ServletContextHandler configureAPI(String apiContextPath, String applicationName, Class<? extends GlobalAuthenticationConfigurerAdapter> securityConfigurationClass) {
final ServletContextHandler childContext = new ServletContextHandler(server, apiContextPath, ServletContextHandler.SESSIONS);
final ServletHolder servletHolder = new ServletHolder(ServletContainer.class);
servletHolder.setInitParameter("javax.ws.rs.Application", applicationName);
servletHolder.setInitOrder(0);
childContext.addServlet(servletHolder, "/*");
AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
webApplicationContext.register(securityConfigurationClass);
webApplicationContext.setEnvironment((ConfigurableEnvironment) applicationContext.getEnvironment());
webApplicationContext.setParent(applicationContext);
childContext.addEventListener(new ContextLoaderListener(webApplicationContext));
// Spring Security filter
childContext.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")),"/*", EnumSet.allOf(DispatcherType.class));
return childContext;
}