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() . 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
@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 2
@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 3
Source Project: piggymetrics   File: CatFilterConfigure.java    License: 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 4
/**
 * 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;
}
 
Example 5
/**
 * 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 6
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 7
@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 8
Source Project: piggymetrics   File: CatFilterConfigure.java    License: 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 9
/**
 * 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 10
Source Project: x7   File: TracingServletRegistrary.java    License: 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 11
@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 12
Source Project: springBoot-study   File: MyWebFilter.java    License: 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
@Bean
public FilterRegistrationBean characterEncodingFilterRegistration() {
    FilterRegistrationBean registrationBean =
            new FilterRegistrationBean(characterEncodingFilter());
    registrationBean.setName("CharacterEncodingFilter");
    registrationBean.addUrlPatterns("/*");
    registrationBean.setOrder(1);
    return registrationBean;
}
 
Example 14
Source Project: logbook   File: LogbookAutoConfiguration.java    License: 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 15
Source Project: layui-admin   File: LayuiAdminStartUp.java    License: 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 16
Source Project: Sentinel   File: FilterContextConfig.java    License: 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 17
/**
 * 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 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: chronus   File: WebConfiguration.java    License: 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 20
Source Project: springboot-admin   File: WebConfig.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("/sys/"));
    registration.addUrlPatterns("/*");
    registration.setName("xssFilter");
    registration.setOrder(Integer.MAX_VALUE);
    return registration;
}