Confusing error message in JWSHeader.java

Issue #360 resolved
Former user created an issue

JWSHeader.java has a very confusing error message when the algorithm doesn't match one of the supported algorithms:

// Get the "alg" parameter
Algorithm alg = Header.parseAlgorithm(jsonObject);

if (! (alg instanceof JWSAlgorithm)) {
    throw new ParseException("The algorithm \"alg\" header parameter must be for signatures", 0);
}

This error message doesn't indicate what went wrong. It should be changed to something clearer, for example:

if (! (alg instanceof JWSAlgorithm)) {
    throw new ParseException("The algorithm \"alg\" header parameter did not match a supported signature algorithm", 0);
}

Comments (1)

  1. Log in to comment