Java Code Examples for org.springframework.boot.web.servlet.FilterRegistrationBean#addInitParameter()
The following examples show how to use
org.springframework.boot.web.servlet.FilterRegistrationBean#addInitParameter() .
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: WebConfig.java From Sentinel with Apache License 2.0 | 6 votes |
/** * 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); // If this is enabled, the entrance of all Web URL resources will be unified as a single context name. // In most scenarios that's enough, and it could reduce the memory footprint. registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "true"); logger.info("Sentinel servlet CommonFilter registered"); return registration; }
Example 2
Source File: CamundaBpmRunRestConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnProperty(name = "enabled", havingValue = "true", prefix = CamundaBpmRunAuthenticationProperties.PREFIX) public FilterRegistrationBean<Filter> processEngineAuthenticationFilter(JerseyApplicationPath applicationPath) { FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>(); registration.setName("camunda-auth"); registration.setFilter(new ProcessEngineAuthenticationFilter()); registration.setOrder(AUTH_FILTER_PRECEDENCE); String restApiPathPattern = applicationPath.getUrlMapping(); registration.addUrlPatterns(restApiPathPattern); // if nothing is set, use Http Basic authentication CamundaBpmRunAuthenticationProperties properties = camundaBpmRunProperties.getAuth(); if (properties.getAuthentication() == null || CamundaBpmRunAuthenticationProperties.DEFAULT_AUTH.equals(properties.getAuthentication())) { registration.addInitParameter("authentication-provider", "org.camunda.bpm.engine.rest.security.auth.impl.HttpBasicAuthenticationProvider"); } return registration; }
Example 3
Source File: DruidConfiguration.java From seata-samples with Apache License 2.0 | 5 votes |
/** * 注册一个:filterRegistrationBean * * @return filter registration bean */ @Bean public FilterRegistrationBean<WebStatFilter> druidStatFilter() { FilterRegistrationBean<WebStatFilter> filterRegistrationBean = new FilterRegistrationBean<WebStatFilter>( new WebStatFilter()); // 添加过滤规则. filterRegistrationBean.addUrlPatterns("/*"); // 添加不需要忽略的格式信息. filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return filterRegistrationBean; }
Example 4
Source File: AppConfiguration.java From SMSC with Apache License 2.0 | 5 votes |
/** * Define filter to force UTF-8 encoding. * * @return filter */ @Bean public FilterRegistrationBean characterEncodingFilterRegistrationBean() { FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setFilter(new org.springframework.web.filter.CharacterEncodingFilter()); registrationBean.addUrlPatterns("/*"); registrationBean.addInitParameter("encoding", "UTF-8"); registrationBean.addInitParameter("forceEncoding", "true"); registrationBean.setName("CharacterEncodingFilter"); return registrationBean; }
Example 5
Source File: DruidConfiguration.java From springBoot-study with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean druidStatFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean( new WebStatFilter()); // 添加过滤规则 filterRegistrationBean.addUrlPatterns("/*"); // 添加不需要忽略的格式信息 filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); System.out.println("druid初始化成功!"); return filterRegistrationBean; }
Example 6
Source File: FilterMethodConfig.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.addInitParameter(CommonFilter.HTTP_METHOD_SPECIFY, "true"); registration.setName("sentinelFilter"); registration.setOrder(1); return registration; }
Example 7
Source File: ShiroCasWebFilterConfiguration.java From shiro-cas-spring-boot-starter with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean<HttpServletRequestWrapperFilter> requestWrapperFilter() { FilterRegistrationBean<HttpServletRequestWrapperFilter> filterRegistration = new FilterRegistrationBean<HttpServletRequestWrapperFilter>(); filterRegistration.setFilter(new HttpServletRequestWrapperFilter()); filterRegistration.setEnabled(casProperties.isEnabled()); filterRegistration.addInitParameter(ConfigurationKeys.IGNORE_CASE.getName(), String.valueOf(casProperties.isIgnoreCase())); if(StringUtils.hasText(casProperties.getRoleAttribute())) { filterRegistration.addInitParameter(ConfigurationKeys.ROLE_ATTRIBUTE.getName(), casProperties.getRoleAttribute()); } filterRegistration.addUrlPatterns(casProperties.getRequestWrapperFilterUrlPatterns()); filterRegistration.setOrder(5); return filterRegistration; }
Example 8
Source File: ShiroCasWebFilterConfiguration.java From shiro-cas-spring-boot-starter with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean<AbstractCasFilter> authenticationFilter() { FilterRegistrationBean<AbstractCasFilter> filterRegistration = new FilterRegistrationBean<AbstractCasFilter>(); if (Protocol.SAML11.equals(casProperties.getProtocol())) { filterRegistration.setFilter(new Saml11AuthenticationFilter()); } else { filterRegistration.setFilter(new AuthenticationFilter()); } if(StringUtils.hasText(casProperties.getAuthenticationRedirectStrategyClass())) { filterRegistration.addInitParameter(ConfigurationKeys.AUTHENTICATION_REDIRECT_STRATEGY_CLASS.getName(), casProperties.getAuthenticationRedirectStrategyClass()); } filterRegistration.addInitParameter(ConfigurationKeys.CAS_SERVER_LOGIN_URL.getName(), casProperties.getCasServerLoginUrl()); filterRegistration.addInitParameter(ConfigurationKeys.ENCODE_SERVICE_URL.getName(), Boolean.toString(casProperties.isEncodeServiceUrl())); filterRegistration.addInitParameter(ConfigurationKeys.GATEWAY.getName(), Boolean.toString(casProperties.isGateway())); if(StringUtils.hasText(casProperties.getGatewayStorageClass())) { filterRegistration.addInitParameter(ConfigurationKeys.GATEWAY_STORAGE_CLASS.getName(), casProperties.getGatewayStorageClass()); } if(StringUtils.hasText(casProperties.getIgnorePattern())) { filterRegistration.addInitParameter(ConfigurationKeys.IGNORE_PATTERN.getName(), casProperties.getIgnorePattern()); } filterRegistration.addInitParameter(ConfigurationKeys.IGNORE_URL_PATTERN_TYPE.getName(), casProperties.getIgnoreUrlPatternType().toString()); //filterRegistration.addInitParameter(ConfigurationKeys.RENEW.getName(), Boolean.toString(properties.isRenew())); if(StringUtils.hasText(casProperties.getServerName())) { filterRegistration.addInitParameter(ConfigurationKeys.SERVER_NAME.getName(), casProperties.getServerName()); } else if(StringUtils.hasText(casProperties.getService())) { filterRegistration.addInitParameter(ConfigurationKeys.SERVICE.getName(), casProperties.getService()); } filterRegistration.addUrlPatterns(casProperties.getAuthenticationFilterUrlPatterns()); filterRegistration.setOrder(4); return filterRegistration; }
Example 9
Source File: ShiroAutoConfiguration.java From utils with Apache License 2.0 | 5 votes |
@Bean(name = "shiroFilter") @DependsOn("securityManager") @ConditionalOnMissingBean public FilterRegistrationBean filterRegistrationBean(SecurityManager securityManager) throws Exception { FilterRegistrationBean filterRegistration = new FilterRegistrationBean(); //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 filterRegistration.addInitParameter("targetFilterLifecycle", "true"); filterRegistration.setFilter((Filter) getShiroFilterFactoryBean(securityManager).getObject()); filterRegistration.setEnabled(true); filterRegistration.addUrlPatterns("/*"); return filterRegistration; }
Example 10
Source File: WebConfig.java From springboot-admin with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean shiroFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new DelegatingFilterProxy("shiroFilter")); //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 registration.addInitParameter("targetFilterLifecycle", "true"); registration.setEnabled(true); registration.setOrder(Integer.MAX_VALUE - 1); registration.addUrlPatterns("/*"); return registration; }
Example 11
Source File: WebConfig.java From WebStack-Guns with MIT License | 5 votes |
/** * druid监控 配置URI拦截策略 */ @Bean public FilterRegistrationBean druidStatFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); //添加过滤规则. filterRegistrationBean.addUrlPatterns("/*"); //添加不需要忽略的格式信息. filterRegistrationBean.addInitParameter( "exclusions", "/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*"); //用于session监控页面的用户名显示 需要登录后主动将username注入到session里 filterRegistrationBean.addInitParameter("principalSessionName", "username"); return filterRegistrationBean; }
Example 12
Source File: ShiroConfig.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
/** * 注册shiroFilter */ @Bean public FilterRegistrationBean filterRegistrationBean(){ FilterRegistrationBean filterRegistration = new FilterRegistrationBean(); filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter")); // 该值缺省为false,表示生命周期有SpringApplicationContext管理,设置为true则表示由ServletContainer管理 filterRegistration.addInitParameter("targetFilterLifecycle", "true"); filterRegistration.setEnabled(true); filterRegistration.addUrlPatterns("/*"); return filterRegistration; }
Example 13
Source File: DruidConfig.java From SpringBoot-Base-System with GNU Lesser General Public License v3.0 | 5 votes |
/** * 不拦截的 * * @time 2018年4月10日 下午5:00:08. * @version V1.0 * @return FilterRegistrationBean */ @Bean public FilterRegistrationBean statFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); filterRegistrationBean.addUrlPatterns("/*"); filterRegistrationBean.addInitParameter("exclusions", "*.my,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return filterRegistrationBean; }
Example 14
Source File: DruidConfiguration.java From LazyREST with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean statFilter() { //创建过滤器 FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); //设置过滤器过滤路径 filterRegistrationBean.addUrlPatterns("/*"); //忽略过滤的形式 filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return filterRegistrationBean; }
Example 15
Source File: DruidAutoConfig.java From springboot-seed with MIT License | 5 votes |
@Bean public FilterRegistrationBean druidStatFilter2() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); //添加过滤规则. filterRegistrationBean.addUrlPatterns("/*"); //添加不需要忽略的格式信息. filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return filterRegistrationBean; }
Example 16
Source File: ServletConfig.java From EasyReport with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean filterRegistrationBean() { final FilterRegistrationBean filterRegistration = new FilterRegistrationBean(); filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter")); filterRegistration.addInitParameter("targetFilterLifecycle", "true"); filterRegistration.setEnabled(true); filterRegistration.addUrlPatterns("/*"); return filterRegistration; }
Example 17
Source File: DruidConfiguration.java From spring-boot-seed with MIT License | 5 votes |
/** * 注入Druid的WebStatFilter * * @return filter */ @Bean public FilterRegistrationBean druidWebStatFilter() { FilterRegistrationBean<WebStatFilter> filterRegistrationBean = new FilterRegistrationBean<>(new WebStatFilter()); // 过滤规则 filterRegistrationBean.addUrlPatterns("/*"); // 过滤忽略格式 filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return filterRegistrationBean; }
Example 18
Source File: DruidConfiguration.java From springBoot-study with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean druidStatFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean( new WebStatFilter()); // 添加过滤规则 filterRegistrationBean.addUrlPatterns("/*"); // 添加不需要忽略的格式信息 filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); System.out.println("druid初始化成功!"); return filterRegistrationBean; }
Example 19
Source File: DruidMonitorConfig.java From spring-boot-cookbook with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean webStatFilter() { /* Web关联监控配置: WebStatFilter用于采集web-jdbc关联监控的数据。为StatViewServlet准备用来展示的数据*/ WebStatFilter filter = new WebStatFilter(); FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter); registrationBean.addUrlPatterns("/*"); // 经常需要排除一些不必要的url,比如*.js,/jslib等等。配置在init-param中。比如: registrationBean.addInitParameter(WebStatFilter.PARAM_NAME_EXCLUSIONS, "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); // druid 0.2.7版本开始支持profile,配置profileEnable能够监控单个url调用的sql列表。 registrationBean.addInitParameter(WebStatFilter.PARAM_NAME_PROFILE_ENABLE, Boolean.TRUE.toString()); return registrationBean; }
Example 20
Source File: WingtipsSpringBootConfiguration.java From wingtips with Apache License 2.0 | 4 votes |
/** * Create and return a {@link RequestTracingFilter}, which will auto-register itself with the Spring Boot app as * a servlet filter and enable Wingtips tracing for incoming requests. * * @return The {@link RequestTracingFilter} that should be used. */ @Bean @ConditionalOnWebApplication public FilterRegistrationBean wingtipsRequestTracingFilter() { if (wingtipsProperties.isWingtipsDisabled()) { // We can't return null or create a FilterRegistrationBean that has a null filter inside as it will result // in a NullPointerException. So instead we'll return a do-nothing servlet filter. return new FilterRegistrationBean(new DoNothingServletFilter()); } // Allow projects to completely override the filter that gets used if desired. If not overridden then create // a new one. if (requestTracingFilter == null) { requestTracingFilter = new RequestTracingFilter(); } FilterRegistrationBean frb = new FilterRegistrationBean(requestTracingFilter); // Add the user ID header keys init param if specified in the wingtips properties. if (wingtipsProperties.getUserIdHeaderKeys() != null) { frb.addInitParameter( RequestTracingFilter.USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME, wingtipsProperties.getUserIdHeaderKeys() ); } // Add the tagging strategy init param if specified in the wingtips properties. if (wingtipsProperties.getServerSideSpanTaggingStrategy() != null) { frb.addInitParameter( RequestTracingFilter.TAG_AND_SPAN_NAMING_STRATEGY_INIT_PARAM_NAME, wingtipsProperties.getServerSideSpanTaggingStrategy() ); } // Add the tagging adapter init param if specified in the wingtips properties. if (wingtipsProperties.getServerSideSpanTaggingAdapter() != null) { frb.addInitParameter( RequestTracingFilter.TAG_AND_SPAN_NAMING_ADAPTER_INIT_PARAM_NAME, wingtipsProperties.getServerSideSpanTaggingAdapter() ); } // Set the order so that the tracing filter is registered first frb.setOrder(Ordered.HIGHEST_PRECEDENCE); return frb; }