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

The following examples show how to use org.springframework.boot.web.servlet.FilterRegistrationBean#setUrlPatterns() . 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
Source Project: CAS   File: CasCustomConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 该过滤器负责对Ticket的校验工作,使用CAS 3.0协议
 *
 * @return
 */
@Bean
public FilterRegistrationBean cas30ProxyReceivingTicketValidationFilter() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new Cas30ProxyReceivingTicketValidationFilter());
    filterRegistration.setEnabled(casEnabled);
    if (autoconfig.getValidateFilters().size() > 0) {
        filterRegistration.setUrlPatterns(autoconfig.getValidateFilters());
    } else {
        filterRegistration.addUrlPatterns("/*");
    }
    filterRegistration.addInitParameter("casServerUrlPrefix", autoconfig.getCasServerUrlPrefix());
    filterRegistration.addInitParameter("serverName", autoconfig.getServerName());
    filterRegistration.setOrder(5);
    return filterRegistration;
}
 
Example 2
Source Project: CAS   File: CasCustomConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 该过滤器负责对Ticket的校验工作,使用CAS 3.0协议
 *
 * @return
 */
@Bean
public FilterRegistrationBean cas30ProxyReceivingTicketValidationFilter() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new Cas30ProxyReceivingTicketValidationFilter());
    filterRegistration.setEnabled(casEnabled);
    if (autoconfig.getValidateFilters().size() > 0) {
        filterRegistration.setUrlPatterns(autoconfig.getValidateFilters());
    } else {
        filterRegistration.addUrlPatterns("/*");
    }
    filterRegistration.addInitParameter("casServerUrlPrefix", autoconfig.getCasServerUrlPrefix());
    filterRegistration.addInitParameter("serverName", autoconfig.getServerName());
    filterRegistration.setOrder(5);
    return filterRegistration;
}
 
Example 3
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.js,*.css,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 4
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 5
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 6
Source Project: mogu_blog_v2   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());

    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.vue,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");

    bean.setInitParameters(initParams);

    bean.setUrlPatterns(Arrays.asList("/*"));

    return bean;
}
 
Example 7
Source Project: SimpleBBS   File: WebMvcConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(downloadFilter);

    //设置过滤器拦截请求
    List<String> urls = new ArrayList<>();
    urls.add("/file/*");
    registrationBean.setUrlPatterns(urls);

    return registrationBean;
}
 
Example 8
Source Project: youran   File: WebConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 防止通过parameter传入XSS脚本
 *
 * @return
 */
@Bean
public FilterRegistrationBean webXSSFilterBean() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    WebXSSFilter filter = new WebXSSFilter();
    registrationBean.setFilter(filter);
    List<String> urlPatterns = new ArrayList<>();
    urlPatterns.add("/*");
    registrationBean.setUrlPatterns(urlPatterns);
    return registrationBean;
}
 
Example 9
Source Project: springbootexamples   File: FilterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean<Filter> filterRegistration(){
	FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>();
	filterRegistrationBean.setFilter(new URLFilter());
	List<String> urlList = new ArrayList<String>();
	urlList.add("/*");
	filterRegistrationBean.setUrlPatterns(urlList);
	filterRegistrationBean.setName("URLFilter");
	filterRegistrationBean.setOrder(1);
	return filterRegistrationBean;
}
 
Example 10
/**
 * Filter to protect the hawkBit management UI 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.ui-filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosMgmtUiFilter(final HawkbitSecurityProperties securityProperties) {

    final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(null,
            securityProperties.getDos().getUiFilter(), securityProperties.getClients());
    // All URLs that can be called anonymous
    filterRegBean.setUrlPatterns(Arrays.asList("/UI/login", "/UI/login/*", "/UI/logout", "/UI/logout/*"));
    filterRegBean.setOrder(DOS_FILTER_ORDER);
    filterRegBean.setName("dosMgmtUiFilter");

    return filterRegBean;
}
 
Example 11
Source Project: kkFileView   File: FilterConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean getTrustHostFilter() {
    Set<String> filterUri = new HashSet<>();
    filterUri.add("/onlinePreview");
    filterUri.add("/picturesPreview");
    filterUri.add("/getCorsFile");
    filterUri.add("/addTask");
    TrustHostFilter filter = new TrustHostFilter();
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(filter);
    registrationBean.setUrlPatterns(filterUri);
    return registrationBean;
}
 
Example 12
Source Project: blog   File: DruidConfig.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
	FilterRegistrationBean<WebStatFilter> bean = new FilterRegistrationBean<>(new WebStatFilter());
	HashMap<String, String> initParams = new HashMap<>();
	initParams.put("exclusions", "/css,/druid/*");
	bean.setInitParameters(initParams);
	bean.setUrlPatterns(Arrays.asList("/*"));
	return bean;
}
 
Example 13
Source Project: Doctor   File: DruidConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean webStatFilter() {
    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());
    Map<String, String> initParams = new HashMap<>();
    initParams.put("exclusions", "*.js,*.css,/druid/*");
    bean.setInitParameters(initParams);
    bean.setUrlPatterns(Arrays.asList("/*"));
    return bean;
}
 
Example 14
Source Project: CAS   File: CasCustomConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 该过滤器使得可以通过org.jasig.cas.client.util.AssertionHolder来获取用户的登录名。
 * 比如AssertionHolder.getAssertion().getPrincipal().getName()。
 * 这个类把Assertion信息放在ThreadLocal变量中,这样应用程序不在web层也能够获取到当前登录信息
 *
 * @return
 */
