小修改
This commit is contained in:
@@ -7,7 +7,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -24,7 +23,6 @@ import java.util.Map;
|
||||
* HMACSHA512(base64UrlEncode(header) + "." +base64UrlEncode(payload),secret)
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
//@Component
|
||||
public class JwtTokenUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JwtTokenUtil.class);
|
||||
private static final String CLAIM_KEY_USERNAME = "sub";
|
||||
@@ -58,7 +56,7 @@ public class JwtTokenUtil {
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("JWT格式验证失败:{}",token);
|
||||
LOGGER.info("JWT格式验证失败:{}", token);
|
||||
}
|
||||
return claims;
|
||||
}
|
||||
@@ -77,7 +75,7 @@ public class JwtTokenUtil {
|
||||
String username;
|
||||
try {
|
||||
Claims claims = getClaimsFromToken(token);
|
||||
username = claims.getSubject();
|
||||
username = claims.getSubject();
|
||||
} catch (Exception e) {
|
||||
username = null;
|
||||
}
|
||||
@@ -124,13 +122,14 @@ public class JwtTokenUtil {
|
||||
/**
|
||||
* 判断token是否可以被刷新
|
||||
*/
|
||||
public boolean canRefresh(String token) {
|
||||
private boolean canRefresh(String token) {
|
||||
return !isTokenExpired(token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 当原来的token没过期是可以刷新
|
||||
*
|
||||
* @param oldToken 带tokenHead的token
|
||||
*/
|
||||
public String refreshHeadToken(String oldToken) {
|
||||
|
||||
Reference in New Issue
Block a user