Created
March 18, 2016 08:07
-
-
Save abhirockzz/2b9ebc289d43dbfc0c92 to your computer and use it in GitHub Desktop.
Snippet for JWT verification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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