@Bean
public FilterRegistrationBean assertionThreadLocalFilter() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new AssertionThreadLocalFilter());
    filterRegistration.setEnabled(true);
    if (autoconfig.getAssertionFilters().size() > 0) {
        filterRegistration.setUrlPatterns(autoconfig.getAssertionFilters());
    } else {
        filterRegistration.addUrlPatterns("/*");
    }
    filterRegistration.setOrder(7);
    return filterRegistration;
}
 
Example 15
@Bean
@ConditionalOnWebApplication
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    HTTPBasicAuthorizeAttribute httpBasicFilter = new HTTPBasicAuthorizeAttribute(config);
    registrationBean.setFilter(httpBasicFilter);
    List<String> urlPatterns = new ArrayList<String>();
    urlPatterns.add("/autoload-cache-ui.html");
    urlPatterns.add("/autoload-cache/*");
    registrationBean.setUrlPatterns(urlPatterns);
    return registrationBean;
}
 
Example 16
/**
 * 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 17
Source Project: springboot-guide   File: MyFilterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean<MyFilter> setUpMyFilter() {
    FilterRegistrationBean<MyFilter> filterRegistrationBean = new FilterRegistrationBean<>();
    filterRegistrationBean.setOrder(2);
    filterRegistrationBean.setFilter(myFilter);
    filterRegistrationBean.setUrlPatterns(new ArrayList<>(Arrays.asList("/api/*")));

    return filterRegistrationBean;
}
 
Example 18
Source Project: spring-boot-inside   File: AdminFilterConfig.java    License: MIT License 5 votes vote down vote up
@Bean
FilterRegistrationBean testFilter() {
	FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
	filterRegistrationBean.setFilter(new AdminFilter());
	filterRegistrationBean.setUrlPatterns(Arrays.asList("/admin/*"));
	return filterRegistrationBean;
}
 
Example 19
Source Project: CAS   File: CasCustomConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 该过滤器使得可以通过org.jasig.cas.client.util.AssertionHolder来获取用户的登录名。
 * 比如AssertionHolder.getAssertion().getPrincipal().getName()。
 * 这个类把Assertion信息放在ThreadLocal变量中,这样应用程序不在web层也能够获取到当前登录信息
 *
 * @return
 */
@Bean
public FilterRegistrationBean assertionThreadLocalFilter() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new AssertionThreadLocalFilter());
    filterRegistration.setEnabled(true);
    if (autoconfig.getAssertionFilters().size() > 0) {
        filterRegistration.setUrlPatterns(autoconfig.getAssertionFilters());
    } else {
        filterRegistration.addUrlPatterns("/*");
    }
    filterRegistration.setOrder(7);
    return filterRegistration;
}
 
Example 20
Source Project: CAS   File: CasCustomConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 该过滤器用于实现单点登出功能,单点退出配置,一定要放在其他filter之前
 *
 * @return
 */
@Bean
public FilterRegistrationBean singleSignOutFilter() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new SingleSignOutFilter());
    filterRegistration.setEnabled(casEnabled);
    if (autoconfig.getSignOutFilters().size() > 0) {
        filterRegistration.setUrlPatterns(autoconfig.getSignOutFilters());
    } else {
        filterRegistration.addUrlPatterns("/*");
    }
    filterRegistration.addInitParameter("casServerUrlPrefix", autoconfig.getCasServerUrlPrefix());
    filterRegistration.setOrder(3);
    return filterRegistration;
}