Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created March 18, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/2b9ebc289d43dbfc0c92 to your computer and use it in GitHub Desktop.
Save abhirockzz/2b9ebc289d43dbfc0c92 to your computer and use it in GitHub Desktop.
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