Skip to content

Commit

Permalink
feat: Add support for "holder" in VP.
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Nov 17, 2021
1 parent cd883df commit 3de3c20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public static void removeFromJsonLdObject(JsonLDObject jsonLdObject) {
* Getters
*/

@SuppressWarnings("unchecked")
public URI getIssuer() {
return JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetStringOrObjectId(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_ISSUER));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
import com.fasterxml.jackson.annotation.JsonCreator;
import foundation.identity.jsonld.JsonLDObject;
import foundation.identity.jsonld.JsonLDUtils;
import info.weboftrust.ldsignatures.LdProof;

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

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

private URI holder;
private VerifiableCredential verifiableCredential;
private LdProof ldProof;

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

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

return (VerifiablePresentation) this.jsonLdObject;
}

public B holder(URI holder) {
this.holder = holder;
return (B) this;
}

public B verifiableCredential(VerifiableCredential verifiableCredential) {
this.verifiableCredential = verifiableCredential;
return (B) this;
Expand Down Expand Up @@ -131,7 +139,10 @@ public static VerifiablePresentation fromVerifiableCredential(VerifiableCredenti
* Getters
*/

@SuppressWarnings("unchecked")
public URI getHolder() {
return JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetStringOrObjectId(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_HOLDER));
}

public VerifiableCredential getVerifiableCredential() {
return VerifiableCredential.getFromJsonLDObject(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class VerifiableCredentialKeywords {
public static final String JSONLD_TERM_CREDENTIALSUBJECT = "credentialSubject";

public static final String JSONLD_TERM_VERIFIABLE_PRESENTATION = "VerifiablePresentation";
public static final String JSONLD_TERM_HOLDER = "holder";
public static final String JSONLD_TERM_VERIFIABLECREDENTIAL = "verifiableCredential";

/*
Expand Down

0 comments on commit 3de3c20

Please sign in to comment.