Skip to content

Commit 124e8f7

Browse files
committed
fix JWT validation logic.
1 parent 9ced4f4 commit 124e8f7

File tree

1 file changed

+6
-7
lines changed
  • components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt

1 file changed

+6
-7
lines changed

components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt/JWTValidator.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,6 @@ public AuthenticationContext authenticate(SignedJWTInfo signedJWTInfo, MessageCo
157157
String jwtTokenIdentifier = getJWTTokenIdentifier(signedJWTInfo);
158158
String jwtHeader = signedJWTInfo.getSignedJWT().getHeader().toString();
159159

160-
long jwtGeneratedTime = 0;
161-
try {
162-
jwtGeneratedTime = signedJWTInfo.getSignedJWT().getJWTClaimsSet().getIssueTime().getTime();
163-
} catch (ParseException e) {
164-
log.error("Error while obtaining JWT token generated time certificate. "
165-
+ GatewayUtils.getMaskedToken(jwtHeader));
166-
}
167160
// Check for CNF validation
168161
if (!isCNFValidationDisabled(disableCNFValidation, false)) {
169162
try {
@@ -187,6 +180,12 @@ public AuthenticationContext authenticate(SignedJWTInfo signedJWTInfo, MessageCo
187180
}
188181
Object authorizedPartyClaim = signedJWTInfo.getJwtClaimsSet().getClaim(APIMgtGatewayConstants.AZP_JWT_CLAIM);
189182
Object entityIdClaim = signedJWTInfo.getJwtClaimsSet().getClaim(APIMgtGatewayConstants.ENTITY_ID_JWT_CLAIM);
183+
long jwtGeneratedTime = 0;
184+
try {
185+
jwtGeneratedTime = signedJWTInfo.getSignedJWT().getJWTClaimsSet().getIssueTime().getTime();
186+
} catch (ParseException e) {
187+
log.error("Error while obtaining JWT token generated time " + GatewayUtils.getMaskedToken(jwtHeader));
188+
}
190189
if (jwtGeneratedTime != 0 && authorizedPartyClaim != null && entityIdClaim != null) {
191190
String authorizedParty = (String) authorizedPartyClaim;
192191
String entityId = (String) entityIdClaim;

0 commit comments

Comments
 (0)