當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterChainProxy類代碼示例

本文整理匯總了Java中org.springframework.security.web.FilterChainProxy的典型用法代碼示例。如果您正苦於以下問題:Java FilterChainProxy類的具體用法?Java FilterChainProxy怎麽用?Java FilterChainProxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FilterChainProxy類屬於org.springframework.security.web包,在下文中一共展示了FilterChainProxy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
            samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
            samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
            metadataDisplayFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
            samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
            samlWebSSOHoKProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
            samlLogoutProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
            samlIDPDiscovery()));
    return new FilterChainProxy(chains);
}
 
開發者ID:lhartikk,項目名稱:spring-tsers-auth,代碼行數:20,代碼來源:WebSecurityConfig.java

示例2: springSecurityFilterChain

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Bean(name = "springSecurityFilterChain")
public FilterChainProxy springSecurityFilterChain() throws ServletException, Exception {

    final List<SecurityFilterChain> listOfFilterChains = new ArrayList<SecurityFilterChain>();

    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/cors")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/dump")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/validatorUrl")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-resources")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/ui")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/security")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/v2/api-docs")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-ui.html")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/webjars/**")));
    // no filters
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/webjars/**")));// no filters
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/*"), securityContextPersistenceFilterWithASCFalse(),
            usernamePasswordAuthenticationFilter(), sessionManagementFilter(), exceptionTranslationFilter(), filterSecurityInterceptor()));

    final FilterChainProxy filterChainProxy = new FilterChainProxy(listOfFilterChains);

    return filterChainProxy;
}
 
開發者ID:tvajjala,項目名稱:interview-preparation,代碼行數:24,代碼來源:WebSecurityConfig.java

示例3: springSecurityFilterChain

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Bean(name = "springSecurityFilterChain")
public FilterChainProxy springSecurityFilterChain() throws ServletException, Exception {

    final List<SecurityFilterChain> listOfFilterChains = new ArrayList<SecurityFilterChain>();
    // listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/login"), new NoSecurityFilter()));

    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/validatorUrl")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-resources")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/ui")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/configuration/security")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/v2/api-docs")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/swagger-ui.html")));
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/webjars/**")));
    // no filters
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/webjars/**")));// no filters
    listOfFilterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/api/**"), securityContextPersistenceFilterWithASCFalse(),
            exceptionTranslationFilter(), filterSecurityInterceptor()));

    final FilterChainProxy filterChainProxy = new FilterChainProxy(listOfFilterChains);

    return filterChainProxy;
}
 
開發者ID:tvajjala,項目名稱:interview-preparation,代碼行數:23,代碼來源:WebSecurityConfig.java

示例4: testWebConfiguration

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Test
public void testWebConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(SecurityAutoConfiguration.class,
			WebMvcAutoConfiguration.class,
			ManagementWebSecurityAutoConfiguration.class,
			JacksonAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
			ManagementServerPropertiesAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
	this.context.refresh();
	assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull();
	FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
	// 1 for static resources, one for management endpoints and one for the rest
	assertThat(filterChainProxy.getFilterChains()).hasSize(3);
	assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
	assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
	assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
	assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:24,代碼來源:ManagementWebSecurityAutoConfigurationTests.java

示例5: testFilterOrdering

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Test
public void testFilterOrdering() {
	load();
	List<RegisteredFilter> registeredFilters = this.context
			.getBean(MockEmbeddedServletContainerFactory.class).getContainer()
			.getRegisteredFilters();
	List<Filter> filters = new ArrayList<Filter>(registeredFilters.size());
	for (RegisteredFilter registeredFilter : registeredFilters) {
		filters.add(registeredFilter.getFilter());
	}
	Iterator<Filter> iterator = filters.iterator();
	assertThat(iterator.next()).isInstanceOf(OrderedCharacterEncodingFilter.class);
	assertThat(iterator.next()).isInstanceOf(SessionRepositoryFilter.class);
	assertThat(iterator.next()).isInstanceOf(Filter.class);
	assertThat(iterator.next()).isInstanceOf(Filter.class);
	assertThat(iterator.next()).isInstanceOf(OrderedRequestContextFilter.class);
	assertThat(iterator.next()).isInstanceOf(FilterChainProxy.class);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:FilterOrderingIntegrationTests.java

示例6: defaultHeaderConfiguration

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Test
public void defaultHeaderConfiguration() throws Exception {
	this.context = SpringApplication.run(VanillaWebConfiguration.class,
			"--server.port=0");
	MockMvc mockMvc = MockMvcBuilders
			.webAppContextSetup((WebApplicationContext) this.context)
			.addFilters((FilterChainProxy) this.context
					.getBean("springSecurityFilterChain", Filter.class))
			.build();
	mockMvc.perform(MockMvcRequestBuilders.get("/"))
			.andExpect(MockMvcResultMatchers.header().string("X-Content-Type-Options",
					is(notNullValue())))
			.andExpect(MockMvcResultMatchers.header().string("X-XSS-Protection",
					is(notNullValue())))
			.andExpect(MockMvcResultMatchers.header().string("Cache-Control",
					is(notNullValue())))
			.andExpect(MockMvcResultMatchers.header().string("X-Frame-Options",
					is(notNullValue())));
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:20,代碼來源:SpringBootWebSecurityConfigurationTests.java

示例7: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
/**
 * SAML Filter.
 * @return SAMLFilter
 * @throws Exception Exception
 */
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
        samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
        samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
        samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
        samlWebSSOHoKProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
        samlLogoutProcessingFilter()));
     return new FilterChainProxy(chains);
}
 
