Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Oct 24, 2024
1 parent bff81b7 commit 7f553a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,12 @@ private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, Par

// Check if user claims are present in access token.
JSONObject jwtJsonObject = new JSONObject(new String(Base64.decodeBase64(accessToken.split("\\.")[1])));
boolean assertion = false;
try {
Object emailClaim = jwtJsonObject.get(EMAIL_OIDC_CLAIM);
Assert.fail("Requested user claim (email) is present in the JWT access token.");
} catch (JSONException e) {
assertion = true;
Assert.assertTrue(true, "Requested user claim (email) is present in the JWT access token.");
}
Assert.assertTrue(assertion, "Requested user claim (email) is present in the JWT access token.");

// Get the user info from the ID token.
Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(EMAIL_OIDC_CLAIM).toString(), USER_EMAIL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, jav
"\\.")[1])));

// Check if user claims are present in access token.
boolean assertion = false;
try {
Object emailClaim = jwtJsonObject.get(EMAIL_OIDC_CLAIM);
Assert.fail("Requested user claim (email) is present in the JWT access token.");
} catch (JSONException e) {
assertion = true;
Assert.assertTrue(true, "Requested user claim (email) is present in the JWT access token.");
}
Assert.assertTrue(assertion, "Requested user claim (email) is present in the JWT access token.");

Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(EMAIL_OIDC_CLAIM), USER_EMAIL,
"Requested user claims is not returned back with the ID token.");
Expand Down

0 comments on commit 7f553a8

Please sign in to comment.