Skip to content

Commit 29072b0

Browse files
committed
refactor: Use new library data-integrity-java
1 parent 76cd140 commit 29072b0

File tree

14 files changed

+92
-92
lines changed

14 files changed

+92
-92
lines changed

examples-ldp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Process finished with exit code 0
6060
signer.setCreated(new Date());
6161
signer.setProofPurpose(LDSecurityKeywords.JSONLD_TERM_ASSERTIONMETHOD);
6262
signer.setVerificationMethod(URI.create("did:example:76e12ec712ebc6f1c221ebfeb1f#keys-1"));
63-
LdProof ldProof = signer.sign(verifiableCredential);
63+
DataIntegrityProof dataIntegrityProof = signer.sign(verifiableCredential);
6464

6565
System.out.println(verifiableCredential.toJson(true));
6666

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@
200200
<dependency>
201201
<groupId>decentralized-identity</groupId>
202202
<artifactId>jsonld-common-java</artifactId>
203-
<version>1.12.0</version>
203+
<version>1.13-SNAPSHOT</version>
204204
</dependency>
205205
<dependency>
206-
<groupId>info.weboftrust</groupId>
207-
<artifactId>ld-signatures-java</artifactId>
208-
<version>1.11.0</version>
206+
<groupId>com.danubetech</groupId>
207+
<artifactId>data-integrity-java</artifactId>
208+
<version>1.12-SNAPSHOT</version>
209209
</dependency>
210210
<dependency>
211211
<groupId>com.nimbusds</groupId>

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.danubetech.verifiablecredentials;
22

33
import com.apicatalog.jsonld.loader.DocumentLoader;
4+
import com.danubetech.dataintegrity.DataIntegrityProof;
45
import com.danubetech.verifiablecredentials.credentialstatus.CredentialStatus;
56
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts;
67
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
78
import com.fasterxml.jackson.annotation.JsonCreator;
89
import foundation.identity.jsonld.JsonLDObject;
910
import foundation.identity.jsonld.JsonLDUtils;
10-
import info.weboftrust.ldsignatures.LdProof;
1111

1212
import java.io.Reader;
1313
import java.net.URI;
@@ -40,7 +40,7 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
4040
private Date expirationDate;
4141
private CredentialSubject credentialSubject;
4242
private CredentialStatus credentialStatus;
43-
private List<LdProof> ldProof;
43+
private List<DataIntegrityProof> dataIntegrityProof;
4444

