Skip to content

Instantly share code, notes, and snippets.

@mgdelacroix
Last active June 6, 2019 13:19
Show Gist options
  • Save mgdelacroix/5f4cc7ffc04d4842efe9 to your computer and use it in GitHub Desktop.
Save mgdelacroix/5f4cc7ffc04d4842efe9 to your computer and use it in GitHub Desktop.
Simple script testing JWT with groovy
@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 "/****************************/"
@mgdelacroix
Copy link
Author

Based on JJWT library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment