From dbee83068f9458e4fc211a692c43c3e4c9fa266b Mon Sep 17 00:00:00 2001 From: Xavi Aracil Date: Fri, 9 Dec 2022 12:27:48 +0100 Subject: [PATCH] Got verification object from graph --- .../probe/VerificationDependenciesProbe.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/VerificationDependenciesProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/VerificationDependenciesProbe.java index 7e4136b..d563176 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/VerificationDependenciesProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/VerificationDependenciesProbe.java @@ -39,18 +39,30 @@ public class VerificationDependenciesProbe extends Probe ObjectMapper mapper = (ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER); JsonNode jsonNode = (mapper).readTree(jsonLdGeneratedObject.getJson()); - // TODO: get verification object from graph - String type = jsonNode.get("verification").get("type").asText().strip(); + JsonNode verificationNode = jsonNode.get("verification"); + 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)) { // get badge UriResource badgeUriResource = resolveUriResource(ctx, jsonNode.get("badge").asText().strip()); JsonLdGeneratedObject badgeObject = (JsonLdGeneratedObject) ctx.getGeneratedObject( JsonLDCompactionProve.getId(badgeUriResource)); - - // get issuer from badge JsonNode badgeNode = ((ObjectMapper) ctx.get(Key.JACKSON_OBJECTMAPPER)) .readTree(badgeObject.getJson()); + // get issuer from badge UriResource issuerUriResource = resolveUriResource(ctx, badgeNode.get("issuer").asText().strip()); JsonLdGeneratedObject issuerObject = (JsonLdGeneratedObject) ctx.getGeneratedObject(