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

The following examples show how to use org.springframework.boot.web.servlet.FilterRegistrationBean#setName() . 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: FilterConfig.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 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 = Maps.newHashMap();
    initParameters.put("excludes", excludes);
    initParameters.put("enabled", enabled);
    registration.setInitParameters(initParameters);
    return registration;
}
 
Example 2
Source File: XxlSsoConfig.java    From xxl-sso with GNU General Public License v3.0 6 votes vote down vote up
@Bean
public FilterRegistrationBean xxlSsoFilterRegistration() {

    // xxl-sso, redis init
    JedisUtil.init(xxlSsoRedisAddress);

    // xxl-sso, filter init
    FilterRegistrationBean registration = new FilterRegistrationBean();

    registration.setName("XxlSsoWebFilter");
    registration.setOrder(1);
    registration.addUrlPatterns("/*");
    registration.setFilter(new XxlSsoWebFilter());
    registration.addInitParameter(Conf.SSO_SERVER, xxlSsoServer);
    registration.addInitParameter(Conf.SSO_LOGOUT_PATH, xxlSsoLogoutPath);
    registration.addInitParameter(Conf.SSO_EXCLUDED_PATHS, xxlSsoExcludedPaths);

    return registration;
}
 
Example 3
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean characterEncodingFilterRegistration() {
    FilterRegistrationBean registrationBean =
            new FilterRegistrationBean(characterEncodingFilter());
    registrationBean.setName("CharacterEncodingFilter");
    registrationBean.addUrlPatterns("/*");
    registrationBean.setOrder(1);
    return registrationBean;
}
 
Example 4
Source File: WebConfig.java    From springboot-admin with 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("/sys/"));
    registration.addUrlPatterns("/*");
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    return registration;
}
 
Example 5
Source File: WebConfiguration.java    From chronus with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean serviceContextFilter(){
    FilterRegistrationBean<ServiceContextFilter> filterBean = new FilterRegistrationBean();
    filterBean.setFilter(new ServiceContextFilter());
    filterBean.setName("ServiceContextFilter");
    filterBean.addUrlPatterns("/api/*");
    return filterBean;
}
 
Example 6
Source File: FilterConfig.java    From renren-fast with GNU General Public License v3.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 7
Source File: WebConfig.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
/**
 * Add {@link CommonFilter} to the server, this is the simplest way to use Sentinel
 * for Web application.
 */
@Bean
public FilterRegistrationBean sentinelFilterRegistration() {
    FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
    registration.setFilter(new CommonFilter());
    registration.addUrlPatterns("/*");
    registration.setName("sentinelFilter");
    registration.setOrder(1);

    logger.info("Sentinel servlet CommonFilter registered");

    return registration;
}
 
Example 8
Source File: FilterContextConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean sentinelFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new CommonFilter());
    registration.addUrlPatterns("/*");
    registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
    registration.setName("sentinelFilter");
    registration.setOrder(1);

    return registration;
}
 
Example 9
Source File: LayuiAdminStartUp.java    From layui-admin with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean shiroFilter(){
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
            new org.springframework.web.filter.DelegatingFilterProxy());
    filterRegistrationBean.addUrlPatterns("/*");
    filterRegistrationBean.setName("myShiroFilter");
    filterRegistrationBean.addInitParameter("targetFilterLifecycle","true");

    return filterRegistrationBean;
}
 
Example 10
Source File: LogbookAutoConfiguration.java    From logbook with MIT License 5 votes vote down vote up
private static FilterRegistrationBean newFilter(final Filter filter, final String filterName, final int order) {
    @SuppressWarnings("unchecked") // as of Spring Boot 2.x
    final FilterRegistrationBean registration = new FilterRegistrationBean(filter);
    registration.setName(filterName);
    registration.setDispatcherTypes(REQUEST, ASYNC);
    registration.setOrder(order);
    return registration;
}
 
Example 11
Source File: CatFilterConfigure.java    From piggymetrics with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean catFilter() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    CatServletFilter filter = new CatServletFilter();
    registration.setFilter(filter);
    registration.addUrlPatterns("/*");
    registration.setName("cat-filter");
    registration.setOrder(1);
    return registration;
}
 
