/**
* 校验JWT合法性
*/
public static Claims parseToken(String token){
if (token==null){
throw new LeaseException(ResultCodeEnum.ADMIN_LOGIN_AUTH);
}
try{
JwtParser jwtParser = Jwts.parserBuilder().setSigningKey(secretKey).build();
Jws<Claims> claimsJws = jwtParser.parseClaimsJws(token);
return claimsJws.getBody();
}catch (ExpiredJwtException e){
throw new LeaseException(ResultCodeEnum.TOKEN_EXPIRED);
}catch (JwtException e){
throw new LeaseException(ResultCodeEnum.TOKEN_INVALID);
}
}
其中jwtParser.parseClaimsJws(token);
此处是parseClaimsJws 而不是 parseClaimsJwt