4545
public Builder(VerifiableCredential jsonLdObject) {
4646
super(jsonLdObject);
@@ -61,7 +61,7 @@ public VerifiableCredential build() {
6161
if (this.expirationDate != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_EXPIRATIONDATE, JsonLDUtils.dateToString(this.expirationDate));
6262
if (this.credentialSubject != null) this.credentialSubject.addToJsonLDObject(this.jsonLdObject);
6363
if (this.credentialStatus != null) this.credentialStatus.addToJsonLDObject(this.jsonLdObject);
64-
if (this.ldProof != null) this.ldProof.forEach(ldProof -> ldProof.addToJsonLDObject(this.jsonLdObject));
64+
if (this.dataIntegrityProof != null) this.dataIntegrityProof.forEach(dataIntegrityProof -> dataIntegrityProof.addToJsonLDObject(this.jsonLdObject));
6565

6666
return (VerifiableCredential) this.jsonLdObject;
6767
}
@@ -91,15 +91,15 @@ public B credentialStatus(CredentialStatus credentialStatus) {
9191
return (B) this;
9292
}
9393

94-
public B ldProof(LdProof ldProof) {
95-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
96-
this.ldProof.add(ldProof);
94+
public B dataIntegrityProof(DataIntegrityProof dataIntegrityProof) {
95+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
96+
this.dataIntegrityProof.add(dataIntegrityProof);
9797
return (B) this;
9898
}
9999

100-
public B ldProof(Collection<LdProof> ldProof) {
101-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
102-
this.ldProof.addAll(ldProof);
100+
public B dataIntegrityProof(Collection<DataIntegrityProof> dataIntegrityProof) {
101+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
102+
this.dataIntegrityProof.addAll(dataIntegrityProof);
103103
return (B) this;
104104
}
105105
}
@@ -162,12 +162,12 @@ public CredentialSubject getCredentialSubject() {
162162
return CredentialSubject.getFromJsonLDObject(this);
163163
}
164164

165-
public LdProof getLdProof() {
166-
return LdProof.getFromJsonLDObject(this);
165+
public DataIntegrityProof getDataIntegrityProof() {
166+
return DataIntegrityProof.getFromJsonLDObject(this);
167167
}
168168

169-
public List<LdProof> getLdProofAsList() {
170-
return LdProof.getFromJsonLDObjectAsList(this);
169+
public List<DataIntegrityProof> getDataIntegrityProofAsList() {
170+
return DataIntegrityProof.getFromJsonLDObjectAsList(this);
171171
}
172172

173173
public CredentialStatus getCredentialStatus() {

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.danubetech.verifiablecredentials;
22

33
import com.apicatalog.jsonld.loader.DocumentLoader;
4+
import com.danubetech.dataintegrity.DataIntegrityProof;
45
import com.danubetech.verifiablecredentials.credentialstatus.CredentialStatus;
56
import com.danubetech.verifiablecredentials.extensions.CredentialSchema;
67
import com.danubetech.verifiablecredentials.extensions.Evidence;
@@ -11,7 +12,6 @@
1112
import com.fasterxml.jackson.annotation.JsonCreator;
1213
import foundation.identity.jsonld.JsonLDObject;
1314
import foundation.identity.jsonld.JsonLDUtils;
14-
import info.weboftrust.ldsignatures.LdProof;
1515

1616
import java.io.Reader;
1717
import java.net.URI;
@@ -46,7 +46,7 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
4646
private List<CredentialStatus> credentialStatus;
4747
private String name;
4848
private String description;
49-
private List<LdProof> ldProof;
49+
private List<DataIntegrityProof> dataIntegrityProof;
5050

5151
//extensions
5252

@@ -76,7 +76,7 @@ public VerifiableCredentialV2 build() {
7676
if (this.credentialStatus != null) this.credentialStatus.forEach(credentialStatus -> credentialStatus.addToJsonLDObject(this.jsonLdObject));
7777
if (this.name != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_NAME, this.name);
7878
if (this.description != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_NAME, this.description);
79-
if (this.ldProof != null) this.ldProof.forEach(ldProof -> ldProof.addToJsonLDObject(this.jsonLdObject));
79+
if (this.dataIntegrityProof != null) this.dataIntegrityProof.forEach(dataIntegrityProof -> dataIntegrityProof.addToJsonLDObject(this.jsonLdObject));
8080

8181
// add extensions
8282
if (this.credentialSchema != null) this.credentialSchema.forEach(credentialSchema -> credentialSchema.addToJsonLDObject(this.jsonLdObject));
@@ -134,15 +134,15 @@ public B description(String description) {
134134
return (B) this;
135135
}
136136

137-
public B ldProof(LdProof ldProof) {
138-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
139-
this.ldProof.add(ldProof);
137+
public B dataIntegrityProof(DataIntegrityProof dataIntegrityProof) {
138+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
139+
this.dataIntegrityProof.add(dataIntegrityProof);
140140
return (B) this;
141141
}
142142

143-
public B ldProof(Collection<LdProof> ldProof) {
144-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
145-
this.ldProof.addAll(ldProof);
143+
public B dataIntegrityProof(Collection<DataIntegrityProof> dataIntegrityProof) {
144+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
145+
this.dataIntegrityProof.addAll(dataIntegrityProof);
146146
return (B) this;
147147
}
148148

@@ -274,12 +274,12 @@ public String getDescription(){
274274
return JsonLDUtils.jsonLdGetString(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_DESCRIPTION);
275275
}
276276

277-
public LdProof getLdProof() {
278-
return LdProof.getFromJsonLDObject(this);
277+
public DataIntegrityProof getDataIntegrityProof() {
278+
return DataIntegrityProof.getFromJsonLDObject(this);
279279
}
280280

281-
public List<LdProof> getLdProofAsList() {
282-
return LdProof.getFromJsonLDObjectAsList(this);
281+
public List<DataIntegrityProof> getDataIntegrityProofAsList() {
282+
return DataIntegrityProof.getFromJsonLDObjectAsList(this);
283283
}
284284

285285
public CredentialSchema getCredentialSchema() {

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.danubetech.verifiablecredentials;
22

33
import com.apicatalog.jsonld.loader.DocumentLoader;
4+
import com.danubetech.dataintegrity.DataIntegrityProof;
45
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts;
56
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
67
import com.fasterxml.jackson.annotation.JsonCreator;
78
import foundation.identity.jsonld.JsonLDObject;
89
import foundation.identity.jsonld.JsonLDUtils;
9-
import info.weboftrust.ldsignatures.LdProof;
1010

1111
import java.io.Reader;
1212
import java.net.URI;
@@ -39,7 +39,7 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
3939

4040
private URI holder;
4141
private List<VerifiableCredential> verifiableCredential;
42-
private List<LdProof> ldProof;
42+
private List<DataIntegrityProof> dataIntegrityProof;
4343

4444
public Builder(VerifiablePresentation jsonLdObject) {
4545
super(jsonLdObject);
@@ -57,7 +57,7 @@ public VerifiablePresentation build() {
5757
// add JSON-LD properties
5858
if (this.holder != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_HOLDER, JsonLDUtils.uriToString(this.holder));
5959
if (this.verifiableCredential != null) this.verifiableCredential.forEach(verifiableCredential -> verifiableCredential.addToJsonLDObject(this.jsonLdObject));
60-
if (this.ldProof != null) this.ldProof.forEach(ldProof -> ldProof.addToJsonLDObject(this.jsonLdObject));
60+
if (this.dataIntegrityProof != null) this.dataIntegrityProof.forEach(dataIntegrityProof -> dataIntegrityProof.addToJsonLDObject(this.jsonLdObject));
6161

6262
return (VerifiablePresentation) this.jsonLdObject;
6363
}
@@ -79,15 +79,15 @@ public B verifiableCredential(Collection<VerifiableCredential> verifiableCredent
7979
return (B) this;
8080
}
8181

82-
public B ldProof(LdProof ldProof) {
83-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
84-
this.ldProof.add(ldProof);
82+
public B dataIntegrityProof(DataIntegrityProof dataIntegrityProof) {
83+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
84+
this.dataIntegrityProof.add(dataIntegrityProof);
8585
return (B) this;
8686
}
8787

88-
public B ldProof(Collection<LdProof> ldProof) {
89-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
90-
this.ldProof.addAll(ldProof);
88+
public B dataIntegrityProof(Collection<DataIntegrityProof> dataIntegrityProof) {
89+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
90+
this.dataIntegrityProof.addAll(dataIntegrityProof);
9191
return (B) this;
9292
}
9393
}
@@ -156,11 +156,11 @@ public String getJwtVerifiableCredentialString() {
156156
return null;
157157
}
158158

159-
public LdProof getLdProof() {
160-
return LdProof.getFromJsonLDObject(this);
159+
public DataIntegrityProof getDataIntegrityProof() {
160+
return DataIntegrityProof.getFromJsonLDObject(this);
161161
}
162162

163-
public List<LdProof> getLdProofAsList() {
164-
return LdProof.getFromJsonLDObjectAsList(this);
163+
public List<DataIntegrityProof> getDataIntegrityProofAsList() {
164+
return DataIntegrityProof.getFromJsonLDObjectAsList(this);
165165
}
166166
}

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.danubetech.verifiablecredentials;
22

33
import com.apicatalog.jsonld.loader.DocumentLoader;
4+
import com.danubetech.dataintegrity.DataIntegrityProof;
45
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts;
56
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
67
import com.fasterxml.jackson.annotation.JsonCreator;
78
import foundation.identity.jsonld.JsonLDObject;
89
import foundation.identity.jsonld.JsonLDUtils;
9-
import info.weboftrust.ldsignatures.LdProof;
1010

1111
import java.io.Reader;
1212
import java.net.URI;
@@ -39,7 +39,7 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
3939

4040
private URI holder;
4141
private List<VerifiableCredentialV2> verifiableCredential;
42-
private List<LdProof> ldProof;
42+
private List<DataIntegrityProof> dataIntegrityProof;
4343

4444
public Builder(VerifiablePresentationV2 jsonLdObject) {
4545
super(jsonLdObject);
@@ -57,7 +57,7 @@ public VerifiablePresentationV2 build() {
5757
// add JSON-LD properties
5858
if (this.holder != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_HOLDER, JsonLDUtils.uriToString(this.holder));
5959
if (this.verifiableCredential != null) this.verifiableCredential.forEach(verifiableCredential -> verifiableCredential.addToJsonLDObject(this.jsonLdObject));
60-
if (this.ldProof != null) this.ldProof.forEach(ldProof -> ldProof.addToJsonLDObject(this.jsonLdObject));
60+
if (this.dataIntegrityProof != null) this.dataIntegrityProof.forEach(dataIntegrityProof -> dataIntegrityProof.addToJsonLDObject(this.jsonLdObject));
6161

6262
return (VerifiablePresentationV2) this.jsonLdObject;
6363
}
@@ -79,15 +79,15 @@ public B verifiableCredential(Collection<VerifiableCredentialV2> verifiableCrede
7979
return (B) this;
8080
}
8181

82-
public B ldProof(LdProof ldProof) {
83-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
84-
this.ldProof.add(ldProof);
82+
public B dataIntegrityProof(DataIntegrityProof dataIntegrityProof) {
83+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
84+
this.dataIntegrityProof.add(dataIntegrityProof);
8585
return (B) this;
8686
}
8787

88-
public B ldProof(Collection<LdProof> ldProof) {
89-
if (this.ldProof == null) this.ldProof = new ArrayList<>();
90-
this.ldProof.addAll(ldProof);
88+
public B dataIntegrityProof(Collection<DataIntegrityProof> dataIntegrityProof) {
89+
if (this.dataIntegrityProof == null) this.dataIntegrityProof = new ArrayList<>();
90+
this.dataIntegrityProof.addAll(dataIntegrityProof);
9191
return (B) this;
9292
}
9393
}
@@ -156,11 +156,11 @@ public String getJwtVerifiableCredentialString() {
156156
return null;
157157
}
158158

159-
public LdProof getLdProof() {
160-
return LdProof.getFromJsonLDObject(this);
159+
public DataIntegrityProof getDataIntegrityProof() {
160+
return DataIntegrityProof.getFromJsonLDObject(this);
161161
}
162162

163-
public List<LdProof> getLdProofAsList() {
164-
return LdProof.getFromJsonLDObjectAsList(this);
163+
public List<DataIntegrityProof> getDataIntegrityProofAsList() {
164+
return DataIntegrityProof.getFromJsonLDObjectAsList(this);
165165
}
166166
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import com.apicatalog.jsonld.document.JsonDocument;
55
import com.apicatalog.jsonld.http.media.MediaType;
66
import com.apicatalog.jsonld.loader.DocumentLoader;
7+
import com.danubetech.dataintegrity.jsonld.LDSecurityContexts;
78
import foundation.identity.jsonld.ConfigurableDocumentLoader;
8-
import info.weboftrust.ldsignatures.jsonld.LDSecurityContexts;
99

1010
import java.net.URI;
1111
import java.util.HashMap;

src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.danubetech.verifiablecredentials.jwt;
22

3+
import com.danubetech.dataintegrity.adapter.JWSSignerAdapter;
4+
import com.danubetech.dataintegrity.adapter.JWSVerifierAdapter;
35
import com.danubetech.keyformats.crypto.ByteSigner;
46
import com.danubetech.keyformats.crypto.ByteVerifier;
57
import com.danubetech.keyformats.crypto.impl.*;
68
import com.nimbusds.jose.*;
79
import com.nimbusds.jose.util.JSONObjectUtils;
810
import com.nimbusds.jwt.JWTClaimsSet;
9-
import info.weboftrust.ldsignatures.adapter.JWSSignerAdapter;
10-
import info.weboftrust.ldsignatures.adapter.JWSVerifierAdapter;
1111
import org.bitcoinj.core.ECKey;
1212
import org.erdtman.jcs.JsonCanonicalizer;
1313

src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.danubetech.verifiablecredentials.proof;
22

33
import com.apicatalog.jsonld.loader.DocumentLoader;
4+
import com.danubetech.dataintegrity.DataIntegrityProof;
5+
import com.danubetech.dataintegrity.jsonld.LDSecurityKeywords;
46
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts;
57
import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords;
68
import com.fasterxml.jackson.annotation.JsonCreator;
79
import foundation.identity.jsonld.JsonLDObject;
8-
import info.weboftrust.ldsignatures.LdProof;
9-
import info.weboftrust.ldsignatures.jsonld.LDSecurityKeywords;
1010

1111
import java.io.Reader;
1212
import java.net.URI;
1313
import java.util.Map;
1414

15-
public class BlockchainHashProof2020 extends LdProof {
15+
public class BlockchainHashProof2020 extends DataIntegrityProof {
1616

1717
public static final URI[] DEFAULT_JSONLD_CONTEXTS = { VerifiableCredentialContexts.JSONLD_CONTEXT_W3C_2018_CREDENTIALS_V1 };
1818
public static final String[] DEFAULT_JSONLD_TYPES = { VerifiableCredentialKeywords.JSONLD_TERM_BLOCKCHAIN_HASH_PROOF_2020 };
@@ -32,7 +32,7 @@ protected BlockchainHashProof2020(Map<String, Object> jsonObject) {
3232
* Factory methods
3333
*/
3434

35-
public static class Builder<B extends Builder<B>> extends LdProof.Builder<B> {
35+
public static class Builder<B extends Builder<B>> extends DataIntegrityProof.Builder<B> {
3636

3737
public Builder(BlockchainHashProof2020 jsonLdObject) {
3838
super(jsonLdObject);

src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public static void main(String[] args) throws Exception {
5858

5959
VerifiableCredential verifiableCredential = VerifiableCredential.fromJsonObject(jsonLdObject.getJsonObject());
6060
Validation.validate(verifiableCredential);
61-
if (verifiableCredential.getLdProof() == null) throw new IllegalStateException("No proof in VC");
61+
if (verifiableCredential.getDataIntegrityProof() == null) throw new IllegalStateException("No proof in VC");
6262
} else if (jsonLdObject.isType(VerifiablePresentation.DEFAULT_JSONLD_TYPES[0])) {
6363

6464
VerifiablePresentation verifiablePresentation = VerifiablePresentation.fromJsonObject(jsonLdObject.getJsonObject());
6565
Validation.validate(verifiablePresentation);
66-
if (verifiablePresentation.getLdProof() == null) throw new IllegalStateException("No proof in VP");
66+
if (verifiablePresentation.getDataIntegrityProof() == null) throw new IllegalStateException("No proof in VP");
6767
} else {
6868

6969
throw new IllegalStateException("Unknown JSON-LD object type: " + jsonLdObject.getTypes());

0 commit comments

Comments
 (0)