|  | @@ -1,27 +1,19 @@
 | 
	
		
			
				|  |  |  package thyyxxk.webserver.config.auth;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.auth0.jwt.JWT;
 | 
	
		
			
				|  |  |  import com.auth0.jwt.JWTVerifier;
 | 
	
		
			
				|  |  |  import com.auth0.jwt.algorithms.Algorithm;
 | 
	
		
			
				|  |  |  import com.auth0.jwt.exceptions.JWTDecodeException;
 | 
	
		
			
				|  |  |  import com.auth0.jwt.exceptions.JWTVerificationException;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | -import org.apache.catalina.User;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  |  import org.springframework.web.method.HandlerMethod;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.HandlerInterceptor;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.config.exception.BizException;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.config.exception.ExceptionEnum;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.constants.Message;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.controller.ShutDownController;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.entity.login.UserInfo;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.entity.socketmessage.ApiMessageBody;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.service.LoginService;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.service.TokenService;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.service.externalhttp.WebSocketService;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.service.redislike.RedisLikeService;
 | 
	
		
			
				|  |  | -import thyyxxk.webserver.utils.SocketMsg;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletResponse;
 | 
	
	
		
			
				|  | @@ -33,17 +25,11 @@ import java.lang.reflect.Method;
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
		
			
				|  |  |  @Component
 | 
	
		
			
				|  |  |  public class AuthenticationInterceptor implements HandlerInterceptor {
 | 
	
		
			
				|  |  | -    private final TokenService tokenService;
 | 
	
		
			
				|  |  | -    private final WebSocketService socketService;
 | 
	
		
			
				|  |  |      private final RedisLikeService redisLikeService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private static final String EXPIRED = "The Token has expired";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public AuthenticationInterceptor(TokenService tokenService,
 | 
	
		
			
				|  |  | -                                     WebSocketService socketService,
 | 
	
		
			
				|  |  | -                                     RedisLikeService redisLikeService) {
 | 
	
		
			
				|  |  | -        this.tokenService = tokenService;
 | 
	
		
			
				|  |  | -        this.socketService = socketService;
 | 
	
		
			
				|  |  | +    public AuthenticationInterceptor(RedisLikeService redisLikeService) {
 | 
	
		
			
				|  |  |          this.redisLikeService = redisLikeService;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -100,19 +86,9 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
 | 
	
		
			
				|  |  |              jwtVerifier.verify(token);
 | 
	
		
			
				|  |  |          } catch (JWTVerificationException e) {
 | 
	
		
			
				|  |  |              if (e.getMessage().contains(EXPIRED)) {
 | 
	
		
			
				|  |  | -                if (code.equals("01897") || code.equals("02896")) {
 | 
	
		
			
				|  |  | -                    log.warn("【{}-{}】令牌已过期,自动刷新令牌。", userInfo.getCode(), userInfo.getName());
 | 
	
		
			
				|  |  | -                    token = tokenService.getToken(userInfo);
 | 
	
		
			
				|  |  | -                    JSONObject message = new JSONObject();
 | 
	
		
			
				|  |  | -                    message.put("token", token);
 | 
	
		
			
				|  |  | -                    String msg = SocketMsg.socketVo(Message.REFRESH_TOKEN, message);
 | 
	
		
			
				|  |  | -                    ApiMessageBody messageBody = new ApiMessageBody(userInfo.getCode(), msg);
 | 
	
		
			
				|  |  | -                    socketService.sendMessageByUserCode(messageBody);
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    throw new BizException(ExceptionEnum.TOKEN_EXPIRED);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +                throw new BizException(ExceptionEnum.TOKEN_EXPIRED);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                log.error("验证令牌出错!");
 | 
	
		
			
				|  |  | +                log.error("验证令牌出错!", e);
 | 
	
		
			
				|  |  |                  throw new BizException(ExceptionEnum.TOKEN_ERROR);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 |