IDTokenClaimsSet idTokenClaimsSet = new IDTokenClaimsSet(issuer, subject, audList, expirationTime, issueTime);
Date authenticationTime = DateUtils.fromSecondsSinceEpoch(300000l);
idTokenClaimsSet.setAuthenticationTime(authenticationTime);
Nonce nonce = new Nonce();
idTokenClaimsSet.setNonce(nonce);
AccessTokenHash accessTokenHash = new AccessTokenHash("123");
idTokenClaimsSet.setAccessTokenHash(accessTokenHash);
CodeHash codeHash = new CodeHash("456");
idTokenClaimsSet.setCodeHash(codeHash);
ACR acr = new ACR("1");
idTokenClaimsSet.setACR(acr);
List<AMR> amrList = new LinkedList<>();
amrList.add(new AMR("A"));
idTokenClaimsSet.setAMR(amrList);
AuthorizedParty authorizedParty = new AuthorizedParty("azp");
idTokenClaimsSet.setAuthorizedParty(authorizedParty);
// Mandatory claims
assertEquals("iss", idTokenClaimsSet.getIssuer().getValue());
assertEquals("sub", idTokenClaimsSet.getSubject().getValue());
assertEquals("aud", idTokenClaimsSet.getAudience().get(0).getValue());
assertEquals(100000l, idTokenClaimsSet.getExpirationTime().getTime() / 1000);
assertEquals(200000l, idTokenClaimsSet.getIssueTime().getTime() / 1000);
// Optional claims
assertEquals(300000l, idTokenClaimsSet.getAuthenticationTime().getTime() / 1000);
assertEquals(nonce.getValue(), idTokenClaimsSet.getNonce().getValue());
assertEquals(accessTokenHash.getValue(), idTokenClaimsSet.getAccessTokenHash().getValue());
assertEquals(codeHash.getValue(), idTokenClaimsSet.getCodeHash().getValue());
assertEquals(acr.getValue(), idTokenClaimsSet.getACR().getValue());
assertEquals("A", idTokenClaimsSet.getAMR().get(0).getValue());
assertEquals(authorizedParty.getValue(), idTokenClaimsSet.getAuthorizedParty().getValue());
String json = idTokenClaimsSet.toJSONObject().toJSONString();
// Try to JWT claims set too
idTokenClaimsSet.toJWTClaimsSet();
idTokenClaimsSet = IDTokenClaimsSet.parse(json);
// Mandatory claims
assertEquals("iss", idTokenClaimsSet.getIssuer().getValue());
assertEquals("sub", idTokenClaimsSet.getSubject().getValue());
assertEquals("aud", idTokenClaimsSet.getAudience().get(0).getValue());
assertEquals(100000l, idTokenClaimsSet.getExpirationTime().getTime() / 1000);
assertEquals(200000l, idTokenClaimsSet.getIssueTime().getTime() / 1000);
// Optional claims
assertEquals(300000l, idTokenClaimsSet.getAuthenticationTime().getTime() / 1000);
assertEquals(nonce.getValue(), idTokenClaimsSet.getNonce().getValue());
assertEquals(accessTokenHash.getValue(), idTokenClaimsSet.getAccessTokenHash().getValue());
assertEquals(codeHash.getValue(), idTokenClaimsSet.getCodeHash().getValue());
assertEquals(acr.getValue(), idTokenClaimsSet.getACR().getValue());
assertEquals("A", idTokenClaimsSet.getAMR().get(0).getValue());
assertEquals(authorizedParty.getValue(), idTokenClaimsSet.getAuthorizedParty().getValue());