Java 类org.springframework.web.servlet.config.annotation.InterceptorRegistry 实例源码

项目:service-hive    文件:DevCloudWebMvcConfigurer.java   
/**
 * 添加令牌处理拦截器,检查请求头是否带有效的令牌。
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    InterceptorRegistration interceptor = registry.addInterceptor(tokenInterceptor);

    String pathPatterns = devcloudProperties.getPathPatterns();
    log.info("Interceptor path patterns: " + pathPatterns);

    if (pathPatterns == null || pathPatterns.isEmpty()) {
        return;
    }

    String[] paths = pathPatterns.split(",");
    if (paths == null || paths.length == 0) {
        return;
    }

    for (String path : paths) {
        interceptor.addPathPatterns(path);
    }
}
项目:SpringBootStudy    文件:WebMvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    //接口签名认证拦截器,该签名认证比较简单,实际项目中可以使用Json Web Token或其他更好的方式替代。
    if (!"dev".equals(env)) { //开发环境忽略签名认证
        registry.addInterceptor(new HandlerInterceptorAdapter() {
            @Override
            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
                //验证签名
                boolean pass = validateSign(request);
                if (pass) {
                    return true;
                } else {
                    logger.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}",
                            request.getRequestURI(), getIpAddress(request), JSON.toJSONString(request.getParameterMap()));

                    Result result = new Result();
                    result.setCode(ResultCode.UNAUTHORIZED).setMessage("签名认证失败");
                    responseResult(response, result);
                    return false;
                }
            }
        });
    }
}
项目:scoold    文件:ScooldServer.java   
@Bean
    public WebMvcConfigurerAdapter baseConfigurerBean(@Named final ScooldRequestInterceptor sri) {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                super.addInterceptors(registry);
                registry.addInterceptor(sri);
            }

//          @Override
//          public void addResourceHandlers(ResourceHandlerRegistry registry) {
//              registry.addResourceHandler("/images/**").addResourceLocations("/static/images/")
//                  .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
//              registry.addResourceHandler("/styles/**").addResourceLocations("/static/styles/")
//                  .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
//              registry.addResourceHandler("/scripts/**").addResourceLocations("/static/scripts/")
//                  .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
//          }
        };
    }
项目:spring-seed    文件:SpringSeedRestApiMvcConfigration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    String[] swaggerPaths = {"/swagger-resources/**", "/v2/api-docs"};
    if(!disableCors){
        registry.addInterceptor(new CorsHeaderInterceptor());
    }
    if(parseAuthorizationHeader && !jwtValue) {
        if(enableSwagger2) {
            registry.addInterceptor(authorizationHeaderInterceptor()).excludePathPatterns(swaggerPaths);
        }else{
            registry.addInterceptor(authorizationHeaderInterceptor());
        }
    }
    if(jwtValue) {
        if(enableSwagger2){
            registry.addInterceptor(jwtTokenInterceptor()).excludePathPatterns(swaggerPaths);
        }else{
            registry.addInterceptor(jwtTokenInterceptor());
        }
    }
    super.addInterceptors(registry);
}
项目:xm-commons    文件:XmWebMvcConfigurerAdapter.java   
/**
 * Registered interceptor to all request except passed urls.
 * @param registry helps with configuring a list of mapped interceptors.
 * @param interceptor the interceptor
 */
