Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@
@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;
Expand Down Expand Up @@ -127,4 +135,4 @@ public VerifiableCredential setAdditionalProperties(Map<String, Object> addition
this.additionalProperties = additionalProperties;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ public void testRequestCredential() {
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"));
}));
Expand Down