Add required default-context value to VerifiableCredential (#30959)
closes #30958 Signed-off-by: Pascal Knüppel <pascal.knueppel@governikus.de>
This commit is contained in:
parent
96234d42cf
commit
4028ada2a5
2 changed files with 13 additions and 2 deletions
|
@ -38,8 +38,16 @@ import java.util.Map;
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class VerifiableCredential {
|
||||
|
||||
public static final String VC_CONTEXT_V1 = "https://www.w3.org/ns/credentials/v1";
|
||||
public static final String VC_CONTEXT_V2 = "https://www.w3.org/ns/credentials/v2";
|
||||
|
||||
/**
|
||||
* @context: The value of the @context property MUST be an ordered set where the first item is a URL with the
|
||||
* value https://www.w3.org/ns/credentials/v2. Subsequent items in the ordered set MUST be composed of any
|
||||
* combination of URLs and/or objects, where each is processable as a JSON-LD Context.
|
||||
*/
|
||||
@JsonProperty("@context")
|
||||
private List<String> context;
|
||||
private List<String> context = new ArrayList<>(List.of(VC_CONTEXT_V1));
|
||||
private List<String> type = new ArrayList<>();
|
||||
private URI issuer;
|
||||
private Date issuanceDate;
|
||||
|
|
|
@ -374,6 +374,9 @@ public class OID4VCIssuerEndpointTest extends OID4VCTest {
|
|||
assertNotNull("A valid credential string should have been responded", jsonWebToken);
|
||||
assertNotNull("The credentials should be included at the vc-claim.", jsonWebToken.getOtherClaims().get("vc"));
|
||||
VerifiableCredential credential = objectMapper.convertValue(jsonWebToken.getOtherClaims().get("vc"), VerifiableCredential.class);
|
||||
assertNotNull("@context is a required VC property", credential.getContext());
|
||||
assertEquals(1, credential.getContext().size());
|
||||
assertEquals(VerifiableCredential.VC_CONTEXT_V1, credential.getContext().get(0));
|
||||
assertTrue("The static claim should be set.", credential.getCredentialSubject().getClaims().containsKey("VerifiableCredential"));
|
||||
assertFalse("Only mappers supported for the requested type should have been evaluated.", credential.getCredentialSubject().getClaims().containsKey("AnotherCredentialType"));
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue