Skip to content

Commit 3de3c20

Browse files
committed
feat: Add support for "holder" in VP.
1 parent cd883df commit 3de3c20

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ public static void removeFromJsonLdObject(JsonLDObject jsonLdObject) {
134134
* Getters
135135
*/
136136

137-
@SuppressWarnings("unchecked")
138137
public URI getIssuer() {
139138
return JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetStringOrObjectId(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_ISSUER));
140139
}

src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
66
import com.fasterxml.jackson.annotation.JsonCreator;
77
import foundation.identity.jsonld.JsonLDObject;
8+
import foundation.identity.jsonld.JsonLDUtils;
89
import info.weboftrust.ldsignatures.LdProof;
910

1011
import java.io.Reader;
@@ -33,6 +34,7 @@ protected VerifiablePresentation(Map<String, Object> jsonObject) {
3334

3435
public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B> {
3536

37+
private URI holder;
3638
private VerifiableCredential verifiableCredential;
3739
private LdProof ldProof;
3840

@@ -50,12 +52,18 @@ public VerifiablePresentation build() {
5052
super.build();
5153

5254
// add JSON-LD properties
55+
if (this.holder != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_HOLDER, JsonLDUtils.uriToString(this.holder));
5356
if (this.verifiableCredential != null) this.verifiableCredential.addToJsonLDObject(this.jsonLdObject);
5457
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLdObject);
5558

5659
return (VerifiablePresentation) this.jsonLdObject;
5760
}
5861

62+
public B holder(URI holder) {
63+
this.holder = holder;
64+
return (B) this;
65+
}
66+
5967
public B verifiableCredential(VerifiableCredential verifiableCredential) {
6068
this.verifiableCredential = verifiableCredential;
6169
return (B) this;
@@ -131,7 +139,10 @@ public static VerifiablePresentation fromVerifiableCredential(VerifiableCredenti
131139
* Getters
132140
*/
133141

134-
@SuppressWarnings("unchecked")
142+
public URI getHolder() {
143+
return JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetStringOrObjectId(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_HOLDER));
144+
}
145+
135146
public VerifiableCredential getVerifiableCredential() {
136147
return VerifiableCredential.getFromJsonLDObject(this);
137148
}

src/main/java/com/danubetech/verifiablecredentials/jsonld/VerifiableCredentialKeywords.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class VerifiableCredentialKeywords {
1414
public static final String JSONLD_TERM_CREDENTIALSUBJECT = "credentialSubject";
1515

1616
public static final String JSONLD_TERM_VERIFIABLE_PRESENTATION = "VerifiablePresentation";
17+
public static final String JSONLD_TERM_HOLDER = "holder";
1718
public static final String JSONLD_TERM_VERIFIABLECREDENTIAL = "verifiableCredential";
1819

1920
/*

0 commit comments

Comments
 (0)