/** * Gets a string array member of a JSON object. * * @param o The JSON object. Must not be {@code null}. * @param key The JSON object member key. Must not be {@code null}. * * @return The JSON object member value, may be {@code null}. * * @throws ParseException If the value is not of the expected type. */ public static String[] getStringArray(final JSONObject o, final String key) throws ParseException { JSONArray jsonArray = getJSONArray(o, key); if (jsonArray == null) { return null; } try { return jsonArray.toArray(new String[0]); } catch (ArrayStoreException e) { throw new ParseException("JSON object member with key \"" + key + "\" is not an array of strings", 0); } }
/** * Parses the optional X.509 certificate chain. * * @param o The JSON object to parse. Must not be {@code null}. * * @return The X.509 certificate chain (containing at least one * certificate) as a unmodifiable list, {@code null} if not * specified. * * @throws ParseException If parsing failed. */ static List<Base64> parseX509CertChain(final JSONObject o) throws ParseException { if (o.containsKey("x5c")) { List<Base64> chain = X509CertChainUtils.toBase64List(JSONObjectUtils.getJSONArray(o, "x5c")); if (chain.isEmpty()) { throw new ParseException("The X.509 certificate chain \"x5c\" must not be empty", 0); } return chain; } else { return null; } } }
throws ParseException { JSONArray keyArray = JSONObjectUtils.getJSONArray(json, "keys");
header = header.x509CertSHA256Thumbprint(new Base64URL(JSONObjectUtils.getString(jsonObject, name))); } else if("x5c".equals(name)) { header = header.x509CertChain(X509CertChainUtils.toBase64List(JSONObjectUtils.getJSONArray(jsonObject, name))); } else if("kid".equals(name)) { header = header.keyID(JSONObjectUtils.getString(jsonObject, name));
header = header.x509CertSHA256Thumbprint(new Base64URL(JSONObjectUtils.getString(jsonObject, name))); } else if("x5c".equals(name)) { header = header.x509CertChain(X509CertChainUtils.toBase64List(JSONObjectUtils.getJSONArray(jsonObject, name))); } else if("kid".equals(name)) { header = header.keyID(JSONObjectUtils.getString(jsonObject, name));
if (jsonObject.containsKey("oth")) { JSONArray arr = JSONObjectUtils.getJSONArray(jsonObject, "oth"); oth = new ArrayList<>(arr.size());