Parse JWT strings, used to convert them into a JWT object representing the expanded JWT.
Javascript example:
try {
//add secret key here
var jwt = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzdWJqZWN0IiwiaXNzIjoiaXNzdWVyIiwiaWF0IjoxNTc0NzY0NTc2LCJqdGkiOiJteUlEIn0.D4MG4GhAop3BZVxWkyFchYcH_cy1aSiucMzkyCRStp0';
var SECRET_KEY = "This is my very secret key that is at least 32 bytes long!!";
var key = system.securityManager.getKeyManager().generateHMACSecretKey(KeyManager.SIGNATURE_HS256, SECRET_KEY);
var parsedJWT = system.securityManager.jwtManager.parseJWT(jwt);
if(parsedJWT.verifyHMAC(key))
{
var subject = parsedJWT.getSubject();
var iss = parsedJWT.getIssuer();
var id = parsedJWT.getJWTId();
log("JWTID: " + id); //Outputs JWTID: myId
}
else
{
throw 'JWT Signature is not verified!';
}
}
catch (e) {
event.getOwner().addErrorMessage("Error parsing JWT: " + e);
}
Javascript example: