diff --git a/inspector-vc-web/pom.xml b/inspector-vc-web/pom.xml index 4dd572c..5de6ee3 100644 --- a/inspector-vc-web/pom.xml +++ b/inspector-vc-web/pom.xml @@ -6,7 +6,7 @@ org.1edtech vc-public-validator - 1.0.5 + 1.0.6 inspector-vc-web diff --git a/inspector-vc/pom.xml b/inspector-vc/pom.xml index 4870bbe..16a930d 100644 --- a/inspector-vc/pom.xml +++ b/inspector-vc/pom.xml @@ -5,7 +5,7 @@ org.1edtech vc-public-validator - 1.0.5 + 1.0.6 inspector-vc diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java index 9769561..b04a07f 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java @@ -354,4 +354,5 @@ public class Assertion extends Credential { private static final String ISSUED_ON_PROPERTY_NAME = "issuedOn"; private static final String EXPIRES_AT_PROPERTY_NAME = "expires"; public static final String JWT_NODE_NAME = ""; // empty because the whole payload is the assertion + public static final Boolean JWT_ALLOW_WHOLE_PAYLOAD = true; } 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 57f939a..c7719c4 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 @@ -91,6 +91,7 @@ public class OB20Inspector extends VCInspector { .put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB20) .put(Key.JSON_DOCUMENT_LOADER, documentLoader) .put(Key.JWT_CREDENTIAL_NODE_NAME, Assertion.JWT_NODE_NAME) + .put(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD, Assertion.JWT_ALLOW_WHOLE_PAYLOAD) .put(Key.URI_RESOURCE_FACTORY, uriResourceFactory) .build(); 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 3ee8523..5206507 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 @@ -99,6 +99,7 @@ public class OB30Inspector extends VCInspector implements SubInspector { .put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30) .put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30) .put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME) + .put(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD, VerifiableCredential.JWT_ALLOW_WHOLE_PAYLOAD) .build(); List accumulator = new ArrayList<>(); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java index dc1b3e3..cbbec84 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java @@ -234,6 +234,7 @@ public class VerifiableCredential extends Credential { private static final String EXPIRES_AT_PROPERTY_NAME_V11 = "expirationDate"; private static final String EXPIRES_AT_PROPERTY_NAME_V20 = "validUntil"; public static final String JWT_NODE_NAME = "vc"; + public static final Boolean JWT_ALLOW_WHOLE_PAYLOAD = true; public static final List REFRESH_SERVICE_MIME_TYPES = List.of(MimeType.JSON, MimeType.JSON_LD, MimeType.TEXT_PLAIN); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java index 5ffd4c1..3c0464e 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java @@ -57,6 +57,9 @@ public abstract class PayloadParser { return outerPayload; } JsonNode vcNode = outerPayload.get(nodeName); + if (vcNode == null && (Boolean) context.get(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD)) { + return outerPayload; + } return vcNode; } diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java index 8575ca7..9e75372 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java @@ -95,6 +95,15 @@ public class OB30Tests { assertDoesNotThrow(()->{ Report report = validator.run(Samples.OB30.PNG.SIMPLE_JWT_PNG.asFileResource()); if(verbose) PrintHelper.print(report, true); + assertValid(report); + }); + } + + @Test + void testSimpleV1PNGJWTValid() { + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB30.PNG.SIMPLE_V1_JWT_PNG.asFileResource()); + if(verbose) PrintHelper.print(report, true); // TODO: moved to warning due to: // - json schema validation error against canonical schema (json-ld schema validates) // - outdated context version @@ -117,10 +126,17 @@ public class OB30Tests { assertDoesNotThrow(()->{ Report report = validator.run(Samples.OB30.SVG.SIMPLE_JWT_SVG.asFileResource()); if(verbose) PrintHelper.print(report, true); - // TODO: moved to warning due to: + assertValid(report); + }); + } + + @Test + void testSimpleV1JsonSVGJWTValid() { + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB30.SVG.SIMPLE_V1_JWT_SVG.asFileResource()); + if(verbose) PrintHelper.print(report, true); // - json schema validation error against canonical schema (json-ld schema validates) // - outdated context version - // assertValid(report); assertWarning(report); }); } diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java index 3a2176f..a2b174b 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java @@ -7,6 +7,7 @@ public class Samples { public static final class SVG { public final static Sample SIMPLE_JSON_SVG = new Sample("ob30/simple-json.svg", true); public final static Sample SIMPLE_JWT_SVG = new Sample("ob30/simple-jwt.svg", true); + public final static Sample SIMPLE_V1_JWT_SVG = new Sample("ob30/simple-jwt_v1.svg", true); } public static final class JSON { public final static Sample COMPLETE_JSON = new Sample("ob30/complete.json", false); @@ -45,6 +46,7 @@ public class Samples { public static final class PNG { public final static Sample SIMPLE_JWT_PNG = new Sample("ob30/simple-jwt.png", true); public final static Sample SIMPLE_JSON_PNG = new Sample("ob30/simple-json.png", true); + public final static Sample SIMPLE_V1_JWT_PNG = new Sample("ob30/simple-jwt_v1.png", true); } public static final class JWT { public final static Sample SIMPLE_JWT = new Sample("ob30/simple.jwt", true); diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java index d0893e2..063245b 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java @@ -120,6 +120,7 @@ public class PayloadParserTests { .put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30) .put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30) .put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME) + .put(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD, VerifiableCredential.JWT_ALLOW_WHOLE_PAYLOAD) .build(); } } diff --git a/inspector-vc/src/test/resources/ob30/simple-jwt.png b/inspector-vc/src/test/resources/ob30/simple-jwt.png index 7211f53..f410de8 100644 Binary files a/inspector-vc/src/test/resources/ob30/simple-jwt.png and b/inspector-vc/src/test/resources/ob30/simple-jwt.png differ diff --git a/inspector-vc/src/test/resources/ob30/simple-jwt.svg b/inspector-vc/src/test/resources/ob30/simple-jwt.svg index 1f1d17f..5e12b1e 100644 --- a/inspector-vc/src/test/resources/ob30/simple-jwt.svg +++ b/inspector-vc/src/test/resources/ob30/simple-jwt.svg @@ -1,7 +1,7 @@ - + diff --git a/inspector-vc/src/test/resources/ob30/simple-jwt_v1.png b/inspector-vc/src/test/resources/ob30/simple-jwt_v1.png new file mode 100644 index 0000000..5617872 Binary files /dev/null and b/inspector-vc/src/test/resources/ob30/simple-jwt_v1.png differ diff --git a/inspector-vc/src/test/resources/ob30/simple-jwt_v1.svg b/inspector-vc/src/test/resources/ob30/simple-jwt_v1.svg new file mode 100644 index 0000000..a071e48 --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/simple-jwt_v1.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f498fc0..9a8b7e3 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.1edtech vc-public-validator - 1.0.5 + 1.0.6 vc-public-validator pom @@ -22,7 +22,7 @@ 11 2.17.2 false - 1.0.6 + 1.0.7