Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Snippet for JWT verification
//excpetion hanlding omitted for brevity
RsaJsonWebKey rsaJsonWebKey = getCachedRSAKey(); //should be the same as the one used to build the JWT previously
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setRequireSubject() // the JWT must have a subject claim
.setVerificationKey(rsaJsonWebKey.getKey()) // verify the signature with the public key
.build(); // create the JwtConsumer instance
JwtClaims jwtClaims = jwtConsumer.processToClaims(jwt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment