Ejemplo n.º 1
0
  @Bean
  public FilterRegistrationBean jwtFilter() {
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    WebTokenFilter authenticationFilter = new WebTokenFilter(key);

    // Protect all methods from "/link"
    URLProtection linkURL = new URLProtection("/link.*");
    linkURL.setAllMethods();
    authenticationFilter.addUrlToProtect(linkURL);

    // Protect GET, DELETE and PUT from "/user"
    URLProtection userURL = new URLProtection("/user.*");
    userURL.addMethod("GET");
    userURL.addMethod("DELETE");
    userURL.addMethod("PUT");
    authenticationFilter.addUrlToProtect(userURL);

    // Protect GET from aggregated link information
    URLProtection aggregatedInfoURL = new URLProtection("/info.*");
    aggregatedInfoURL.addMethod("GET");
    authenticationFilter.addUrlToProtect(aggregatedInfoURL);

    // Protect GET from simple link information
    URLProtection infoURL = new URLProtection("/.*\\+");
    infoURL.addMethod("GET");
    authenticationFilter.addUrlToProtect(infoURL);

    registrationBean.setFilter(authenticationFilter);

    return registrationBean;
  }
 @Bean
 public FilterRegistrationBean resourceFilterRegistration() {
   FilterRegistrationBean bean = new FilterRegistrationBean();
   bean.setFilter(resourceFilter);
   bean.setEnabled(false);
   return bean;
 }
 @Bean
 public FilterRegistrationBean togglzFilter() {
   FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
   filterRegistration.setFilter(new TogglzFilter());
   filterRegistration.addUrlPatterns("/*");
   return filterRegistration;
 }
Ejemplo n.º 4
0
  @Bean
  public FilterRegistrationBean jwtFilter() {
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    registrationBean.setFilter(new JwtFilter());
    registrationBean.addUrlPatterns("/api/*");

    return registrationBean;
  }
Ejemplo n.º 5
0
 @Bean(name = "sitemeshFilter")
 public FilterRegistrationBean sitemeshFilter() {
   FilterRegistrationBean bean = new FilterRegistrationBean();
   bean.setFilter(new SitemeshFilter());
   bean.addUrlPatterns("/*");
   bean.setOrder(1111);
   return bean;
 }
 @Bean
 public FilterRegistrationBean jersey() {
   FilterRegistrationBean bean = new FilterRegistrationBean();
   bean.setFilter(new ServletContainer());
   bean.addInitParameter(
       "com.sun.jersey.config.property.packages", "com.sun.jersey;sample.jersey1");
   return bean;
 }
 @Bean
 public FilterRegistrationBean filterRegistrationBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
   characterEncodingFilter.setEncoding("UTF-8");
   registrationBean.setFilter(characterEncodingFilter);
   return registrationBean;
 }
Ejemplo n.º 8
0
 /** 扩展filter */
 @Bean
 public FilterRegistrationBean filterRegistrationBean(AuthFilter filter) {
   FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
   filterRegistrationBean.setFilter(filter);
   filterRegistrationBean.setEnabled(true);
   filterRegistrationBean.addUrlPatterns("/admin");
   return filterRegistrationBean;
 }
 @Bean
 @ConditionalOnMissingBean
 public FilterRegistrationBean requestContextFilter() {
   FilterRegistrationBean registration = new FilterRegistrationBean();
   registration.setFilter(new RequestContextFilter());
   registration.setOrder(this.jersey.getFilter().getOrder() - 1);
   registration.setName("requestContextFilter");
   return registration;
 }
Ejemplo n.º 10
0
 @Bean
 @DependsOn("tokenAuthFilter")
 public FilterRegistrationBean tokenAuthFilterRegisterBean() {
   FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
   filterRegistrationBean.setFilter(tokenAuthFilter());
   filterRegistrationBean.setEnabled(false);
   filterRegistrationBean.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
   return filterRegistrationBean;
 }
