Java Code Examples for org.springframework.boot.web.servlet.FilterRegistrationBean#setDispatcherTypes()

The following examples show how to use org.springframework.boot.web.servlet.FilterRegistrationBean#setDispatcherTypes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: supplierShop   File: FilterConfig.java    License: MIT License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
public FilterRegistrationBean xssFilterRegistration()
{
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new XssFilter());
    registration.addUrlPatterns(StringUtils.split(urlPatterns, ","));
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    Map<String, String> initParameters = new HashMap<String, String>();
    initParameters.put("excludes", excludes);
    initParameters.put("enabled", enabled);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 2
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean frb = new FilterRegistrationBean();
    frb.setName("sakai.request");
    frb.setServletNames(Arrays.asList("sakai.rubrics", "dispatcherServlet"));
    frb.setFilter(new RequestFilter());
    frb.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE);
    return frb;
}
 
Example 3
@Bean
public FilterRegistrationBean traceWebFilter(BeanFactory beanFactory,
		SleuthWebProperties webProperties) {
	FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
			new LazyTracingFilter(beanFactory));
	filterRegistrationBean.setDispatcherTypes(DispatcherType.ASYNC,
			DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE,
			DispatcherType.REQUEST);
	filterRegistrationBean.setOrder(webProperties.getFilterOrder());
	return filterRegistrationBean;
}
 
Example 4
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean frb = new FilterRegistrationBean();
    frb.setName("sakai.request");
    frb.setServletNames(Arrays.asList("sakai.rubrics", "dispatcherServlet"));
    frb.setFilter(new RequestFilter());
    frb.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE);
    return frb;
}
 
Example 5
@Bean
@ConditionalOnMissingBean(name = FILTER_NAME)
public FilterRegistrationBean flowFilter(final Flow flow) {
    final Filter filter = new FlowFilter(flow);
    @SuppressWarnings("unchecked") // as of Spring Boot 2.x
    final FilterRegistrationBean registration = new FilterRegistrationBean(filter);
    registration.setName(FILTER_NAME);
    registration.setDispatcherTypes(REQUEST);
    // see https://github.com/opentracing-contrib/java-spring-web/blob/master/opentracing-spring-web-starter/src/main/java/io/opentracing/contrib/spring/web/starter/WebTracingProperties.java
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
    return registration;
}
 
Example 6
Source Project: app-engine   File: FilterConfigFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean requestLogChain() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    Filter headerFilter = new RequestLogFilter();
    registration.setFilter(headerFilter);
    registration.setOrder(Integer.MAX_VALUE);
    //拦截错误转发
    registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
    return registration;
}
 
Example 7
Source Project: v-mock   File: FilterConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean tagFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new TagFilter());
    registration.addUrlPatterns(StrUtil.split(URL_PATTERNS, ","));
    registration.setName("tagFilter");
    registration.setOrder(Integer.MAX_VALUE);
    Map<String, String> initParameters = CollUtil.newHashMap();
    initParameters.put("excludes", EXCLUDES);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 8
Source Project: EasyEE   File: ShiroConfiguration.java    License: MIT License 5 votes vote down vote up
/**
 * Shiro Core FilterRegistrationBean: Shiro DelegatingFilterProxy
 * 
 * @return
 */
@Bean 
public FilterRegistrationBean shiroFilterRegistrationBean() {
	FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
	DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy("shiroFilter");
	delegatingFilterProxy.setTargetFilterLifecycle(true);
	filterRegistration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE,
			DispatcherType.ERROR);
	filterRegistration.setFilter(delegatingFilterProxy);
	List<String> urlPatterns = new ArrayList<String>();
	urlPatterns.add("/*");
	filterRegistration.setUrlPatterns(urlPatterns);
	return filterRegistration;
}
 
Example 9
Source Project: DimpleBlog   File: FilterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Bean
public FilterRegistrationBean xssFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new XssFilter());
    registration.addUrlPatterns(StringUtils.split(urlPatterns, ","));
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    Map<String, String> initParameters = new HashMap<>();
    initParameters.put("excludes", excludes);
    initParameters.put("enabled", enabled);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 10
Source Project: java-tutorial   File: MarvelApplication.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean parmsFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new ParamsFilter());
    registration.addUrlPatterns("/*");
    registration.setName("paramsFilter");
    registration.setOrder(Integer.MAX_VALUE - 1);
    return registration;
}
 
Example 11
Source Project: spring-boot-seed   File: Log4jConfiguration.java    License: MIT License 5 votes vote down vote up
/**
 * Log4j2 过滤器
 *
 * @return filter
 */