Example 12
Source File: MyWebFilter.java    From springBoot-study with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean testFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new MyFilter());
    //过滤掉 /api 和hello 的所有请求
    registration.addUrlPatterns("/*");
    registration.addInitParameter("paramName", "paramValue");
    registration.setName("MyFilter");
    registration.setOrder(1);
    return registration;
}
 
Example 13
Source File: OpenTracingFlowIdAutoConfiguration.java    From opentracing-toolbox with MIT License 5 votes vote down vote up
@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 14
Source File: TracingServletRegistrary.java    From x7 with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean braveServletFilterRegistration(BraveServletFilter braveServletFilter) {

    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(braveServletFilter);
    registration.addUrlPatterns("/*");
    registration.setName(BraveServletFilter.class.getSimpleName());
    registration.setOrder(10);
    return registration;
}
 
Example 15
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Filter to protect the hawkBit server DDI download interface against
 * to many requests.
 * 
 * @param securityProperties
 *            for filter configuration
 *
 * @return the spring filter registration bean for registering a denial
 *         of service protection filter in the filter chain
 */
@Bean
@ConditionalOnProperty(prefix = "hawkbit.server.security.dos.filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosDDiDlFilter(final HawkbitSecurityProperties securityProperties) {

    final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(Arrays.asList(DDI_DL_ANT_MATCHER),
            securityProperties.getDos().getFilter(), securityProperties.getClients());
    filterRegBean.setOrder(DOS_FILTER_ORDER);
    filterRegBean.setName("dosDDiDlFilter");

    return filterRegBean;
}
 
Example 16
Source File: CatFilterConfigure.java    From piggymetrics with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean catFilter() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    CatServletFilter filter = new CatServletFilter();
    registration.setFilter(filter);
    registration.addUrlPatterns("/*");
    registration.setName("cat-filter");
    registration.setOrder(1);
    return registration;
}
 
Example 17
Source File: WebConfiguration.java    From springBoot-study with Apache License 2.0 5 votes vote down vote up
@Bean
    public FilterRegistrationBean testFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new MyFilter());
        //过滤掉 /getUser 和/hello 的请求
        registration.addUrlPatterns("/getUser","/hello");
        //过滤掉所有请求
//      registration.addUrlPatterns("/*");
        registration.addInitParameter("paramName", "paramValue");
        registration.setName("MyFilter");
        registration.setOrder(1);
        return registration;
    }
 
Example 18
Source File: MarvelApplication.java    From java-tutorial with 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 19
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Filter to protect the hawkBit server DDI interface against to many
 * requests.
 * 
 * @param securityProperties
 *            for filter configuration
 *
 * @return the spring filter registration bean for registering a denial
 *         of service protection filter in the filter chain
 */
@Bean
@ConditionalOnProperty(prefix = "hawkbit.server.security.dos.filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosDDiFilter(final HawkbitSecurityProperties securityProperties) {

    final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(Arrays.asList(DDI_ANT_MATCHERS),
            securityProperties.getDos().getFilter(), securityProperties.getClients());
    filterRegBean.setOrder(DOS_FILTER_ORDER);
    filterRegBean.setName("dosDDiFilter");

    return filterRegBean;
}
 
Example 20
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Filter to protect the hawkBit server system management interface against
 * to many requests.
 * 
 * @param securityProperties
 *            for filter configuration
 *
 * @return the spring filter registration bean for registering a denial of
 *         service protection filter in the filter chain
 */
@Bean
@ConditionalOnProperty(prefix = "hawkbit.server.security.dos.filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosSystemFilter(final HawkbitSecurityProperties securityProperties) {

    final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(Collections.emptyList(),
            securityProperties.getDos().getFilter(), securityProperties.getClients());
    filterRegBean.setUrlPatterns(Arrays.asList("/system/*"));
    filterRegBean.setOrder(DOS_FILTER_ORDER);
    filterRegBean.setName("dosSystemFilter");

    return filterRegBean;
}