開發者ID:takesection,項目名稱:spring-boot-saml2,代碼行數:21,代碼來源:WebSecurityConfig.java

示例8: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
private FilterChainProxy samlFilter(SAMLEntryPoint samlEntryPoint, SAMLContextProvider contextProvider) {
	List<SecurityFilterChain> chains = new ArrayList<>();
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
		samlEntryPoint));
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
		new MetadataDisplayFilter()));
	try {
		chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
			samlWebSSOProcessingFilter(samlAuthenticationProvider, contextProvider, samlProcessor)));
	} catch (Exception e) {
		e.printStackTrace();
	}
	SAMLDiscovery samlDiscovery = new SAMLDiscovery();
	samlDiscovery.setMetadata(cachingMetadataManager);
	samlDiscovery.setContextProvider(contextProvider);
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
		samlDiscovery));
	return new FilterChainProxy(chains);
}
 
開發者ID:spring-projects,項目名稱:spring-security-saml-dsl,代碼行數:20,代碼來源:SAMLConfigurer.java

示例9: testWebConfiguration

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Test
public void testWebConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(SecurityAutoConfiguration.class,
			WebMvcAutoConfiguration.class,
			ManagementWebSecurityAutoConfiguration.class,
			JacksonAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
			ManagementServerPropertiesAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
	this.context.refresh();
	assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
	FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
	// 4 for static resources, one for management endpoints and one for the rest
	assertThat(filterChainProxy.getFilterChains(), hasSize(6));
	assertThat(filterChainProxy.getFilters("/beans"), hasSize(greaterThan(0)));
	assertThat(filterChainProxy.getFilters("/beans/"), hasSize(greaterThan(0)));
	assertThat(filterChainProxy.getFilters("/beans.foo"), hasSize(greaterThan(0)));
	assertThat(filterChainProxy.getFilters("/beans/foo/bar"),
			hasSize(greaterThan(0)));
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:25,代碼來源:ManagementWebSecurityAutoConfigurationTests.java

示例10: updateSecurityChain

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
/**
 * Updates security chain with given {@link org.motechproject.security.domain.MotechURLSecurityRule}
 *
 * @param securityRules list that contains new security rules
 */
private void updateSecurityChain(List<MotechURLSecurityRule> securityRules) {
    LOGGER.debug("Updating security chain");

    // sort rules by priority descending
    TreeSet<MotechURLSecurityRule> sortedRules = new TreeSet<>(new SecurityRuleComparator());
    sortedRules.addAll(securityRules);

    List<SecurityFilterChain> newFilterChains = new ArrayList<>();

    for (MotechURLSecurityRule securityRule : sortedRules) {
        if (securityRule.isActive() && !securityRule.isDeleted()) {
            LOGGER.debug("Creating SecurityFilterChain for: {}", securityRule.getPattern());
            for (HTTPMethod method : securityRule.getMethodsRequired()) {
                newFilterChains.add(securityRuleBuilder.buildSecurityChain(securityRule, method));
            }
            LOGGER.debug("Created SecurityFilterChain for: {}", securityRule.getPattern());
        }
    }

    proxy = new FilterChainProxy(newFilterChains);
    LOGGER.debug("Updated security chain.");
}
 
開發者ID:motech,項目名稱:motech,代碼行數:28,代碼來源:MotechProxyManager.java

示例11: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
/**
 * Define the security filter chain in order to support SSO Auth by using SAML 2.0
 *
 * @return Filter chain proxy
 * @throws Exception
 */
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"), samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"), samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
                                              metadataDisplayFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
                                              samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
                                              samlWebSSOHoKProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
                                              samlLogoutProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"), samlIDPDiscovery()));
    return new FilterChainProxy(chains);
}
 
