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() . 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: CasCustomConfig.java    From CAS with 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 File: CasCustomConfig.java    From CAS with 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
Source File: DruidConfig.java    From Doctor with 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 4
Source File: DruidConfig.java    From mogu_blog_v2 with 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 File: CasCustomConfig.java    From CAS with 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;
}
 
Example 6
Source File: CasCustomConfig.java    From CAS with 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 7
Source File: AdminFilterConfig.java    From spring-boot-inside with 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 8
Source File: MyFilterConfig.java    From springboot-guide with 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 9
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 10
Source File: AutoloadCacheAutoConfigure.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: CasCustomConfig.java    From CAS with 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 12
Source File: DruidConfig.java    From mogu_blog_v2 with 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 13
Source File: DruidConfig.java    From codeway_service with GNU General Public License v3.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 File: DruidConfig.java    From blog with 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 15
Source File: FilterConfiguration.java    From kkFileView with 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 16
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 17
Source File: FilterConfig.java    From springbootexamples with 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 18
Source File: WebConfig.java    From youran with 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 19
Source File: WebMvcConfig.java    From SimpleBBS with 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 20
Source File: DruidConfig.java    From mogu_blog_v2 with 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;
}