Java Code Examples for org.springframework.boot.context.embedded.FilterRegistrationBean#setFilter()

The following examples show how to use org.springframework.boot.context.embedded.FilterRegistrationBean#setFilter() . 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: WebSecurityConfig.java    From mojito with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnProperty(value = "l10n.security.oauth2.enabled", havingValue = "true")
public FilterRegistrationBean oauth2ClientFilterRegistration(OAuth2ClientContextFilter filter) {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(filter);
    registration.setOrder(-100);
    return registration;
}
 
Example 2
Source File: CatConfig.java    From x-pipe with Apache License 2.0 6 votes vote down vote up
@Bean
public FilterRegistrationBean catFilter() {
	
	FilterRegistrationBean bean = new FilterRegistrationBean();
	bean.setFilter(new CatFilter());
	bean.setName("cat-filter");
	bean.addUrlPatterns("/*");
	bean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD);
	return bean;
}
 
Example 3
Source File: RoothubApplication.java    From Roothub with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean filterRegistrationBean() {
	FilterRegistrationBean registrationBean = new FilterRegistrationBean();
	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setForceEncoding(true);
	characterEncodingFilter.setEncoding("UTF-8");
	registrationBean.setFilter(characterEncodingFilter);
	return registrationBean;
}
 
Example 4
Source File: OpenApiWebMvcConfigurer.java    From spring-backend-boilerplate with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean httpMethodFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(httpMethodFilter());
    registration.addUrlPatterns("/*");
    registration.setName("httpMethodFilter");
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
    return registration;
}
 
Example 5
Source File: OpenApiWebMvcConfigurer.java    From spring-backend-boilerplate with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean httpMethodFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(httpMethodFilter());
    registration.addUrlPatterns("/*");
    registration.setName("httpMethodFilter");
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
    return registration;
}
 
Example 6
Source File: ShiroAutoConfiguration.java    From spring-boot-shiro with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: WebApplication.java    From hello-sso-jwt-resource 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 8
Source File: MetaServerContextConfig.java    From x-pipe with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean domainValidateFilter() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    Supplier<String> expectedDomainName = () -> {
        // toLowerCase() to match metaServerConfig retrieve info
        String dcName = FoundationService.DEFAULT.getDataCenter().toLowerCase();
        DcInfo dcInfo = metaServerConfig.getDcInofs().get(dcName);
        return dcInfo.getMetaServerAddress();
    };
    DomainValidateFilter filter = new DomainValidateFilter(()->metaServerConfig.validateDomain(), expectedDomainName);
    registrationBean.setFilter(filter);
    registrationBean.addUrlPatterns("/*");
    return registrationBean;
}
 
Example 9
Source File: RestConfiguration.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean loggingFilterRegistration() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(loggingFilter());
    registrationBean.setUrlPatterns(Collections.singletonList("/*"));
    registrationBean.setName("LoggingFilter");
    return registrationBean;
}
 
Example 10
Source File: RequestCorrelationConfiguration.java    From request-correlation-spring-cloud-starter with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean requestCorrelationFilterBean(RequestCorrelationFilter correlationFilter) {

    final FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(correlationFilter);
    filterRegistration.setMatchAfter(false);
    filterRegistration.setDispatcherTypes(
            EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC));
    filterRegistration.setAsyncSupported(true);
    filterRegistration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return filterRegistration;
}
 
Example 11
Source File: WebConfig.java    From jcart with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean PostAuthorizationFilterRegistrationBean() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(postAuthorizationFilter);
    registrationBean.setOrder(Integer.MAX_VALUE);
    return registrationBean;
}