diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/dromara/maxkey/authn/jwt/AuthJwtService.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/dromara/maxkey/authn/jwt/AuthJwtService.java index 3837514df..93fa2e51c 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/dromara/maxkey/authn/jwt/AuthJwtService.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/dromara/maxkey/authn/jwt/AuthJwtService.java @@ -122,7 +122,7 @@ public class AuthJwtService { if(StringUtils.isNotBlank(authToken) && authToken.length() > 20) { try { JWTClaimsSet claims = resolve(authToken); - boolean isExpiration = claims.getExpirationTime().before(DateTime.now().toDate()); + boolean isExpiration = claims.getExpirationTime().after(DateTime.now().toDate()); boolean isVerify = hmac512Service.verify(authToken); _logger.debug("JWT Validate {} " , isVerify && isExpiration); diff --git a/maxkey-common/src/test/java/org/maxkey/DateExpirationTest.java b/maxkey-common/src/test/java/org/maxkey/DateExpirationTest.java new file mode 100644 index 000000000..5ed345d67 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/DateExpirationTest.java @@ -0,0 +1,43 @@ +/* + * Copyright [2024] [MaxKey of copyright http://www.maxkey.top] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.maxkey; + +import java.util.Date; + +import org.dromara.maxkey.util.DateUtils; +import org.joda.time.DateTime; + +public class DateExpirationTest { + + public static void main(String[] args) { + // 当前时间 + Date now = DateTime.now().toDate(); + // 用户时间 + Date uDate = DateUtils.parse("2025-01-04 16:59:53",DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS); + + System.out.println("user time " + DateUtils.formatDateTime(uDate)); + System.out.println("now time " + DateUtils.formatDateTime(now)); + + //用户时间 > 当前时间 + System.out.println("after "+uDate.after(now)); + //用户时间 < 当前时间 + System.out.println("before "+uDate.before(now)); + } + +}