Java Code Examples for org.springframework.boot.web.servlet.FilterRegistrationBean#setOrder()
The following examples show how to use
org.springframework.boot.web.servlet.FilterRegistrationBean#setOrder() .
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 supplierShop with MIT License | 6 votes |
@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
Source File: OAuth2RestOperationsConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 6 votes |
@Bean public FilterRegistrationBean<OAuth2ClientContextFilter> oauth2ClientFilterRegistration( OAuth2ClientContextFilter filter, SecurityProperties security) { FilterRegistrationBean<OAuth2ClientContextFilter> registration = new FilterRegistrationBean<>(); registration.setFilter(filter); registration.setOrder(security.getFilter().getOrder() - 10); return registration; }
Example 3
Source File: CustomZuulConfig.java From api-gateway-old with Apache License 2.0 | 6 votes |
/** * 解决跨域问题 * * @return 跨域声明 */ @Bean public FilterRegistrationBean corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.setAllowedOrigins(allowedOrigins); config.addAllowedHeader("*"); config.setMaxAge(18000L); config.addAllowedMethod("*"); //添加response暴露的header String[] responseHeader = {"date", "content-encoding", "server", "etag", "vary", "Cache-Control", "Last-Modified", "content-type", "transfer-encoding", "connection", "x-application-context"}; config.setExposedHeaders(Arrays.asList(responseHeader)); source.registerCorsConfiguration("/**", config); FilterRegistrationBean bean = new FilterRegistrationBean<>(new CorsFilter(source)); bean.setOrder(0); return bean; }
Example 4
Source File: OpenTracingSpringMvcAutoConfiguration.java From sofa-tracer with Apache License 2.0 | 6 votes |
@Bean public FilterRegistrationBean springMvcDelegatingFilterProxy() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); SpringMvcSofaTracerFilter filter = new SpringMvcSofaTracerFilter(); filterRegistrationBean.setFilter(filter); List<String> urlPatterns = openTracingSpringProperties.getUrlPatterns(); if (urlPatterns == null || urlPatterns.size() <= 0) { filterRegistrationBean.addUrlPatterns("/*"); } else { filterRegistrationBean.setUrlPatterns(urlPatterns); } filterRegistrationBean.setName(filter.getFilterName()); filterRegistrationBean.setAsyncSupported(true); filterRegistrationBean.setOrder(openTracingSpringProperties.getFilterOrder()); return filterRegistrationBean; }
Example 5
Source File: WebConfiguration.java From spring-boot-demo with MIT License | 5 votes |
@Bean public FilterRegistrationBean customFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); //注入过滤器 registration.setFilter(new CustomFilter()); //过滤器名称 registration.setName("CustomFilter"); //拦截规则 registration.addUrlPatterns("/*"); //过滤器顺序 registration.setOrder(1); return registration; }
Example 6
Source File: SecurityConfig.java From springboot-security-wechat with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean oauth2ClientFilterRegistration(OAuth2ClientContextFilter filter) { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(filter); registration.setOrder(-100); return registration; }
Example 7
Source File: SecurityManagedConfiguration.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
/** * 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 8
Source File: FaradayConfiguration.java From staffjoy with MIT License | 5 votes |
@Bean public FilterRegistrationBean<NakedDomainFilter> nakedDomainFilterRegistrationBean(EnvConfig envConfig) { FilterRegistrationBean<NakedDomainFilter> registrationBean = new FilterRegistrationBean<>(new NakedDomainFilter(envConfig)); registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 90); // before ReverseProxyFilter return registrationBean; }
Example 9
Source File: CorsConfig.java From ZTuoExchange_framework with MIT License | 5 votes |
@Bean public FilterRegistrationBean corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.addAllowedOrigin("*"); config.setAllowCredentials(true); config.addAllowedHeader("*"); config.addAllowedMethod("*"); source.registerCorsConfiguration("/**", config); FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source)); bean.setOrder(0); return bean; }
Example 10
Source File: MyFilterConfig.java From springboot-guide with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean<MyFilter2> setUpMyFilter2() { FilterRegistrationBean<MyFilter2> filterRegistrationBean = new FilterRegistrationBean<>(); filterRegistrationBean.setOrder(1); filterRegistrationBean.setFilter(myFilter2); filterRegistrationBean.setUrlPatterns(new ArrayList<>(Arrays.asList("/api/*"))); return filterRegistrationBean; }
Example 11
Source File: Application.java From airsonic with GNU General Public License v3.0 | 5 votes |
@Bean public FilterRegistrationBean restFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(restFilter()); registration.addUrlPatterns("/rest/*"); registration.setName("RESTFilter"); registration.setOrder(3); return registration; }
Example 12
Source File: LdapConfiguration.java From edison-microservice with Apache License 2.0 | 5 votes |
/** * Add an authentication filter that requires a certain LDAP role to access secured paths. * All routes starting with the value of the {@code edison.ldap.prefixes} property will be secured by LDAP. * If no property is set this will default to all routes starting with '/internal'. * * @param ldapProperties the properties used to configure LDAP * @return FilterRegistrationBean */ @Bean @ConditionalOnProperty(prefix = "edison.ldap", name = "required-role") public FilterRegistrationBean<LdapRoleAuthenticationFilter> ldapRoleAuthenticationFilter(final LdapProperties ldapProperties) { FilterRegistrationBean<LdapRoleAuthenticationFilter> filterRegistration = new FilterRegistrationBean<>(); filterRegistration.setFilter(new LdapRoleAuthenticationFilter(ldapProperties)); filterRegistration.setOrder(Ordered.LOWEST_PRECEDENCE); ldapProperties.getPrefixes().forEach(prefix -> filterRegistration.addUrlPatterns(String.format("%s/*", prefix))); return filterRegistration; }
Example 13
Source File: CorsConfig.java From x7 with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean corsFilterRegistration(CorsFilter corsFilter) { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(corsFilter); registration.addUrlPatterns("/*"); registration.setName(CorsFilter.class.getSimpleName()); registration.setOrder(1); return registration; }
Example 14
Source File: EurekaServerAutoConfiguration.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(name = "httpTraceFilter") public FilterRegistrationBean<?> traceFilterRegistration( @Qualifier("httpTraceFilter") Filter filter) { FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<Filter>(); bean.setFilter(filter); bean.setOrder(Ordered.LOWEST_PRECEDENCE - 10); return bean; }
Example 15
Source File: Application.java From ReCiter with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean squigglyRequestFilter() { FilterRegistrationBean filter = new FilterRegistrationBean(); filter.setFilter(new SquigglyRequestFilter()); filter.setOrder(1); return filter; }
Example 16
Source File: FilterConfig.java From Sentinel with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean sentinelFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new CommonFilter()); registration.addUrlPatterns("/*"); registration.setName("sentinelFilter"); registration.setOrder(1); return registration; }
Example 17
Source File: FilterConfig.java From sdb-mall with Apache License 2.0 | 5 votes |
@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
Source File: CatFilterConfigure.java From cat_lab with MIT License | 5 votes |
@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 19
Source File: LdapConfiguration.java From edison-microservice with Apache License 2.0 | 5 votes |
/** * Add an authentication filter to the web application context if edison.ldap property is set to {@code enabled}'. * All routes starting with the value of the {@code edison.ldap.prefix} property will be secured by LDAP. If no * property is set this will default to all routes starting with '/internal'. * * @param ldapProperties the properties used to configure LDAP * @param ldapConnectionFactory the connection factory used to build the LdapAuthenticationFilter * @return FilterRegistrationBean */ @Bean public FilterRegistrationBean<LdapAuthenticationFilter> ldapAuthenticationFilter(final LdapProperties ldapProperties, final LdapConnectionFactory ldapConnectionFactory) { FilterRegistrationBean<LdapAuthenticationFilter> filterRegistration = new FilterRegistrationBean<>(); filterRegistration.setFilter(new LdapAuthenticationFilter(ldapProperties, ldapConnectionFactory)); filterRegistration.setOrder(Ordered.LOWEST_PRECEDENCE - 1); ldapProperties.getPrefixes().forEach(prefix -> filterRegistration.addUrlPatterns(String.format("%s/*", prefix))); return filterRegistration; }
Example 20
Source File: FilterConfig.java From RuoYi with Apache License 2.0 | 5 votes |
@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; }