当前位置: 首页>>代码示例>>Java>>正文


Java FilterRegistrationBean类代码示例

本文整理汇总了Java中org.springframework.boot.context.embedded.FilterRegistrationBean的典型用法代码示例。如果您正苦于以下问题:Java FilterRegistrationBean类的具体用法?Java FilterRegistrationBean怎么用?Java FilterRegistrationBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilterRegistrationBean类属于org.springframework.boot.context.embedded包,在下文中一共展示了FilterRegistrationBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterRegistrationBean

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();

    final CorsConfiguration corsConfiguration = new CorsConfiguration();
    corsConfiguration.setAllowCredentials(corsSupportProperties.isAllowCredentials());
    corsConfiguration.addAllowedOrigin(corsSupportProperties.getAllowOrigin());
    corsConfiguration.addAllowedHeader(corsSupportProperties.getAllowHeader());
    corsConfiguration.addAllowedMethod(corsSupportProperties.getAllowMethod());

    urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);

    CorsFilter corsFilter = new CorsFilter(urlBasedCorsConfigurationSource);
    FilterRegistrationBean registration = new FilterRegistrationBean(corsFilter);
    registration.addUrlPatterns("/*");
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return registration;
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:19,代码来源:CorsSupportConfiguration.java

示例2: wicketFilterRegistration

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean wicketFilterRegistration() {

	FilterRegistrationBean registration = new FilterRegistrationBean();
	WicketFilter wicketFilter = new WicketFilter();
	registration.setFilter(wicketFilter);
	registration.setName("wicketFilter");
	registration.addInitParameter(WicketFilter.APP_FACT_PARAM,
			SpringWebApplicationFactory.class.getName());
	registration.addInitParameter("configuration", configuration);
	registration.addInitParameter("testsMode", String.valueOf(testMode));
	registration.addInitParameter("mockMode",String.valueOf(mockMode));
	registration.addInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/portal/*");
	registration.addInitParameter(WicketFilter.IGNORE_PATHS_PARAM,"/favicon.ico");
	registration.addUrlPatterns("/portal/*");
	registration.setDispatcherTypes(DispatcherType.REQUEST,DispatcherType.FORWARD);
	registration.setMatchAfter(true);


	return registration;
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:22,代码来源:WicketWebInitializer.java

示例3: xssFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean xssFilter() {
	FilterRegistrationBean registration = new FilterRegistrationBean(new XssFilter());

	// Default values if not set
	if (properties.getUrlPattern() == null ||  properties.getUrlPattern().isEmpty()){
		properties.setUrlPattern(DEFAULT_URL_PATTERN);
	}
	if (properties.getMatch() == null ||  properties.getMatch().isEmpty()){
		properties.setMatch(DEFAULT_MATCH);
	}
	if (properties.getExclude() == null ||  properties.getExclude().isEmpty()){
		properties.setExclude(DEFAULT_EXCLUDE);
	}
	if (properties.getWildcards() == null){
		properties.setWildcards(DEFAULT_WILCARDS);
	}
	registration.addUrlPatterns(properties.getUrlPattern());
	registration.setInitParameters(properties.getAsInitParameters());
	return registration;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:22,代码来源:XssFilterAutoConfiguration.java

示例4: authenticationFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean authenticationFilter() {
  FilterRegistrationBean casFilter = new FilterRegistrationBean();

  Map<String, String> filterInitParam = Maps.newHashMap();
  filterInitParam.put("redisClusterName", "casClientPrincipal");
  filterInitParam.put("serverName", portalConfig.portalServerName());
  filterInitParam.put("casServerLoginUrl", portalConfig.casServerLoginUrl());
  //we don't want to use session to store login information, since we will be deployed to a cluster, not a single instance
  filterInitParam.put("useSession", "false");
  filterInitParam.put("/openapi.*", "exclude");

  casFilter.setInitParameters(filterInitParam);
  casFilter.setFilter(filter("com.ctrip.framework.apollo.sso.filter.ApolloAuthenticationFilter"));
  casFilter.addUrlPatterns("/*");
  casFilter.setOrder(2);

  return casFilter;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:20,代码来源:AuthConfiguration.java

示例5: correlationIdFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean correlationIdFilter() {
    return new FilterRegistrationBean(new Filter() {

        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            chain.doFilter(request, response);
        }

        @Override
        public void destroy() {
        }
    });
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:19,代码来源:App.java

示例6: corsFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
/**
 * Enables CORS
 *
 * @return
 */
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
开发者ID:jiaweizhang,项目名称:hackduke-backend-workshop,代码行数:25,代码来源:Application.java

示例7: corsFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
/**
 * Enables CORS
 *
 * @return
 */
@Bean
public FilterRegistrationBean corsFilter() {
	UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
	CorsConfiguration config = new CorsConfiguration();
	config.setAllowCredentials(true);
	config.addAllowedOrigin("*");
	config.addAllowedHeader("*");
	config.addAllowedMethod("OPTIONS");
	config.addAllowedMethod("HEAD");
	config.addAllowedMethod("GET");
	config.addAllowedMethod("PUT");
	config.addAllowedMethod("POST");
	config.addAllowedMethod("DELETE");
	config.addAllowedMethod("PATCH");
	source.registerCorsConfiguration("/**", config);
	final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
	bean.setOrder(0);
	return bean;
}
 
开发者ID:jiaweizhang,项目名称:assimulator,代码行数:25,代码来源:Application.java

示例8: corsFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
/**
 * 
 * This allows access to the REST interface from client web code served up by a
 * different URL than this one, i.e. cross-site scripting.
 * 
 * http://stackoverflow.com/questions/31724994/spring-data-rest-and-cors
 * http://stackoverflow.com/a/31748398/122441 until https://jira.spring.io/browse/DATAREST-573
 * @return
 */ 
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    // return new CorsFilter(source);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:30,代码来源:RestConfiguration.java

示例9: doHandle

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Override
public void doHandle(Map<String, Object> attributes, BeanDefinition beanDefinition,
		BeanDefinitionRegistry registry) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder
			.rootBeanDefinition(FilterRegistrationBean.class);
	builder.addPropertyValue("asyncSupported", attributes.get("asyncSupported"));
	builder.addPropertyValue("dispatcherTypes", extractDispatcherTypes(attributes));
	builder.addPropertyValue("filter", beanDefinition);
	builder.addPropertyValue("initParameters", extractInitParameters(attributes));
	String name = determineName(attributes, beanDefinition);
	builder.addPropertyValue("name", name);
	builder.addPropertyValue("servletNames", attributes.get("servletNames"));
	builder.addPropertyValue("urlPatterns",
			extractUrlPatterns("urlPatterns", attributes));
	registry.registerBeanDefinition(name, builder.getBeanDefinition());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:WebFilterHandler.java

示例10: rewriteFilterConfig

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean rewriteFilterConfig() {
    FilterRegistrationBean reg = new FilterRegistrationBean();
    reg.setName(REWRITE_FILTER_NAME);
    reg.setFilter(new UrlRewriteFilter());
    reg.addInitParameter("confPath", REWRITE_FILTER_CONF_PATH);
    reg.addInitParameter("confReloadCheckInterval", "-1");
    reg.addInitParameter("statusPath", "/redirect");
    reg.addInitParameter("statusEnabledOnHosts", "*");
    reg.addInitParameter("logLevel", "WARN");
    return reg;
}
 
开发者ID:hosken5,项目名称:spring-boot-freemarker-showcase,代码行数:13,代码来源:SiteConfig.java

示例11: mongoFilterBean

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean mongoFilterBean() {
  FilterRegistrationBean registrationBean = new FilterRegistrationBean();
  registrationBean.setFilter(mongoFilter);
  List<String> urls = new ArrayList<String>();
  
  urls.add("/");
  urls.add("/user");
  urls.add("/login");
  urls.add("/history/*");
  urls.add("/features/*");
  urls.add("/admin/*");
  urls.add("/pipelines/*");
  urls.add("/api/output/*");
  
  registrationBean.setUrlPatterns(urls);
  return registrationBean;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:LearningAnalyticsProcessor,代码行数:19,代码来源:MongoMultiTenantConfiguration.java

示例12: threadLocalFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean threadLocalFilter() {
    Filter filter = new MDCServletFilter();
    FilterRegistrationBean registration = new FilterRegistrationBean(filter);
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    registration.setName(MDCServletFilter.class.getSimpleName());
    return registration;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:9,代码来源:WebAutoConfiguration.java

示例13: corsFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter()
{
	FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
	filterRegistrationBean.setFilter(new CORSFilter());
	filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST);
	filterRegistrationBean.setUrlPatterns(Arrays.asList("/*"));
	filterRegistrationBean.setOrder(Integer.MIN_VALUE + 1000);
	return filterRegistrationBean;
}
 
开发者ID:tmply,项目名称:tmply,代码行数:11,代码来源:WebMvcConfig.java

示例14: httpMethodFilterRegistration

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean httpMethodFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(httpMethodFilter());
    registration.addUrlPatterns("/*");
    registration.setName("httpMethodFilter");
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
    return registration;
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:10,代码来源:OpenApiWebMvcConfigurer.java

示例15: openApiAuthenticationFilter

import org.springframework.boot.context.embedded.FilterRegistrationBean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean openApiAuthenticationFilter(ConsumerAuthUtil consumerAuthUtil,
                                                          ConsumerAuditUtil consumerAuditUtil) {
  FilterRegistrationBean openApiFilter = new FilterRegistrationBean();

  openApiFilter.setFilter(new ConsumerAuthenticationFilter(consumerAuthUtil, consumerAuditUtil));
  openApiFilter.addUrlPatterns("/openapi/*");

  return openApiFilter;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:11,代码来源:AuthFilterConfiguration.java


注:本文中的org.springframework.boot.context.embedded.FilterRegistrationBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。