public class ServiceManageRestInterceptorextends HandlerInterceptorAdapter{
private Loggerlogger = LoggerFactory.getLogger(ServiceManageRestInterceptor.class);
@Autowired
private JWTUtiljwtUtil;
@Value("${token-header}")
private StringtokenHeader;
private ListallowedClient;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
// // 配置该注解,说明不进行服务拦截
// IgnoreClientToken annotation = handlerMethod.getBeanType().getAnnotation(IgnoreClientToken.class);
// if (annotation == null) {
// annotation = handlerMethod.getMethodAnnotation(IgnoreClientToken.class);
// }
// if(annotation!=null) {
// return super.preHandle(request, response, handler);
// }
// String token = request.getHeader(serviceAuthConfig.getTokenHeader());
// IJWTInfo infoFromToken = serviceAuthUtil.getInfoFromToken(token);
// String uniqueName = infoFromToken.getUniqueName();
// for(String client:serviceAuthUtil.getAllowedClient()){
// if(client.equals(uniqueName)){
// return super.preHandle(request, response, handler);
// }
// }
throw new ClientForbiddenException("Client is Forbidden!");
}
}