perf: token兼容旧版本,旧版本使用的是10位数的秒作为数据
This commit is contained in:
@@ -2,6 +2,7 @@ package com.tiesheng.util.jwt;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.util.jwt.signers.JWTSigner;
|
||||
import com.tiesheng.util.jwt.signers.NoneJWTSigner;
|
||||
@@ -200,7 +201,10 @@ public class JWTValidator {
|
||||
validateNotAfter(JWTPayload.NOT_BEFORE, notBefore, now, leeway);
|
||||
|
||||
// 检查失效时间(失效时间不能早于当前时间)
|
||||
final Date expiresAt = payload.getClaimsJson().getDate(JWTPayload.EXPIRES_AT);
|
||||
// 这里兼容一下旧版本,旧版本使用的是10位数的秒作为数据
|
||||
String string = payload.getClaimsJson().getString(JWTPayload.EXPIRES_AT);
|
||||
Date expiresAt = StrUtil.length(string) == 10 ? DateUtil.date(NumberUtil.parseLong(string) * 1000L)
|
||||
: DateUtil.parse(string);
|
||||
validateNotBefore(JWTPayload.EXPIRES_AT, expiresAt, now, leeway);
|
||||
|
||||
// 检查签发时间(签发时间不能晚于当前时间)
|
||||
|
||||
Reference in New Issue
Block a user