Last active
October 4, 2017 22:24
-
-
Save verglor/724e2505879dad59714bdc842cc9a57e to your computer and use it in GitHub Desktop.
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.8.0') | |
import io.jsonwebtoken.* | |
def secret = 'SECRET' | |
def payload = [ | |
gid: "PLOM", // global facility id | |
uid: 123, // user id (if previously provided) | |
email: "[email protected]", // 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