Skip to content

Instantly share code, notes, and snippets.

@verglor
Last active October 4, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verglor/724e2505879dad59714bdc842cc9a57e to your computer and use it in GitHub Desktop.
Save verglor/724e2505879dad59714bdc842cc9a57e to your computer and use it in GitHub Desktop.
@Grab('io.jsonwebtoken:jjwt:0.8.0')
import io.jsonwebtoken.*
def secret = 'SECRET'
def payload = [
gid: "PLOM", // global facility id
uid: 123, // user id (if previously provided)
email: "jozko@mrkvicka.sk", // user email
firstName: "Jožko", // user first name
lastName: "Mrkvička", // user last name
phone: "+420666123456", // user phone
rid: 123, // reservation id
exp: System.currentTimeSeconds() + 15*60, // reservation expiration timestamp
title: 'Balík apartmán premium wellness', // package title
desc: 'Luxusný pobyt na 3 dni all inclusive s wellnessom', // package description
price: 123.45, // package price
cur: 'EUR' // currency of package price
]
def jwt = Jwts.builder().setClaims(payload).signWith(SignatureAlgorithm.HS256, secret.bytes).compressWith(CompressionCodecs.DEFLATE).compact()
println jwt
Jwts.parser().setSigningKey(secret.bytes).parseClaimsJws(jwt).body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment