Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. String jwtString = getAccessTokenString(synCtx);
  2. try {
  3. AccessTokenVerifier jwtVerifier = JwtVerifiers.accessTokenVerifierBuilder()
  4. .setIssuer(issuerUrl)
  5. .setAudience(audience)
  6. .setConnectionTimeout(Duration.ofSeconds(1)) // defaults to 1000ms
  7. .setReadTimeout(Duration.ofSeconds(1)) // defaults to 1000ms
  8. .build();
  9. Jwt jwt= jwtVerifier.decode(jwtString);
  10.  
  11. System.out.println(jwt.getTokenValue()); // print the token
  12. System.out.println(jwt.getClaims().get("invalidKey")); // an invalid key just returns null
  13. System.out.println(jwt.getClaims().get("groups")); // handle an array value
  14. System.out.println(jwt.getExpiresAt()); // print the expiration time
  15.  
  16. return true;
  17. } catch (JwtVerificationException e) {
  18. // TODO Auto-generated catch block
  19. e.printStackTrace();
  20. return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement