@Test
    public void testValidateIdToken() throws Exception {
        algorithms.add(JWSAlgorithm.HS256);
        final TokenValidator validator = new TokenValidator(configuration, metadata);

        final JwtGenerator generator = new JwtGenerator(new SecretSignatureConfiguration(CLIENT_SECRET, JWSAlgorithm.HS256));
        final Map<String, Object> claims = new HashMap<>();
        claims.put("iss", PAC4J_URL);
        claims.put("sub", KEY);
        claims.put("aud", ID);
        final long now = new Date().getTime() / 1000;
        claims.put("exp", now + 1000);
        claims.put("iat", now);
        final Nonce nonce = new Nonce();
        claims.put("nonce", nonce.toString());
        final String idToken = generator.generate(claims);

        final IDTokenClaimsSet claimsSet = validator.validate(SignedJWT.parse(idToken), nonce);
        assertEquals(KEY, claimsSet.getSubject().toString());
        assertEquals(PAC4J_URL, claimsSet.getIssuer().toString());
        assertEquals(ID, claimsSet.getAudience().get(0).toString());
        assertNotNull(claimsSet.getExpirationTime());
        assertNotNull(claimsSet.getIssueTime());
        assertEquals(nonce, claimsSet.getNonce());
    }
Tests {@link TokenValidator}.

@author Jerome LELEU
@since 5.2.0
pac4j-oidc/src/test/java/org/pac4j/oidc/profile/creator/TokenValidatorTests.java