Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix deprecated parser() and setSigningKey(java.security.Key) usage in JJWT 0.12.x? [closed]

I'm upgrading my Java/Kotlin project to use JJWT version 0.12.6, and I noticed that the methods Jwts.parser() and setSigningKey(Key) are now deprecated.

What I want:

How to correctly parse and validate JWT tokens using the latest JJWT API without deprecated methods.

What I've tried:

val claims = Jwts.parser()
    .setSigningKey(key)
    .parseClaimsJws(token)
    .body
like image 849
Md Esadulhaq Avatar asked Dec 09 '25 07:12

Md Esadulhaq


1 Answers

Since 0.12.0 to get all claims from Token (also to validate it):

private Claims getAllClaimsFromToken(String token) {
    return Jwts.parser()
        .verifyWith(getPublicSigningKey())
        .build()
        .parseSignedClaims(token)
        .getPayload();
}
like image 74
Kimo_do Avatar answered Dec 11 '25 20:12

Kimo_do



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!