開發者ID:chrludwig,項目名稱:websec-saml2sp,代碼行數:23,代碼來源:SamlSpringSecurityConfig.java

示例12: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
/**
 * Define the security filter chain in order to support SSO Auth by using SAML 2.0
 *
 * @return Filter chain proxy
 * @throws Exception
 */
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
            new TargetStoringFilter(),
            samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
            new TargetStoringFilter(),
            samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
            metadataDisplayFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
            samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
            samlLogoutProcessingFilter()));
    return new FilterChainProxy(chains);
}
 
開發者ID:solita,項目名稱:kansalaisaloite,代碼行數:24,代碼來源:WebSecurityConfig.java

示例13: samlFilter

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
/**
* Define the security filter chain in order to support SSO Auth by using SAML 2.0
* 
* @return Filter chain proxy
* @throws Exception
*/
  @Bean
  public FilterChainProxy samlFilter() throws Exception {
      List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
              samlEntryPoint()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
              samlLogoutFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
              metadataDisplayFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
              samlWebSSOProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
              samlWebSSOHoKProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
              samlLogoutProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
              samlIDPDiscovery()));
      return new FilterChainProxy(chains);
  }
 
開發者ID:vdenotaris,項目名稱:spring-boot-security-saml-sample,代碼行數:26,代碼來源:WebSecurityConfig.java

示例14: postProcessAfterInitialization

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof FilterChainProxy) {

        FilterChainProxy chains = (FilterChainProxy) bean;

        for (SecurityFilterChain chain : chains.getFilterChains()) {
            for (Filter filter : chain.getFilters()) {
                if (filter instanceof OAuth2ClientAuthenticationProcessingFilter) {
                    OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationProcessingFilter =
                        (OAuth2ClientAuthenticationProcessingFilter) filter;
                    oAuth2ClientAuthenticationProcessingFilter
                        .setAuthenticationSuccessHandler(new OAuth2AuthenticationSuccessHandler());
                }
            }
        }
    }
    return bean;
}
 
開發者ID:jhipster,項目名稱:generator-jhipster,代碼行數:20,代碼來源:_OAuth2Configuration.java

示例15: printAllFilters

import org.springframework.security.web.FilterChainProxy; //導入依賴的package包/類
@SneakyThrows
private void printAllFilters(FilterChain chain) {
	ApplicationFilterChain filterChain = (ApplicationFilterChain) chain;

	// 讀取私有變量 filters
	ApplicationFilterConfig[] filterConfigs = (ApplicationFilterConfig[]) readField(filterChain, "filters");
	int filterSize = (int) readField(filterChain, "n");

	System.out.println("\n\nprintAllFilters(), size=" + filterSize);

	for (int i = 0; i < filterSize; i++) {
		System.out.println(filterConfigs[i].getFilterName() + ", " + filterConfigs[i].getFilterClass());

		Filter filter = (Filter) invokeMethod(filterConfigs[i], "getFilter");

		// spring 的 filter 代理類
		if (filter instanceof DelegatingFilterProxy) {
			DelegatingFilterProxy filterProxy = (DelegatingFilterProxy) filter;

			FilterChainProxy springFilter = (FilterChainProxy) readField(DelegatingFilterProxy.class, filterProxy,
					"delegate");

			System.out.println(springFilter.getFilterChains());
			// List<Filter> springAdditionalFilters = (List<Filter>) readField(
			// springFilter, "additionalFilters");
			//
			// for (Filter f : springAdditionalFilters) {
			// System.out.print("\t\t");
			// System.out.println(f.getClass());
			// }
		}
	}

	System.out.println("\n\n");
}
 
開發者ID:xwjie,項目名稱:ElementVueSpringbootCodeTemplate,代碼行數:36,代碼來源:UserFilter.java


注:本文中的org.springframework.security.web.FilterChainProxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。