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 cebf818..84e1c9b 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 @@ -92,6 +92,7 @@ public abstract class Credential extends GeneratedObject { List getAllowedTypeValues(); boolean isAllowedTypeValuesRequired(); List getContextUris(); + String toString(); } public abstract static class Builder { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB20Inspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB20Inspector.java index 6c4a5cb..d812cb8 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB20Inspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB20Inspector.java @@ -136,7 +136,7 @@ public class OB20Inspector extends VCInspector { List validations = assertion.getValidations(); for (Validation validation : validations) { probeCount++; - accumulator.add(ValidationPropertyProbeFactory.of(validation).run(assertionNode, ctx)); + accumulator.add(ValidationPropertyProbeFactory.of(assertion.getCredentialType().toString(), validation).run(assertionNode, ctx)); if(broken(accumulator)) return abort(ctx, accumulator, probeCount); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/jsonld/probe/JsonLDCompactionProve.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/jsonld/probe/JsonLDCompactionProve.java index a934d46..b1b8946 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/jsonld/probe/JsonLDCompactionProve.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/jsonld/probe/JsonLDCompactionProve.java @@ -51,7 +51,7 @@ public class JsonLDCompactionProve extends Probe { return success(this, ctx); } catch (Exception e) { - return fatal("Error while parsing credential: " + e.getMessage(), ctx); + return fatal("Error while compacting JSON-LD: " + crd.getJson() + ". Caused by: " + e.getMessage(), ctx); } } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java index c6f9192..f0ec2ab 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java @@ -19,7 +19,7 @@ public class ContextPropertyProbe extends StringValuePropertyProbe { private final CredentialEnum type; public ContextPropertyProbe(CredentialEnum type) { - super(ID, "@context"); + super(ID, type.toString(), "@context"); this.type = checkNotNull(type); setValueValidations(this::validate); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/PropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/PropertyProbe.java index cd1232a..cde8cb5 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/PropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/PropertyProbe.java @@ -12,8 +12,8 @@ public class PropertyProbe extends Probe { private final String propertyName; private BiFunction validations; - public PropertyProbe(String id, String propertyName) { - super(id); + public PropertyProbe(String id, String typeName, String propertyName) { + super(id, typeName, propertyName); this.propertyName = propertyName; this.validations = this::defaultValidation; } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/StringValuePropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/StringValuePropertyProbe.java index 5a3ff3b..de249c9 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/StringValuePropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/StringValuePropertyProbe.java @@ -12,8 +12,8 @@ import com.fasterxml.jackson.databind.JsonNode; public class StringValuePropertyProbe extends PropertyProbe { private BiFunction, RunContext, ReportItems> valueValidations; - public StringValuePropertyProbe(String id, String propertyName) { - super(id, propertyName); + public StringValuePropertyProbe(String id, String credentialType, String propertyName) { + super(id, credentialType, propertyName); this.valueValidations = this::defaultValidation; super.setValidations(this::nodeValidation); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/TypePropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/TypePropertyProbe.java index b53f5bd..7814f46 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/TypePropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/TypePropertyProbe.java @@ -18,7 +18,7 @@ public class TypePropertyProbe extends StringValuePropertyProbe { private final CredentialEnum expected; public TypePropertyProbe(CredentialEnum expected) { - super(ID, "type"); + super(ID, expected.toString(), "type"); this.expected = checkNotNull(expected); this.setValueValidations(this::validate); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationImagePropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationImagePropertyProbe.java index b5cdbcd..e4123b4 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationImagePropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationImagePropertyProbe.java @@ -20,12 +20,12 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class ValidationImagePropertyProbe extends ValidationPropertyProbe { - public ValidationImagePropertyProbe(Validation validation) { - super(ID, validation); + public ValidationImagePropertyProbe(String credentialType, Validation validation) { + this(credentialType, validation, true); } - public ValidationImagePropertyProbe(Validation validation, boolean fullValidate) { - super(ID, validation, fullValidate); + public ValidationImagePropertyProbe(String credentialType, Validation validation, boolean fullValidate) { + super(ID, credentialType, validation, fullValidate); } @Override diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationIssuerPropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationIssuerPropertyProbe.java index a9ebb17..8eeb931 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationIssuerPropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationIssuerPropertyProbe.java @@ -16,12 +16,12 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class ValidationIssuerPropertyProbe extends ValidationPropertyProbe { - public ValidationIssuerPropertyProbe(Validation validation) { - super(ID, validation); + public ValidationIssuerPropertyProbe(String credentialType, Validation validation) { + this(credentialType, validation, true); } - public ValidationIssuerPropertyProbe(Validation validation, boolean fullValidate) { - super(ID, validation, fullValidate); + public ValidationIssuerPropertyProbe(String credentialType, Validation validation, boolean fullValidate) { + super(ID, credentialType, validation, fullValidate); } @Override diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbe.java index 8cb907d..b7fdc56 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbe.java @@ -37,22 +37,22 @@ import foundation.identity.jsonld.ConfigurableDocumentLoader; */ public class ValidationPropertyProbe extends PropertyProbe { protected final Validation validation; - protected final boolean fullValidate; // TODO: fullValidate + protected final boolean fullValidate; - public ValidationPropertyProbe(Validation validation) { - this(ID, validation, true); + public ValidationPropertyProbe(String credentialType, Validation validation) { + this(ID, credentialType, validation, true); } - public ValidationPropertyProbe(String id, Validation validation) { - this(id, validation, true); + public ValidationPropertyProbe(String id, String credentialType, Validation validation) { + this(id, credentialType, validation, true); } - public ValidationPropertyProbe(Validation validation, boolean fullValidate) { - this(ID, validation, fullValidate); + public ValidationPropertyProbe(String credentialType, Validation validation, boolean fullValidate) { + this(ID, credentialType, validation, fullValidate); } - public ValidationPropertyProbe(String id, Validation validation, boolean fullValidate) { - super(id + "<" + validation.getName() + ">", validation.getName()); + public ValidationPropertyProbe(String id, String credentialType, Validation validation, boolean fullValidate) { + super(id, credentialType, validation.getName()); this.validation = validation; this.fullValidate = fullValidate; setValidations(this::validate); @@ -170,7 +170,7 @@ public class ValidationPropertyProbe extends PropertyProbe { private ReportItems validatePrerequisites(JsonNode node, RunContext ctx) { List results = validation.getPrerequisites().stream() - .map(v -> ValidationPropertyProbeFactory.of(v, validation.isFullValidate())) + .map(v -> ValidationPropertyProbeFactory.of(validation.getName(), v, validation.isFullValidate())) .map(probe -> { try { return probe.run(node, ctx); @@ -186,7 +186,7 @@ public class ValidationPropertyProbe extends PropertyProbe { private ReportItems validateExpectedTypes(JsonNode node, RunContext ctx) { List results = validation.getExpectedTypes().stream() .flatMap(type -> type.getValidations().stream()) - .map(v -> ValidationPropertyProbeFactory.of(v, validation.isFullValidate())) + .map(v -> ValidationPropertyProbeFactory.of(validation.getName(), v, validation.isFullValidate())) .map(probe -> { try { return probe.run(node, ctx); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java index a88266b..917ef2b 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java @@ -3,6 +3,8 @@ package org.oneedtech.inspect.vc.probe.validation; import static org.oneedtech.inspect.util.code.Defensives.checkNotNull; import org.oneedtech.inspect.vc.Assertion.ValueType; +import org.oneedtech.inspect.vc.Credential.CredentialEnum; +import org.oneedtech.inspect.vc.Assertion; import org.oneedtech.inspect.vc.Validation; /** @@ -10,21 +12,21 @@ import org.oneedtech.inspect.vc.Validation; * @author xaracil */ public class ValidationPropertyProbeFactory { - public static ValidationPropertyProbe of(Validation validation) { - return of(validation, true); + public static ValidationPropertyProbe of(String type, Validation validation) { + return of(type, validation, true); } - public static ValidationPropertyProbe of(Validation validation, boolean fullValidate) { + public static ValidationPropertyProbe of(String type, Validation validation, boolean fullValidate) { checkNotNull(validation.getType()); if (validation.getType() == ValueType.RDF_TYPE) { - return new ValidationRdfTypePropertyProbe(validation, fullValidate); + return new ValidationRdfTypePropertyProbe(type, validation, fullValidate); } if (validation.getType() == ValueType.IMAGE) { - return new ValidationImagePropertyProbe(validation); + return new ValidationImagePropertyProbe(type, validation); } if (validation.getType() == ValueType.ISSUER) { - return new ValidationIssuerPropertyProbe(validation); + return new ValidationIssuerPropertyProbe(type, validation); } - return new ValidationPropertyProbe(validation, fullValidate); + return new ValidationPropertyProbe(type, validation, fullValidate); } } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationRdfTypePropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationRdfTypePropertyProbe.java index 60bbc15..5443752 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationRdfTypePropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationRdfTypePropertyProbe.java @@ -19,12 +19,12 @@ import com.fasterxml.jackson.databind.node.TextNode; * @author xaracil */ public class ValidationRdfTypePropertyProbe extends ValidationPropertyProbe { - public ValidationRdfTypePropertyProbe(Validation validation) { - super(ID, validation); + public ValidationRdfTypePropertyProbe(String credentialType, Validation validation ) { + this(credentialType, validation, true); } - public ValidationRdfTypePropertyProbe(Validation validation, boolean fullValidate) { - super(ID, validation, fullValidate); + public ValidationRdfTypePropertyProbe(String credentialType, Validation validation, boolean fullValidate) { + super(ID, credentialType, validation, fullValidate); } @Override