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/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(); } }