protected void registerTenantInterceptorWithIgnorePathPattern(
                InterceptorRegistry registry, HandlerInterceptor interceptor) {
    InterceptorRegistration tenantInterceptorRegistration = registry.addInterceptor(interceptor);
    tenantInterceptorRegistration.addPathPatterns("/**");

    List<String> tenantIgnorePathPatterns = getTenantIgnorePathPatterns();
    Objects.requireNonNull(tenantIgnorePathPatterns, "tenantIgnorePathPatterns can't be null");

    for (String pattern : tenantIgnorePathPatterns) {
        tenantInterceptorRegistration.excludePathPatterns(pattern);
    }

    LOGGER.info("Added handler interceptor '{}' to all urls, exclude {}", interceptor.getClass()
                    .getSimpleName(), tenantIgnorePathPatterns);
}
项目:SpringBootStudy    文件:WebMvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    //接口签名认证拦截器,该签名认证比较简单,实际项目中可以使用Json Web Token或其他更好的方式替代。
    if (!"dev".equals(env)) { //开发环境忽略签名认证
        registry.addInterceptor(new HandlerInterceptorAdapter() {
            @Override
            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
                //验证签名
                boolean pass = validateSign(request);
                if (pass) {
                    return true;
                } else {
                    logger.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}",
                            request.getRequestURI(), getIpAddress(request), JSON.toJSONString(request.getParameterMap()));

                    Result result = new Result();
                    result.setCode(ResultCode.UNAUTHORIZED).setMessage("签名认证失败");
                    responseResult(response, result);
                    return false;
                }
            }
        });
    }
}
项目:X-mall    文件:MallWebAppConfigurer.java   
/**
 * 拦截器链
 * @param registry
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    // 多个拦截器组成一个拦截器链
    // addPathPatterns 用于添加拦截规则
    // excludePathPatterns 用户排除拦截
    registry.addInterceptor(new MallInterceptor())
            .addPathPatterns("/manage/**", "/app/**")
            // 不拦截登录接口
            .excludePathPatterns("/app/user/login");
    //registry.addInterceptor(new MyInterceptor2()).addPathPatterns("/**");
    super.addInterceptors(registry);
}
项目:travel-agency    文件:WebConfiguration.java   
@Override
    public void addInterceptors(InterceptorRegistry registry) {
        if(twoFaEnabeld){
            log.info("2FA is ENABLED");
//            registry.addInterceptor( verifyInterceptorBean() )
//                .excludePathPatterns("/static/**", "/webjars/**", "/verify");
        }else{
            log.info("2FA is DISABLED");
        }

    }
项目:spring-cloud-ribbon-extensions    文件:PreservesHeadersInboundHttpRequestStrategy.java   
/**
 * Adds http request interceptor copying headers from the request to the context
 *
 * @param registry the interceptor registry
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new PreservesHttpHeadersInterceptor(properties.buildEntriesFilter())).addPathPatterns(
            "/**");
    log.info("Context propagation enabled for http request on keys={}.", properties.getKeys());
}
项目:xm-commons    文件:XmWebMvcConfigurerAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public final void addInterceptors(InterceptorRegistry registry) {
    registerTenantInterceptorWithIgnorePathPattern(registry, tenantInterceptor);
    registerXmLoggingInterceptor(registry);

    xmAddInterceptors(registry);
}
项目:spring-boot-frameset    文件:MyWebMvcConfigurerAdapter.java   
/**
 * 拦截器
 *
 * @param registry
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    // addPathPatterns 用于添加拦截规则
    // excludePathPatterns 用户排除拦截
    registry.addInterceptor(new MyInterceptor()).addPathPatterns("/learn/**").excludePathPatterns("login/**");
    super.addInterceptors(registry);
}
项目:servlet4-demo    文件:ApplicationConfigTest.java   
@Before
public void setUp() {
  sut = new ApplicationConfig();
  server = mock(Server.class);
  registry = mock(InterceptorRegistry.class);
  when(server.getThreadPool()).thenReturn(new ThreadPool() {
    @Override
    public void join() throws InterruptedException {
      // Do nothing. This is just a unit test.
    }

    @Override
    public int getThreads() {
      return 0;
    }

    @Override
    public int getIdleThreads() {
      return 0;
    }

    @Override
    public boolean isLowOnThreads() {
      return false;
    }

    @Override
    public void execute(Runnable command) {
      // Do nothing. This is just a unit test.
    }
  });
}
项目:uckefu    文件:UKWebAppConfigurer.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    // 多个拦截器组成一个拦截器链
    // addPathPatterns 用于添加拦截规则
    // excludePathPatterns 用户排除拦截
    registry.addInterceptor(new UserInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/login.html").excludePathPatterns("/im/**");
    super.addInterceptors(registry);
}
项目:OperatieBRP    文件:WebConfiguratie.java   
@Override
public void addInterceptors(final InterceptorRegistry registry) {

    for (final EntityManagerFactory entityManagerFactory : entityManagerFactories) {
        final OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor = new OpenEntityManagerInViewInterceptor();
        openEntityManagerInViewInterceptor.setEntityManagerFactory(entityManagerFactory);
        registry.addWebRequestInterceptor(openEntityManagerInViewInterceptor);
    }

    super.addInterceptors(registry);
}
项目:second-opinion-api    文件:SecondOpinionConfiguration.java   
@Bean
public WebMvcConfigurerAdapter adapter() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(new LogExecutionInterceptor());
        }
    };
}
项目:uroborosql-springboot-demo    文件:MvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(loggingInterceptor)
        .addPathPatterns("/**");
    if (enabledAuth) {
        registry.addInterceptor(authInterceptor)
            .addPathPatterns("/api/**")
            .excludePathPatterns("/api/login");

    }
}
项目:myth    文件:AdminConfiguration.java   
@Bean
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
        }
    };
}
项目:xq_seckill_microservice    文件:WebAppConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    // 多个拦截器组成一个拦截器链
    // addPathPatterns 用于添加拦截规则
    // excludePathPatterns 用户排除拦截
    registry.addInterceptor(logInterceptor).addPathPatterns("/**");
}
项目:tulingchat    文件:MyWebAppConfigurer.java   
/**
 * 添加拦截器
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
  // addInterceptor方法 可以加入多个拦截器组成一个拦截器链
  // addPathPatterns 用于添加拦截规则
  // excludePathPatterns 用户排除拦截规则
 registry.addInterceptor(getMyInterceptor()).addPathPatterns("/**");
 super.addInterceptors(registry);
}
项目:spring-multitenancy    文件:MultitenancyWebConfig.java   
@Override
public void addInterceptors (InterceptorRegistry registry) {
    registry.addInterceptor(new MultitenancyWebInterceptor(config));
}
项目:Agent-Benchmarks    文件:ApplicationConfigAdapter.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    super.addInterceptors(registry);
}
项目:burpextender-proxyhistory-webui    文件:WebMvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new JdbcConnectionInterceptor());
}
项目:xm-uaa    文件:LocaleConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    registry.addInterceptor(localeChangeInterceptor);
}
项目:jhipster-microservices-example    文件:LocaleConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    registry.addInterceptor(localeChangeInterceptor);
}
项目:amanda    文件:WebServletContextConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(localeChangeInterceptor());
}
项目:jhipster-microservices-example    文件:LocaleConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    registry.addInterceptor(localeChangeInterceptor);
}
项目:MTC_Labrat    文件:LocaleConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    registry.addInterceptor(localeChangeInterceptor);
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:LocaleConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    registry.addInterceptor(localeChangeInterceptor);
}
项目:Spring-5.0-Cookbook    文件:SpringDispatcherConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/login.html");
    registry.addInterceptor(new AfterLogoutInterceptor()).addPathPatterns("/after_logout.html*");
}
项目:Spring-5.0-Cookbook    文件:SpringDispatcherConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/login.html");
    registry.addInterceptor(new AfterLogoutInterceptor()).addPathPatterns("/after_logout.html*");
}
项目:pds    文件:WebMvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**");
}
项目:cas-5.1.0    文件:CasSecurityContextConfiguration.java   
@Override
public void addInterceptors(final InterceptorRegistry registry) {
    registry.addInterceptor(statusInterceptor()).addPathPatterns("/status/**");
    registry.addInterceptor(webContentInterceptor()).addPathPatterns("/*");
}
项目:cas-5.1.0    文件:OidcConfiguration.java   
@Override
public void addInterceptors(final InterceptorRegistry registry) {
    registry.addInterceptor(oauthInterceptor()).addPathPatterns('/' + OidcConstants.BASE_OIDC_URL.concat("/").concat("*"));
}
项目:cas-5.1.0    文件:CasOAuthConfiguration.java   
@Override
public void addInterceptors(final InterceptorRegistry registry) {
    registry.addInterceptor(oauthInterceptor()).addPathPatterns(BASE_OAUTH20_URL.concat("/").concat("*"));
}
项目:spring-cloud-samples    文件:WebConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
}
项目:WIFIProbe    文件:WebMvcConfig.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
}
项目:zyndev-spring-cloud    文件:MyWebMvcConfigurer.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new BasicInterceptor()).addPathPatterns("/**");
    super.addInterceptors(registry);
}
项目:springboot_op    文件:LoggerInterceptorConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new LoggerInterceptor()).addPathPatterns("/*");
}
项目:springboot_op    文件:TestInterceptorConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new TestInterceptor()).addPathPatterns("/*");
}
项目:configx    文件:WebAutoConfiguration.java   
@Override
public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(loginInterceptor());
}