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() . 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 File: AuthConfiguration.java    From apollo with 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 2
Source File: XssFilterConfigurer.java    From mySpringBoot with Apache License 2.0 6 votes vote down vote up
/**
 * 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 3
Source File: FilterConfig.java    From RuoYi-Vue with 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 4
Source File: FilterConfig.java    From ruoyiplus with 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 5
Source File: AuthConfiguration.java    From apollo with 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 6
Source File: CasClientConfiguration.java    From cas-client-autoconfig-support with Apache License 2.0 5 votes vote down vote up
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 7
Source File: FebsSecurityConfig.java    From FEBS-Security with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: ContainerBasedAuthFilterRegistration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: DruidConfig.java    From blog with 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 10
Source File: FilterConfig.java    From DimpleBlog with 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 11
Source File: DruidConfig.java    From codeway_service with GNU General Public License v3.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 12
Source File: FilterConfigs.java    From charging_pile_cloud with 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 13
Source File: DruidConfig.java    From Doctor with 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 14
Source File: WebApplication.java    From hellokoding-courses with 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 15
Source File: WebApplication.java    From hellokoding-courses with 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 16
Source File: DruidConfig.java    From mogu_blog_v2 with 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 17
Source File: DruidConfig.java    From mogu_blog_v2 with 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 18
Source File: DruidConfig.java    From mogu_blog_v2 with 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 19
Source File: WebAppSecurityConfig.java    From camunda-bpm-identity-keycloak with Apache License 2.0 5 votes vote down vote up
@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 20
Source File: DruidConfig.java    From codeway_service with GNU General Public License v3.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;
}