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

The following examples show how to use org.springframework.boot.web.servlet.FilterRegistrationBean#setInitParameters() . 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: RuoYi-Vue   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(FilterRegistrationBean.HIGHEST_PRECEDENCE);
    Map<String, String> initParameters = new HashMap<String, String>();
    initParameters.put("excludes", excludes);
    initParameters.put("enabled", enabled);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 2
Source Project: ruoyiplus   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 3
Source Project: apollo   File: AuthConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public FilterRegistrationBean assertionHolder() {
  FilterRegistrationBean assertionHolderFilter = new FilterRegistrationBean();

  Map<String, String> filterInitParam = Maps.newHashMap();
  filterInitParam.put("/openapi.*", "exclude");

  assertionHolderFilter.setInitParameters(filterInitParam);

  assertionHolderFilter.setFilter(
      filter("com.ctrip.framework.apollo.sso.filter.ApolloAssertionThreadLocalFilter"));
  assertionHolderFilter.addUrlPatterns("/*");
  assertionHolderFilter.setOrder(4);

  return assertionHolderFilter;
}
 
Example 4
/**
 * xss过滤拦截器
 */
@Bean
public FilterRegistrationBean xssFilterRegistrationBean() {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(new XssFilter());
    filterRegistrationBean.setOrder(Integer.MAX_VALUE-1);
    filterRegistrationBean.setEnabled(true);
    filterRegistrationBean.addUrlPatterns("/*");
    Map<String, String> initParameters = new HashMap();
    //excludes用于配置不需要参数过滤的请求url
    initParameters.put("excludes", "/favicon.ico,/img/*,/js/*,/css/*");
    //isIncludeRichText主要用于设置富文本内容是否需要过滤
    initParameters.put("isIncludeRichText", "true");
    filterRegistrationBean.setInitParameters(initParameters);
    return filterRegistrationBean;
}
 
Example 5
Source Project: apollo   File: AuthConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 6
Source Project: Doctor   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());
    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.js,*.css,/druid/*");
    bean.setInitParameters(initParams);
    bean.setUrlPatterns(Arrays.asList("/*"));
    return bean;
}
 
Example 7
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.js,*.css,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 8
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
   public FilterRegistrationBean containerBasedAuthenticationFilter(){

       FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
       filterRegistration.setFilter(new ContainerBasedAuthenticationFilter());
       filterRegistration.setInitParameters(Collections.singletonMap("authentication-provider", "org.camunda.bpm.extension.keycloak.showcase.sso.KeycloakAuthenticationProvider"));
       filterRegistration.setOrder(101); // make sure the filter is registered after the Spring Security Filter Chain
       filterRegistration.addUrlPatterns("/app/*");
       return filterRegistration;
   }
 
Example 9
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 10
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 11
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 12
Source Project: hellokoding-courses   File: WebApplication.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean jwtFilter() {
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(new JwtFilter());
    registrationBean.setInitParameters(Collections.singletonMap("services.auth", authService));
    registrationBean.addUrlPatterns("/protected-resource", "/logout");

    return registrationBean;
}
 
Example 13
Source Project: hellokoding-courses   File: WebApplication.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean jwtFilter() {
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(new JwtFilter());
    registrationBean.setInitParameters(Collections.singletonMap("services.auth", authService));
    registrationBean.addUrlPatterns("/protected-resource");

    return registrationBean;
}
 
Example 14
private void initFilter(final FilterRegistrationBean filterRegistrationBean,
                        final Filter targetFilter,
                        int filterOrder,
                        final Map<String, String> initParams,
                        List<String> urlPatterns) {

    filterRegistrationBean.setFilter(targetFilter);
    filterRegistrationBean.setOrder(filterOrder);
    filterRegistrationBean.setInitParameters(initParams);
    if (urlPatterns.size() > 0) {
        filterRegistrationBean.setUrlPatterns(urlPatterns);
    }
}
 
Example 15
Source Project: charging_pile_cloud   File: FilterConfigs.java    License: MIT License 5 votes vote down vote up
/**
 * xss过滤拦截器
 */
@Bean
public FilterRegistrationBean xssFilterRegistrationBean() {
	FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
	filterRegistrationBean.setFilter(new XssFilter());
	filterRegistrationBean.setOrder(1);
	filterRegistrationBean.setEnabled(true);
	filterRegistrationBean.addUrlPatterns("/*");
	Map<String, String> initParameters = Maps.newHashMap();
	initParameters.put("excludes", noFilter);
	initParameters.put("isIncludeRichText", "true");
	filterRegistrationBean.setInitParameters(initParameters);
	return filterRegistrationBean;
}
 
Example 16
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.js,*.css,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 17
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 18
Source Project: blog   File: DruidConfig.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
	FilterRegistrationBean<WebStatFilter> bean = new FilterRegistrationBean<>(new WebStatFilter());
	HashMap<String, String> initParams = new HashMap<>();
	initParams.put("exclusions", "/css,/druid/*");
	bean.setInitParameters(initParams);
	bean.setUrlPatterns(Arrays.asList("/*"));
	return bean;
}
 
Example 19
@Bean
public FilterRegistrationBean<ContainerBasedAuthenticationFilter> containerBasedAuthFilter() {
    FilterRegistrationBean<ContainerBasedAuthenticationFilter> filterRegistration =
        new FilterRegistrationBean<>();
    filterRegistration.setFilter(new ContainerBasedAuthenticationFilter());
    filterRegistration.setInitParameters(Collections.singletonMap("authentication-provider",
        "org.camunda.bpm.engine.rest.security.auth.impl.ContainerBasedAuthenticationProvider"));
    filterRegistration.addUrlPatterns(ChangedAppPathContainerBasedAuthIT.MY_APP_PATH + "/*");
    return filterRegistration;
}
 
Example 20
/**
 * XssFilter Bean
 */
@Bean
@SuppressWarnings({ "unchecked", "rawtypes" })
public FilterRegistrationBean xssFilterRegistrationBean() {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(new XssFilter());
    filterRegistrationBean.setOrder(1);
    filterRegistrationBean.setEnabled(true);
    filterRegistrationBean.addUrlPatterns("/*");
    Map<String, String> initParameters = new HashMap<>();
    initParameters.put("excludes", "/favicon.ico,/img/*,/js/*,/css/*");
    initParameters.put("isIncludeRichText", "true");
    filterRegistrationBean.setInitParameters(initParameters);
    return filterRegistrationBean;
}