Created
July 28, 2015 20:24
-
-
Save theblang/5f3ceb8214c2e90c948f to your computer and use it in GitHub Desktop.
Decode JWT in Java without the secret using JJWT
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
String token = Jwts.builder() | |
.setExpiration(new Date()) | |
.setSubject("Joe") | |
.signWith(SignatureAlgorithm.HS512, MacProvider.generateKey()) | |
.compact(); | |
System.out.println(token); | |
String[] pieces = token.split("\\."); | |
System.out.println(pieces[1]); | |
try { | |
System.out.println(new String(DatatypeConverter.parseBase64Binary(pieces[1]), "UTF-8")); | |
} catch (UnsupportedEncodingException ex) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment