Got verification object from graph

This commit is contained in:
Xavi Aracil 2022-12-09 12:27:48 +01:00
parent 1133628f5f
commit dbee83068f

View File

@ -39,18 +39,30 @@ public class VerificationDependenciesProbe extends Probe<JsonLdGeneratedObject>
ObjectMapper mapper = (ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER); ObjectMapper mapper = (ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER);
JsonNode jsonNode = (mapper).readTree(jsonLdGeneratedObject.getJson()); JsonNode jsonNode = (mapper).readTree(jsonLdGeneratedObject.getJson());
// TODO: get verification object from graph JsonNode verificationNode = jsonNode.get("verification");
String type = jsonNode.get("verification").get("type").asText().strip(); checkNotNull(verificationNode);
String type = null;
if (verificationNode.isTextual()) {
// get verification from graph
UriResource verificationUriResource = resolveUriResource(ctx, verificationNode.asText().strip());
JsonLdGeneratedObject verificationObject = (JsonLdGeneratedObject) ctx.getGeneratedObject(
JsonLDCompactionProve.getId(verificationUriResource));
JsonNode verificationRootNode = ((ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER))
.readTree(verificationObject.getJson());
type = verificationRootNode.get("type").asText().strip();
} else {
type = verificationNode.get("type").asText().strip();
}
if ("HostedBadge".equals(type)) { if ("HostedBadge".equals(type)) {
// get badge // get badge
UriResource badgeUriResource = resolveUriResource(ctx, jsonNode.get("badge").asText().strip()); UriResource badgeUriResource = resolveUriResource(ctx, jsonNode.get("badge").asText().strip());
JsonLdGeneratedObject badgeObject = (JsonLdGeneratedObject) ctx.getGeneratedObject( JsonLdGeneratedObject badgeObject = (JsonLdGeneratedObject) ctx.getGeneratedObject(
JsonLDCompactionProve.getId(badgeUriResource)); JsonLDCompactionProve.getId(badgeUriResource));
// get issuer from badge
JsonNode badgeNode = ((ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER)) JsonNode badgeNode = ((ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER))
.readTree(badgeObject.getJson()); .readTree(badgeObject.getJson());
// get issuer from badge
UriResource issuerUriResource = resolveUriResource(ctx, badgeNode.get("issuer").asText().strip()); UriResource issuerUriResource = resolveUriResource(ctx, badgeNode.get("issuer").asText().strip());
JsonLdGeneratedObject issuerObject = (JsonLdGeneratedObject) ctx.getGeneratedObject( JsonLdGeneratedObject issuerObject = (JsonLdGeneratedObject) ctx.getGeneratedObject(