Skip to content

Commit

Permalink
fix JWT validation logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
dushaniw committed Feb 13, 2024
1 parent 9ced4f4 commit 124e8f7
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ public AuthenticationContext authenticate(SignedJWTInfo signedJWTInfo, MessageCo
String jwtTokenIdentifier = getJWTTokenIdentifier(signedJWTInfo);
String jwtHeader = signedJWTInfo.getSignedJWT().getHeader().toString();

long jwtGeneratedTime = 0;
try {
jwtGeneratedTime = signedJWTInfo.getSignedJWT().getJWTClaimsSet().getIssueTime().getTime();
} catch (ParseException e) {
log.error("Error while obtaining JWT token generated time certificate. "
+ GatewayUtils.getMaskedToken(jwtHeader));
}
// Check for CNF validation
if (!isCNFValidationDisabled(disableCNFValidation, false)) {
try {
Expand All @@ -187,6 +180,12 @@ public AuthenticationContext authenticate(SignedJWTInfo signedJWTInfo, MessageCo
}
Object authorizedPartyClaim = signedJWTInfo.getJwtClaimsSet().getClaim(APIMgtGatewayConstants.AZP_JWT_CLAIM);
Object entityIdClaim = signedJWTInfo.getJwtClaimsSet().getClaim(APIMgtGatewayConstants.ENTITY_ID_JWT_CLAIM);
long jwtGeneratedTime = 0;
try {
jwtGeneratedTime = signedJWTInfo.getSignedJWT().getJWTClaimsSet().getIssueTime().getTime();
} catch (ParseException e) {
log.error("Error while obtaining JWT token generated time " + GatewayUtils.getMaskedToken(jwtHeader));
}
if (jwtGeneratedTime != 0 && authorizedPartyClaim != null && entityIdClaim != null) {
String authorizedParty = (String) authorizedPartyClaim;
String entityId = (String) entityIdClaim;
Expand Down

0 comments on commit 124e8f7

Please sign in to comment.