Skip to content
Open
Show file tree
Hide file tree
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 @@ -213,7 +213,14 @@ public static boolean validateJWTSignatureWithPublicKey(String jwtString, String

try {
JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey) publicKey);
return SignedJWT.parse(jwtString).verify(verifier);
boolean isValid = SignedJWT.parse(jwtString).verify(verifier);
if (!isValid) {
log.error("Invalid JWT signature");
throw new OpenBankingException("Invalid JWT signature");
} else {
log.debug("Returning true since the JWT signature is valid.");
return true;
}
} catch (JOSEException | ParseException e) {
throw new OpenBankingException("Error occurred while validating JWT signature");
}
Comment on lines 224 to 226
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 1

Suggested change
} catch (JOSEException | ParseException e) {
throw new OpenBankingException("Error occurred while validating JWT signature");
}
} catch (JOSEException | ParseException e) {
log.error("Error occurred while validating JWT signature: " + e.getMessage());
throw new OpenBankingException("Error occurred while validating JWT signature");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ public Response validate(@Context HttpServletRequest request, @Context HttpServl
requestData = JWTUtils.decodeRequestJWT(payload, "body");
} catch (OpenBankingException e) {
log.error("Error while validating JWT signature", e);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, "Error while validating JWT " +
"signature");
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, e.getMessage());
} catch (ParseException e) {
log.error("Error while decoding validation JWT", e);
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, "Error while decoding validation JWT");
throw new ConsentException(ResponseStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}
} else {
try {
Expand Down