Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error log improvements & handle jwksinfo null instance #12105

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,18 @@
}
}
return JWTUtil.verifyTokenSignature(signedJWT, certificateAlias);
} catch (ParseException | JOSEException | IOException e) {
log.error("Error while parsing JWT", e);
} catch (ParseException e) {
log.error("Error while parsing JWKS information", e);

Check warning on line 171 in components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java#L170-L171

Added lines #L170 - L171 were not covered by tests
throw new APIManagementException("Error while parsing JWT", e);
} catch (JOSEException e) {
log.error("Error while verifying token signature", e);
throw new APIManagementException("Error while parsing JWT", e);
} catch (IOException e) {
log.error("Error while connecting to JWKS endpoint", e);
throw new APIManagementException("Error while parsing JWT", e);
} catch (APIManagementException e) {
log.error("Error while retrieving JWKS information", e);
throw new APIManagementException(e.getMessage(), e);

Check warning on line 181 in components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java#L173-L181

Added lines #L173 - L181 were not covered by tests
}

}
Expand Down Expand Up @@ -220,11 +229,15 @@
jwtValidationInfo.setJti(jwtClaimsSet.getJWTID());
}

private JWKSet retrieveJWKSet() throws IOException, ParseException {
private JWKSet retrieveJWKSet() throws IOException, ParseException, APIManagementException {

String jwksInfo = JWTUtil
.retrieveJWKSConfiguration(tokenIssuer.getJwksConfigurationDTO().getUrl());
jwkSet = JWKSet.parse(jwksInfo);
if (jwksInfo != null) {
jwkSet = JWKSet.parse(jwksInfo);
} else {
throw new APIManagementException("Invalid JWKS endpoint.");

Check warning on line 239 in components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/jwt/JWTValidatorImpl.java#L239

Added line #L239 was not covered by tests
}
return jwkSet;
}
}
Loading