@Bean
public FilterRegistrationBean log4jServletFilter() {
    FilterRegistrationBean<Log4jServletFilter> filterRegistrationBean = new FilterRegistrationBean<>(new Log4jServletFilter());
    filterRegistrationBean.addUrlPatterns("/*");
    filterRegistrationBean.setDispatcherTypes(REQUEST, FORWARD, INCLUDE, ERROR, ASYNC);
    return filterRegistrationBean;
}
 
Example 12
Source Project: RuoYi   File: FilterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes" , "unchecked"})
@Bean
public FilterRegistrationBean xssFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new XssFilter());
    registration.addUrlPatterns(StrUtil.split(urlPatterns, ","));
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    Map<String, String> initParameters = new HashMap<>();
    initParameters.put("excludes" , excludes);
    initParameters.put("enabled" , enabled);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 13
@Bean
public FilterRegistrationBean openEntityManagerInViewFilter() {
    FilterRegistrationBean<OpenEntityManagerInViewFilter> filterRegistrationBean
            = new FilterRegistrationBean<>(new OpenEntityManagerInViewFilter());
    filterRegistrationBean.addUrlPatterns("/*");
    filterRegistrationBean.setName("openEntityManagerInViewFilter");
    filterRegistrationBean.setOrder(-200); // 必须在安全过滤器(-100)之前执行
    filterRegistrationBean.setDispatcherTypes(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD));

    return filterRegistrationBean;
}
 
Example 14
Source Project: logbook   File: AsyncDispatchTest.java    License: MIT License 5 votes vote down vote up
@Bean
@SuppressWarnings({"rawtypes", "unchecked"}) // as of Spring Boot 2.x
public FilterRegistrationBean logbookFilter(final Logbook logbook) {
    final FilterRegistrationBean registration =
            new FilterRegistrationBean(new LogbookFilter(logbook));
    registration.setDispatcherTypes(REQUEST, ASYNC);
    return registration;
}
 
Example 15
/**
 * 防XSS注入
 */
@Bean
public FilterRegistrationBean<XssFilter> xssFilterRegistration() {
	FilterRegistrationBean<XssFilter> registration = new FilterRegistrationBean<>();
	registration.setDispatcherTypes(DispatcherType.REQUEST);
	registration.setFilter(new XssFilter(xssProperties, xssUrlProperties));
	registration.addUrlPatterns("/*");
	registration.setName("xssFilter");
	registration.setOrder(Ordered.LOWEST_PRECEDENCE);
	return registration;
}
 
Example 16
Source Project: mysiteforme   File: ShiroConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean delegatingFilterProxy(){
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    DelegatingFilterProxy proxy = new DelegatingFilterProxy();
    proxy.setTargetFilterLifecycle(true);
    proxy.setTargetBeanName("shiroFilter");
    filterRegistrationBean.setFilter(proxy);
    filterRegistrationBean.setDispatcherTypes(DispatcherType.ERROR,DispatcherType.REQUEST,DispatcherType.FORWARD,DispatcherType.INCLUDE);
    return filterRegistrationBean;
}
 
Example 17
Source Project: sdb-mall   File: FilterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean xssFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new XssFilter());
    registration.addUrlPatterns("/*");
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    return registration;
}
 
Example 18
@Bean
public FilterRegistrationBean xssFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setDispatcherTypes(DispatcherType.REQUEST);
    registration.setFilter(new XssFilter());
    registration.addUrlPatterns("/*");
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    return registration;
}
 
Example 19
Source Project: eventapis   File: EventApisFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
    public FilterRegistrationBean createOpContextFilter(@Autowired OperationContext operationContext) {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new OpContextFilter(operationContext));
//        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
        registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
        return registration;
    }
 
Example 20
Source Project: EasyEE   File: ShiroConfiguration.java    License: MIT License 5 votes vote down vote up
/**
 * Shiro Core FilterRegistrationBean: Shiro DelegatingFilterProxy
 * 
 * @return
 */
@Bean 
public FilterRegistrationBean shiroFilterRegistrationBean() {
	FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
	DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy("shiroFilter");
	delegatingFilterProxy.setTargetFilterLifecycle(true);
	filterRegistration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE,
			DispatcherType.ERROR);
	filterRegistration.setFilter(delegatingFilterProxy);
	List<String> urlPatterns = new ArrayList<String>();
	urlPatterns.add("/*");
	filterRegistration.setUrlPatterns(urlPatterns);
	return filterRegistration;
}