Код: Выделить всё
public class JwtTokenDecoder implements JwtDecoder {
private String secretKey = '123456789';
@SneakyThrows
@Override
public Jwt decode(String token) throws JwtException {
JwtParser build = Jwts.parser().verifyWith(getSigningKey()).build();
io.jsonwebtoken.Jwt parse = build.parse(token);
Map claims = JsonHelper.jsonMapper().convertValue(parse.getPayload(), new TypeReference() {
});
claims.put("iat", Instant.ofEpochSecond((long) claims.get("iat")));
claims.put("exp", Instant.ofEpochSecond((long) claims.get("exp")));
return Jwt.withTokenValue(token)
.headers((val) -> val.putAll(parse.getHeader()))
.claims((val) -> val.putAll(claims))
.build();
}
private SecretKey getSigningKey() {
byte[] keyBytes = secretKey.getBytes(StandardCharsets.UTF_8);
return Keys.hmacShaKeyFor(keyBytes);
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -algorithm