Ejemplo n.º 11
0
 @Bean
 public FilterRegistrationBean filterRegistrationBean() {
   FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
   filterRegistrationBean.setFilter(new WebStatFilter());
   filterRegistrationBean.addUrlPatterns("/*");
   filterRegistrationBean.addInitParameter(
       "exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
   return filterRegistrationBean;
 }
 @Bean
 public FilterRegistrationBean securityFilterBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   registrationBean.setFilter(openLRSAuthenticationFilter);
   List<String> urls = new ArrayList<String>(2);
   urls.add("/v1/*");
   registrationBean.setUrlPatterns(urls);
   registrationBean.setOrder(2);
   return registrationBean;
 }
 @Bean
 public FilterRegistrationBean corsFilterBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   registrationBean.setFilter(corsFilter);
   List<String> urls = new ArrayList<String>(1);
   urls.add("/v1/*");
   registrationBean.setUrlPatterns(urls);
   registrationBean.setOrder(1);
   return registrationBean;
 }
 @Bean
 public FilterRegistrationBean oAuthFilterBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   registrationBean.setFilter(oAuthFilter);
   List<String> urls = new ArrayList<String>(1);
   urls.add("/lti");
   registrationBean.setUrlPatterns(urls);
   registrationBean.setOrder(4);
   return registrationBean;
 }
 @Bean
 public FilterRegistrationBean validationFilterBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   registrationBean.setFilter(xapiRequestValidationFilter);
   List<String> urls = new ArrayList<String>(1);
   urls.add("/v1/xAPI/*");
   registrationBean.setUrlPatterns(urls);
   registrationBean.setOrder(3);
   return registrationBean;
 }
Ejemplo n.º 16
0
  @Bean
  public FilterRegistrationBean someFilterRegistration() {

    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(cacheFilter());
    //        registration.addUrlPatterns("/url/*");
    //        registration.addInitParameter("paramName", "paramValue");
    //        registration.setName("someFilter");
    return registration;
  }
 @Bean
 public FilterRegistrationBean authFilter() {
   AuthFilter authFilter = new AuthFilter();
   FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
   filterRegBean.setFilter(authFilter);
   List<String> urlPatterns = new ArrayList<String>();
   urlPatterns.add("/*");
   filterRegBean.setUrlPatterns(urlPatterns);
   return filterRegBean;
 }
 @Bean
 @ConditionalOnBean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
 public FilterRegistrationBean securityFilterChainRegistration(
     @Qualifier(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
         Filter securityFilter,
     SecurityProperties securityProperties) {
   FilterRegistrationBean registration = new FilterRegistrationBean(securityFilter);
   registration.setOrder(securityProperties.getFilterOrder());
   registration.setName(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME);
   return registration;
 }
Ejemplo n.º 19
0
  /**
   * 中文解码
   *
   * @return
   */
  @Bean
  public FilterRegistrationBean filterRegistrationBean() {

    CharacterEncodingFilter compressingFilter = new CharacterEncodingFilter();
    compressingFilter.setEncoding("UTF-8");
    compressingFilter.setForceEncoding(true);

    FilterRegistrationBean registrationBean = new FilterRegistrationBean();

    registrationBean.setFilter(compressingFilter);

    return registrationBean;
  }
  /**
   * 配置Druid过滤器
   *
   * @param ds
   * @return
   */
  @Bean
  public FilterRegistrationBean druidWebStatFilter(DruidSettings ds) {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean(new WebStatFilter());

    Map<String, String> initParameters = new HashMap<>();
    initParameters.put("exclusions", ds.getExclusions());
    initParameters.put("sessionStatMaxCount", ds.getSessionStatMaxCount().toString());
    initParameters.put("sessionStatEnable", ds.isSessionStatEnable() + "");
    if (ds.getPrincipalSessionName() != null) {
      initParameters.put("principalSessionName", ds.getPrincipalSessionName());
    }
    initParameters.put("profileEnable", ds.isProfileEnable() + "");
    registrationBean.setInitParameters(initParameters);
    registrationBean.addUrlPatterns("/*");
    return registrationBean;
  }
 @Bean
 @ConditionalOnMissingBean(name = "jerseyFilterRegistration")
 @ConditionalOnProperty(prefix = "spring.jersey", name = "type", havingValue = "filter")
 public FilterRegistrationBean jerseyFilterRegistration() {
   FilterRegistrationBean registration = new FilterRegistrationBean();
   registration.setFilter(new ServletContainer(this.config));
   registration.setUrlPatterns(Arrays.asList(this.path));
   registration.setOrder(this.jersey.getFilter().getOrder());
   registration.addInitParameter(ServletProperties.FILTER_CONTEXT_PATH, stripPattern(this.path));
   addInitParameters(registration);
   registration.setName("jerseyFilter");
   registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
   return registration;
 }