Build JJWT parsers with Jwts.parser()

Proprietary

Migrates Jwts.parserBuilder(), deprecated since JJWT 0.12, to Jwts.parser(), which returns a JwtParserBuilder since, and setSigningKey(..) to verifyWith(..). A String key is Base64 decoded and a byte[] key is used as an HMAC-SHA key, as before. setSigningKey(Key) is only changed when the key is declared as a SecretKey or PublicKey, which verifyWith(..) requires. Parsers built for unsecured JWTs (alg: none) with parseClaimsJwt(..) or parsePlaintextJwt(..) get unsecured(), which 0.12 requires to keep accepting them, as do parsers without a key, which could only parse unsecured JWTs before 0.12; these are marked with a warning for a security review. Keys converted from a String or byte[] are marked too, as 0.12 rejects keys that are shorter than required, or (from a String) not strictly Base64 encoded.

org.openrewrite.java.security.jjwt.MigrateJwtParser
mod run . --recipe=org.openrewrite.java.security.jjwt.MigrateJwtParser

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.