|
|
@@ -1,6 +1,8 @@
|
|
|
package com.inspur.smsb.gateway.utils;
|
|
|
|
|
|
+import cn.hutool.core.exceptions.ValidateException;
|
|
|
import cn.hutool.jwt.JWTUtil;
|
|
|
+import cn.hutool.jwt.JWTValidator;
|
|
|
|
|
|
/**
|
|
|
* @author lijiaqi
|
|
|
@@ -13,7 +15,23 @@ public class TokenParseUtil {
|
|
|
* */
|
|
|
public static final String PUBLIC_KEY = "MIIBIjANBgkqhk";
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证token完整有效性,以及时间有效性
|
|
|
+ */
|
|
|
public static boolean verityToken(String token) {
|
|
|
+ return verifyTokenCompletion(token) && verifyTokenLeeDate(token);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean verifyTokenCompletion(String token) {
|
|
|
return JWTUtil.verify(token, PUBLIC_KEY.getBytes());
|
|
|
}
|
|
|
+
|
|
|
+ private static boolean verifyTokenLeeDate(String token) {
|
|
|
+ try {
|
|
|
+ JWTValidator.of(token).validateDate();
|
|
|
+ } catch (ValidateException e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|