Last active
June 6, 2019 13:19
-
-
Save mgdelacroix/5f4cc7ffc04d4842efe9 to your computer and use it in GitHub Desktop.
Simple script testing JWT with groovy
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
@Grab("io.jsonwebtoken:jjwt:0.4") | |
import io.jsonwebtoken.Jwts | |
import static io.jsonwebtoken.SignatureAlgorithm.HS256 | |
def key = "2193872103019283092174917" | |
def token = Jwts.builder() | |
.setSubject("Hello World") | |
.signWith(HS256, key) | |
.compact() | |
def name = Jwts.parser() | |
.setSigningKey(key) | |
.parseClaimsJws(token) | |
.getBody() | |
.getSubject() | |
println "/********** REPORT **********/" | |
println " => Key: $key" | |
println " => Token: $token" | |
println " => Name: $name" | |
println "/****************************/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on JJWT library