/** * Parses a JWS header from the specified JSON object. * * @param jsonObject The JSON object to parse. Must not be * {@code null}. * * @return The JWS header. * * @throws ParseException If the specified JSON object doesn't * represent a valid JWS header. */ public static JWSHeader parse(final JSONObject jsonObject) throws ParseException { return parse(jsonObject, null); }
/** * Parses a JWS header from the specified JSON object string. * * @param jsonString The JSON string to parse. Must not be * {@code null}. * * @return The JWS header. * * @throws ParseException If the specified JSON object string doesn't * represent a valid JWS header. */ public static JWSHeader parse(final String jsonString) throws ParseException { return parse(jsonString, null); }
/** * Parses a JWS header from the specified Base64URL. * * @param base64URL The Base64URL to parse. Must not be {@code null}. * * @return The JWS header. * * @throws ParseException If the specified Base64URL doesn't represent * a valid JWS header. */ public static JWSHeader parse(final Base64URL base64URL) throws ParseException { return parse(base64URL.decodeToString(), base64URL); } }
/** * Parses a JWS header from the specified JSON object string. * * @param jsonString The JSON string to parse. Must not be * {@code null}. * @param parsedBase64URL The original parsed Base64URL, {@code null} * if not applicable. * * @return The JWS header. * * @throws ParseException If the specified JSON object string doesn't * represent a valid JWS header. */ public static JWSHeader parse(final String jsonString, final Base64URL parsedBase64URL) throws ParseException { return parse(JSONObjectUtils.parse(jsonString), parsedBase64URL); }
this.header = JWSHeader.parse(firstPart);
/** * Parses a {@link PlainHeader}, {@link JWSHeader} or {@link JWEHeader} * from the specified JSON object. * * @param jsonObject The JSON object to parse. Must not be * {@code null}. * @param parsedBase64URL The original parsed Base64URL, {@code null} * if not applicable. * * @return The header. * * @throws ParseException If the specified JSON object doesn't * represent a valid header. */ public static Header parse(final JSONObject jsonObject, final Base64URL parsedBase64URL) throws ParseException { Algorithm alg = parseAlgorithm(jsonObject); if (alg.equals(Algorithm.NONE)) { return PlainHeader.parse(jsonObject, parsedBase64URL); } else if (alg instanceof JWSAlgorithm) { return JWSHeader.parse(jsonObject, parsedBase64URL); } else if (alg instanceof JWEAlgorithm) { return JWEHeader.parse(jsonObject, parsedBase64URL); } else { throw new AssertionError("Unexpected algorithm type: " + alg); } }
String receivedSigAlg = JWSHeader.parse(token.getHeader()).getAlgorithm().getName(); if (!receivedSigAlg.equals(expectedSigAlg)) { verified = false;