/** * 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); }
/** * 添加令牌处理拦截器,检查请求头是否带有效的令牌。 */ @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); } }
@Override public void addInterceptors(InterceptorRegistry registry) { /*Optional.ofNullable(interceptorList).ifPresent(list->{ list.stream().forEach(inter->registry.addInterceptor(inter)); });*/ if(LangUtils.isEmpty(interceptorList)){ return ; } for(HandlerInterceptor inter : interceptorList){ InterceptorRegistration reg = registry.addInterceptor(inter); if(inter instanceof WebInterceptorAdapter){ WebInterceptorAdapter webinter = (WebInterceptorAdapter) inter; if(LangUtils.isEmpty(webinter.getPathPatterns())){ continue; } reg.addPathPatterns(webinter.getPathPatterns()); } } // registry.addInterceptor(new BootFirstInterceptor()); }
@Override protected void addInterceptors(InterceptorRegistry registry) { for (MappedInterceptor interceptor : mappedInterceptors) { InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor()); if (interceptor.getPathPatterns() != null) { registration.addPathPatterns(interceptor.getPathPatterns()); } } }
@Override public void addInterceptors(InterceptorRegistry registry) { InterceptorRegistration reg = registry.addInterceptor(loggerInterceptor); if(LangUtils.isEmpty(loggerInterceptor.getPathPatterns())){ return ; } reg.addPathPatterns(loggerInterceptor.getPathPatterns()); }
@Override public void addInterceptors(InterceptorRegistry registry) { @SuppressWarnings("unused") InterceptorRegistration registration = registry.addInterceptor( new SecurityHandlerInterceptor()).addPathPatterns("/account", "/account/*", "/reader", "/reader/*"); }
public void addInterceptors(InterceptorRegistry registry) { InterceptorRegistration filterResponseInterceptor = registry.addInterceptor(new FilterResponseInterceptor(filterPreResponseHandler)); // 拦截配置 filterResponseInterceptor.addPathPatterns("/**"); try { filterInterceptor = applicationContext.getBean(FilterInterceptor.class); }catch (Exception e){ } logger.info("filterInterceptor->"+filterInterceptor); if(filterInterceptor!=null){ filterInterceptor.addInterceptors(registry); } }
@Before public void setUp() throws Exception { applicationConfiguration = new ApplicationConfiguration(tenantInterceptorAdapter); when(registry.addInterceptor(tenantInterceptorAdapter)).thenReturn(new InterceptorRegistration(tenantInterceptorAdapter)); }