Set option to return whole JWT payload as credential
This commit is contained in:
parent
3d643b579b
commit
7608773cd8
@ -354,4 +354,5 @@ public class Assertion extends Credential {
|
|||||||
private static final String ISSUED_ON_PROPERTY_NAME = "issuedOn";
|
private static final String ISSUED_ON_PROPERTY_NAME = "issuedOn";
|
||||||
private static final String EXPIRES_AT_PROPERTY_NAME = "expires";
|
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 String JWT_NODE_NAME = ""; // empty because the whole payload is the assertion
|
||||||
|
public static final Boolean JWT_ALLOW_WHOLE_PAYLOAD = true;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class OB20Inspector extends VCInspector {
|
|||||||
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB20)
|
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB20)
|
||||||
.put(Key.JSON_DOCUMENT_LOADER, documentLoader)
|
.put(Key.JSON_DOCUMENT_LOADER, documentLoader)
|
||||||
.put(Key.JWT_CREDENTIAL_NODE_NAME, Assertion.JWT_NODE_NAME)
|
.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)
|
.put(Key.URI_RESOURCE_FACTORY, uriResourceFactory)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
|||||||
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30)
|
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30)
|
||||||
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
|
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
|
||||||
.put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME)
|
.put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME)
|
||||||
|
.put(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD, VerifiableCredential.JWT_ALLOW_WHOLE_PAYLOAD)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<ReportItems> accumulator = new ArrayList<>();
|
List<ReportItems> accumulator = new ArrayList<>();
|
||||||
|
@ -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_V11 = "expirationDate";
|
||||||
private static final String EXPIRES_AT_PROPERTY_NAME_V20 = "validUntil";
|
private static final String EXPIRES_AT_PROPERTY_NAME_V20 = "validUntil";
|
||||||
public static final String JWT_NODE_NAME = "vc";
|
public static final String JWT_NODE_NAME = "vc";
|
||||||
|
public static final Boolean JWT_ALLOW_WHOLE_PAYLOAD = true;
|
||||||
public static final List<MimeType> REFRESH_SERVICE_MIME_TYPES =
|
public static final List<MimeType> REFRESH_SERVICE_MIME_TYPES =
|
||||||
List.of(MimeType.JSON, MimeType.JSON_LD, MimeType.TEXT_PLAIN);
|
List.of(MimeType.JSON, MimeType.JSON_LD, MimeType.TEXT_PLAIN);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@ public abstract class PayloadParser {
|
|||||||
return outerPayload;
|
return outerPayload;
|
||||||
}
|
}
|
||||||
JsonNode vcNode = outerPayload.get(nodeName);
|
JsonNode vcNode = outerPayload.get(nodeName);
|
||||||
|
if (vcNode == null && (Boolean) context.get(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD)) {
|
||||||
|
return outerPayload;
|
||||||
|
}
|
||||||
|
|
||||||
return vcNode;
|
return vcNode;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,7 @@ public class PayloadParserTests {
|
|||||||
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30)
|
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30)
|
||||||
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
|
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
|
||||||
.put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME)
|
.put(Key.JWT_CREDENTIAL_NODE_NAME, VerifiableCredential.JWT_NODE_NAME)
|
||||||
|
.put(Key.JWT_CREDENTIAL_ALLOW_WHOLE_PAYLOAD, VerifiableCredential.JWT_ALLOW_WHOLE_PAYLOAD)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user