private JsonValue getValue(JsonObject operation) { JsonValue value = operation.get("value"); if (value == null) { missingMember(operation.getString("op"), "value"); } return value; }
final JsonValue jsonValue = packageJson.get("requires"); if (jsonValue.getValueType() != JsonValue.ValueType.OBJECT) { final JsonObjectBuilder requiresBuilder = Json.createObjectBuilder();
@Override public JsonValue get() { if (!contains()) { throw new JsonException(JsonMessages.NODEREF_OBJECT_MISSING(key)); } return object.get(key); }
String displayName = null; if (json.containsKey("name")) { final Object value = json.get("name"); if (value instanceof JsonString) { final String valueString = ((JsonString) value).getString(); final Object value = json.get("license"); if (value instanceof JsonString) { dependency.setLicense(json.getString("license"));
String evidenceStr = null; if (json.containsKey(key)) { final JsonValue value = json.get(key); if (value instanceof JsonString) { evidenceStr = ((JsonString) value).getString();
private static String getJsonString(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.STRING) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected string got %s", prop, ret.getValueType().name())); } return obj.getString(prop); }
private String resolveAlgorithm(JsonObject headers) { JsonString algClaim = (JsonString) headers.get("alg"); if (algClaim == null) { throw log.tokenRealmJwtSignatureInvalidAlgorithm("not_provided"); } String algorithm = algClaim.getString(); log.debugf("Token is using algorithm [%s]", algorithm); switch (algorithm) { case "RS256": return "SHA256withRSA"; case "RS384": return "SHA384withRSA"; case "RS512": return "SHA512withRSA"; default: throw log.tokenRealmJwtSignatureInvalidAlgorithm(algorithm); } }
private boolean hasValidAudience(JsonObject claims) throws RealmUnavailableException { if (this.audiences.isEmpty()) return true; JsonValue audience = claims.get("aud"); if (audience == null) { log.debug("Token does not contain an audience claim"); return false; } JsonArray audClaimArray; if (JsonValue.ValueType.STRING.equals(audience.getValueType())) { audClaimArray = Json.createArrayBuilder().add(audience).build(); } else { audClaimArray = (JsonArray) audience; } boolean valid = audClaimArray.stream() .map(jsonValue -> (JsonString) jsonValue) .anyMatch(audience1 -> audiences.contains(audience1.getString())); if (!valid) { log.debugf("Audience check failed. Provided [%s] but was expected [%s].", audClaimArray.toArray(), this.audiences); } return valid; }
private void diffObject(String path, JsonObject source, JsonObject target) { source.forEach((key, value) -> { if (target.containsKey(key)) { diff(path + '/' + key, value, target.get(key)); } else { builder.remove(path + '/' + key); } }); target.forEach((key, value) -> { if (! source.containsKey(key)) { builder.add(path + '/' + key, value); } }); }
builder.add(key, mergePatch(targetJsonObject.get(key), value)); } else { builder.add(key, mergePatch(JsonValue.EMPTY_JSON_OBJECT, value));
references[s-i-1] = NodeReference.of(object, tokens[i]); if (i < s-1) { value = object.get(tokens[i]); if (value == null) {
private static JsonObject getJsonObject(JsonObject object, String propName) { JsonObject obj = null; JsonValue val = object.get(propName); if (val != null && val.getValueType() == ValueType.OBJECT) { obj = val.asJsonObject(); } return obj; }
private static long getJsonLong(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.NUMBER) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected number got %s", prop, ret.getValueType().name())); } return Long.parseLong(ret.toString()); }
@Override public JsonValue get() { if (!contains()) { throw new JsonException(JsonMessages.NODEREF_OBJECT_MISSING(key)); } return object.get(key); }
private static int getJsonInt(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.NUMBER) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected number got %s", prop, ret.getValueType().name())); } return Integer.parseInt(ret.toString()); }
private static JsonObject getJsonObject(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.OBJECT) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected object got %s", prop, ret.getValueType().name())); } return ret.asJsonObject(); }
private static JsonArray getJsonArray(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.ARRAY) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected array got %s", prop, ret.getValueType().name())); } return ret.asJsonArray(); }