Skip to content

Commit b574f50

Browse files
committed
fix: Allow multiple proofs on VC
1 parent a7930e7 commit b574f50

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
import java.io.Reader;
1313
import java.net.URI;
14-
import java.util.Date;
15-
import java.util.List;
16-
import java.util.Map;
14+
import java.util.*;
1715

1816
public class VerifiableCredential extends JsonLDObject {
1917

@@ -42,7 +40,7 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
4240
private Date expirationDate;
4341
private CredentialSubject credentialSubject;
4442
private CredentialStatus credentialStatus;
45-
private LdProof ldProof;
43+
private List<LdProof> ldProof;
4644

4745
public Builder(VerifiableCredential jsonLdObject) {
4846
super(jsonLdObject);
@@ -63,7 +61,7 @@ public VerifiableCredential build() {
6361
if (this.expirationDate != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_EXPIRATIONDATE, JsonLDUtils.dateToString(this.expirationDate));
6462
if (this.credentialSubject != null) this.credentialSubject.addToJsonLDObject(this.jsonLdObject);
6563
if (this.credentialStatus != null) this.credentialStatus.addToJsonLDObject(this.jsonLdObject);
66-
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLdObject);
64+
if (this.ldProof != null) this.ldProof.forEach(ldProof -> ldProof.addToJsonLDObject(this.jsonLdObject));
6765

6866
return (VerifiableCredential) this.jsonLdObject;
6967
}
@@ -94,7 +92,14 @@ public B credentialStatus(CredentialStatus credentialStatus) {
9492
}
9593

9694
public B ldProof(LdProof ldProof) {
97-
this.ldProof = ldProof;
95+
if (this.ldProof == null) this.ldProof = new ArrayList<>();
96+
this.ldProof.add(ldProof);
97+
return (B) this;
98+
}
99+
100+
public B ldProof(Collection<LdProof> ldProof) {
101+
if (this.ldProof == null) this.ldProof = new ArrayList<>();
102+
this.ldProof.addAll(ldProof);
98103
return (B) this;
99104
}
100105
}

0 commit comments

Comments
 (0)