|
|
@@ -31,7 +31,9 @@ public class JwtTokenUtil implements Serializable { |
|
|
|
private static final long serialVersionUID = -2550185165626007488L; |
|
|
|
|
|
|
|
// * 60000 = 1 Min |
|
|
|
public static final long JWT_TOKEN_EXPIRED_TIME = 60000 * 14400; |
|
|
|
// public static final long JWT_TOKEN_EXPIRED_TIME = 60000 * 14400; |
|
|
|
public static final long JWT_TOKEN_EXPIRED_TIME = 60000 * 60; |
|
|
|
public static final long JWT_REFRESH_TOKEN_EXPIRED_TIME = 60000 * 90; |
|
|
|
public static final String AES_SECRET = "ffii"; |
|
|
|
public static final String TOKEN_SEPARATOR = "@@"; |
|
|
|
|
|
|
@@ -79,10 +81,10 @@ public class JwtTokenUtil implements Serializable { |
|
|
|
// Serialization(https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-3.1) |
|
|
|
// compaction of the JWT to a URL-safe string |
|
|
|
private String doGenerateToken(Map<String, Object> claims, String subject) { |
|
|
|
logger.info((new Date(System.currentTimeMillis() + JWT_TOKEN_EXPIRED_TIME)).toString()); |
|
|
|
// logger.info((new Date(System.currentTimeMillis() + JWT_TOKEN_EXPIRED_TIME)).toString()); |
|
|
|
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis())) |
|
|
|
.setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_EXPIRED_TIME)) |
|
|
|
.signWith(secretKey).compact(); |
|
|
|
.setExpiration(new Date(System.currentTimeMillis() + (JWT_TOKEN_EXPIRED_TIME))) |
|
|
|
.signWith(secretKey).compact(); |
|
|
|
} |
|
|
|
|
|
|
|
// validate token |
|
|
@@ -94,8 +96,10 @@ public class JwtTokenUtil implements Serializable { |
|
|
|
public RefreshToken createRefreshToken(String username) { |
|
|
|
RefreshToken refreshToken = new RefreshToken(); |
|
|
|
refreshToken.setUserName(username); |
|
|
|
refreshToken.setExpiryDate(Instant.now().plusMillis(JWT_TOKEN_EXPIRED_TIME * 60 * 24)); |
|
|
|
long instantNum = Instant.now().plusMillis(JWT_TOKEN_EXPIRED_TIME * 60 * 24).toEpochMilli(); |
|
|
|
// refreshToken.setExpiryDate(Instant.now().plusMillis(JWT_TOKEN_EXPIRED_TIME * 60 * 24)); |
|
|
|
refreshToken.setExpiryDate(Instant.now().plusMillis(JWT_REFRESH_TOKEN_EXPIRED_TIME)); |
|
|
|
// long instantNum = Instant.now().plusMillis(JWT_TOKEN_EXPIRED_TIME * 60 * 24).toEpochMilli(); |
|
|
|
long instantNum = Instant.now().plusMillis(JWT_REFRESH_TOKEN_EXPIRED_TIME).toEpochMilli(); |
|
|
|
refreshToken.setToken(AES.encrypt(username + TOKEN_SEPARATOR + instantNum, AES_SECRET)); |
|
|
|
return refreshToken; |
|
|
|
} |
|
|
|