diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java index 3e73655..dce7153 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java @@ -45,7 +45,7 @@ public class Credential extends GeneratedObject { return resource; } - public JsonNode asJson() { + public JsonNode getJson() { return jsonData; } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java index a8af2c9..37c84af 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java @@ -8,7 +8,6 @@ import java.util.Map; import org.oneedtech.inspect.core.SubInspector; import org.oneedtech.inspect.core.probe.GeneratedObject; import org.oneedtech.inspect.core.probe.RunContext; -import org.oneedtech.inspect.core.probe.RunContext.Key; import org.oneedtech.inspect.core.probe.json.JsonPathEvaluator; import org.oneedtech.inspect.core.report.Report; import org.oneedtech.inspect.core.report.ReportItems; @@ -18,7 +17,7 @@ import org.oneedtech.inspect.util.resource.Resource; import com.fasterxml.jackson.databind.ObjectMapper; /** - * An inspector for EndersementCredential objects. + * An inspector for EndorsementCredential objects. * @author mgylling */ public class EndorsementInspector extends VCInspector implements SubInspector { @@ -30,7 +29,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector { @Override public Report run(Resource resource, Map parentObjects) { /* - * resource is the top-level credential that embeds the endorsement, we + * The resource param is the top-level credential that embeds the endorsement, we * expect parentObjects to provide a pointer to the JsonNode we should check */ Credential endorsement = (Credential) parentObjects.get(ENDORSEMENT_KEY); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java index d68c7e8..c1849f4 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java @@ -1,17 +1,15 @@ package org.oneedtech.inspect.vc; +import static com.google.common.base.Strings.isNullOrEmpty; import static java.lang.Boolean.TRUE; import static org.oneedtech.inspect.core.Inspector.Behavior.RESET_CACHES_ON_RUN; import static org.oneedtech.inspect.core.report.ReportUtil.onProbeException; import static org.oneedtech.inspect.util.json.ObjectMapperCache.Config.DEFAULT; -import static org.oneedtech.inspect.vc.EndorsementInspector.ENDORSEMENT_KEY; import static org.oneedtech.inspect.vc.util.JsonNodeUtil.getEndorsements; -import static com.google.common.base.Strings.isNullOrEmpty; import java.net.URI; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Optional; import org.oneedtech.inspect.core.probe.Outcome; @@ -92,15 +90,15 @@ public class OB30Inspector extends VCInspector { //validate the value of the type property probeCount++; - accumulator.add(new JsonArrayProbe(vcType).run(crd.asJson(), ctx)); + accumulator.add(new JsonArrayProbe(vcType).run(crd.getJson(), ctx)); probeCount++; - accumulator.add(new JsonArrayProbe(obType).run(crd.asJson(), ctx)); + accumulator.add(new JsonArrayProbe(obType).run(crd.getJson(), ctx)); if(broken(accumulator)) return abort(ctx, accumulator, probeCount); //validate against the canonical schema SchemaKey canonical = crd.getSchemaKey().orElseThrow(); probeCount++; - accumulator.add(new JsonSchemaProbe(canonical).run(crd.asJson(), ctx)); + accumulator.add(new JsonSchemaProbe(canonical).run(crd.getJson(), ctx)); //validate against any inline schemas probeCount++; @@ -148,7 +146,7 @@ public class OB30Inspector extends VCInspector { if(broken(accumulator)) return abort(ctx, accumulator, probeCount); //embedded endorsements - List endorsements = getEndorsements(crd.asJson(), jsonPath); + List endorsements = getEndorsements(crd.getJson(), jsonPath); if(endorsements.size() > 0) { EndorsementInspector subInspector = new EndorsementInspector.Builder().build(); for(JsonNode endorsementNode : endorsements) { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ExpirationVerifierProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ExpirationVerifierProbe.java index d2d5715..e511902 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ExpirationVerifierProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ExpirationVerifierProbe.java @@ -28,7 +28,7 @@ public class ExpirationVerifierProbe extends Probe { */ ZonedDateTime now = ZonedDateTime.now(); - JsonNode node = crd.asJson().get("expirationDate"); + JsonNode node = crd.getJson().get("expirationDate"); if(node != null) { ZonedDateTime expirationDate = null; try { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/InlineJsonSchemaProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/InlineJsonSchemaProbe.java index 01a0e26..94f6363 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/InlineJsonSchemaProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/InlineJsonSchemaProbe.java @@ -37,7 +37,7 @@ public class InlineJsonSchemaProbe extends Probe { // ArrayNode nodes = jsonPath.eval("$..*[?(@.credentialSchema)]", crd.getJson()); // note - we dont get deep nested ones in e.g. EndorsementCredential - JsonNode credentialSchemaNode = crd.asJson().get("credentialSchema"); + JsonNode credentialSchemaNode = crd.getJson().get("credentialSchema"); if(credentialSchemaNode == null) return success(ctx); ArrayNode schemas = (ArrayNode) credentialSchemaNode; //TODO guard this cast @@ -51,7 +51,7 @@ public class InlineJsonSchemaProbe extends Probe { if(ioErrors.contains(id)) continue; if(skipCanonical && equals(crd.getSchemaKey(), id)) continue; try { - accumulator.add(new JsonSchemaProbe(id).run(crd.asJson(), ctx)); + accumulator.add(new JsonSchemaProbe(id).run(crd.getJson(), ctx)); } catch (Exception e) { if(!ioErrors.contains(id)) { ioErrors.add(id); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/IssuanceVerifierProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/IssuanceVerifierProbe.java index 53875db..7eef25a 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/IssuanceVerifierProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/IssuanceVerifierProbe.java @@ -28,7 +28,7 @@ public class IssuanceVerifierProbe extends Probe { */ ZonedDateTime now = ZonedDateTime.now(); - JsonNode node = crd.asJson().get("issuanceDate"); + JsonNode node = crd.getJson().get("issuanceDate"); if(node != null) { ZonedDateTime issuanceDate = null; try { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ProofVerifierProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ProofVerifierProbe.java index e3073aa..a95b9f8 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ProofVerifierProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ProofVerifierProbe.java @@ -61,7 +61,7 @@ public class ProofVerifierProbe extends Probe { //clone the incoming credential object so we can modify it freely ObjectMapper mapper = (ObjectMapper)ctx.get(JACKSON_OBJECTMAPPER); - JsonNode copy = mapper.readTree(crd.asJson().toString()); + JsonNode copy = mapper.readTree(crd.getJson().toString()); //remove proof ((ObjectNode)copy).remove("proof"); @@ -69,7 +69,7 @@ public class ProofVerifierProbe extends Probe { //create JSON-P Json-LD instance JsonDocument jsonLdDoc = JsonDocument.of(new StringReader(copy.toString())); - //create rdf and normalize + //create rdf and normalize //TODO add DocumentLoader to cache contexts RdfDataset dataSet = JsonLd.toRdf(jsonLdDoc).ordered(true).get(); RdfDataset normalized = RdfNormalize.normalize(dataSet); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java index d491dc6..ca11b0f 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java @@ -36,7 +36,7 @@ public class RevocationListProbe extends Probe { * report a warning, not an error. */ - JsonNode credentialStatus = crd.asJson().get("credentialStatus"); + JsonNode credentialStatus = crd.getJson().get("credentialStatus"); if(credentialStatus != null) { JsonNode type = credentialStatus.get("type"); if(type != null && type.asText().strip().equals("1EdTechRevocationList")) { @@ -52,7 +52,7 @@ public class RevocationListProbe extends Probe { * credential's id is in the list of revokedCredentials and the value of * revoked is true or ommitted, the issuer has revoked the credential. */ - JsonNode crdID = crd.asJson().get("id"); + JsonNode crdID = crd.getJson().get("id"); //TODO these != checks sb removed (trigger warning) if(crdID != null) { List list = JsonNodeUtil.asNodeList(revocList.get("revokedCredentials")); if(list != null) {