lyhzzz 1 month ago
parent
commit
f1df498018
1 changed files with 3 additions and 6 deletions
  1. 3 6
      src/main/java/com/fdkankan/ucenter/aop/SignVerifyAspect.java

+ 3 - 6
src/main/java/com/fdkankan/ucenter/aop/SignVerifyAspect.java

@@ -58,7 +58,7 @@ public class SignVerifyAspect {
             log.info("verifySign--requestPath:{},sign:{},appId:{}",request.getRequestURL(),sign,appId);
             throw new BusinessException(ResultCode.SIGN_ERROR);
         }
-        if(!checkSign(sign,appId,byAppId.getPrivateKey())){
+        if(!SignUtils.checkSign(sign,appId,byAppId.getPrivateKey())){
             log.info("verifySign-checkSign-error-requestPath:{},sign:{},appId:{}",request.getRequestURL(),sign,appId);
             throw new BusinessException(ResultCode.SIGN_ERROR);
         }
@@ -88,11 +88,8 @@ public class SignVerifyAspect {
                 return false;
             }
             Long time = new Date().getTime();
-            if(time < timestamp && timestamp - time > 1000 * 60){
-                log.info("time:{},timestamp:{}",time,timestamp);
-                return false;
-            }
-            if(time -timestamp >1000 * 60 *5){ //app使用会有误差,未来时间
+            //app获取时间存在误差,前后五分钟失败
+            if(Math.abs(time -timestamp) >1000 * 60 *5){
                 return false;
             }
             return true;