Pure Java implementation for JSON Web Token (JWT) [RFC7519]
// create a default header:
// e.g. {"typ":"JWT","alg":"HS256"}
Header header = Header.DEFAULT;
// create a payload
// e.g. {"iss":"RJ","aud":"you","exp":1483200000,"iat":1451577600,"name":"tester"}
Payload payload = new Payload();
// set some registed claims
payload.issuer = "RJ";
payload.audience = "you";
payload.issuedAt = ZonedDateTime.now().toEpochSecond();
payload.expires = ZonedDateTime.now().plusMonths(1).toEpochSecond();
// add your public/private claims
payload.add("name", "tester");
...
// sign and encode with the secret key
// eg. [header].[payload].[signature]
String jwt = new JWT(header, payload).encode("the-secret-key");
// verify and decode to a JWT instance
JWT jwt = JWT.decode("[header].[payload].[signature]", "the-secret-key");
// get your public/private claims value
String name = jwt.poyload.get("name");