以下のメソッドを変更した。
- SecretKey key = Keys.secretKeyFor(SignatureAlgorithm.HS512);
+ SecretKey key = Jwts.SIG.HS512.key().build();
- Claims claims = Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token).getBody();
+ Claims claims = Jwts.parser().verifyWith(key).build().parseSignedClaims(token).getPayload();
Jwts.builder()
- .setClaims(claims)
- .setSubject(username)
- .setIssuedAt(createdDate)
- .setExpiration(expirationDate)
+ .claims(claims)
+ .subject(username)
+ .issuedAt(createdDate)
+ .expiration(expirationDate)
.signWith(key)
.compact();
0.12.0はバグがあるので注意!
https://github.com/jwtk/jjwt/issues/854
class io.jsonwebtoken.impl.lang.OptionalMethodInvoker cannot access class sun.security.util.KeyUtil (in module java.base) because module java.base does not export sun.security.util to unnamed module