Skip to content

Commit

Permalink
Merge pull request #90 from smartSenseSolutions/fix/vc-builder-creden…
Browse files Browse the repository at this point in the history
…tial-status-issue

fix: missing credential status in builder
  • Loading branch information
borisrizov-zf authored Mar 21, 2024
2 parents c46c418 + 4ae905d commit caed90f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ maven/mavencentral/commons-digester/commons-digester/2.1, Apache-2.0, approved,
maven/mavencentral/commons-logging/commons-logging/1.2, Apache-2.0, approved, CQ10162
maven/mavencentral/commons-validator/commons-validator/1.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.setl/rdf-urdna/1.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/jakarta.json/jakarta.json-api/2.1.3, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7907
maven/mavencentral/jakarta.json/jakarta.json-api/2.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp
maven/mavencentral/net.i2p.crypto/eddsa/0.3.0, CC0-1.0, approved, CQ22537
maven/mavencentral/org.apache.commons/commons-lang3/3.14.0, Apache-2.0, approved, #11677
maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.77, MIT AND CC0-1.0, approved, #11595
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public VerifiableCredential build() {
if (expirationDate != null) {
map.put(VerifiableCredential.EXPIRATION_DATE, formatter.format(expirationDate));
}
if (credentialStatus != null) {
map.put(VerifiableCredential.CREDENTIAL_STATUS, credentialStatus);
}
if (proof != null) {
map.put(VerifiableCredential.PROOF, proof);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredentialSubject;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredentialType;
import org.eclipse.tractusx.ssi.lib.proof.transform.LinkedDataTransformer;
import org.eclipse.tractusx.ssi.lib.util.TestResourceUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -56,9 +57,13 @@ public void testLinkedDataTransformer() {
.issuer(URI.create("did:test:isser"))
.expirationDate(Instant.now().plusSeconds(3600))
.issuanceDate(Instant.now())
.verifiableCredentialStatus(TestResourceUtil.getStatusListEntry())
.credentialSubject(verifiableCredentialSubject)
.build();

// check status added in VC
Assertions.assertNotNull(credentialWithoutProof.getVerifiableCredentialStatus());

var transformedWithoutProof = linkedDataTransformer.transform(credentialWithoutProof);

final VerifiableCredential verifiableCredentialWithProof =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import org.bouncycastle.util.io.pem.PemReader;
import org.eclipse.tractusx.ssi.lib.model.did.Ed25519VerificationMethod;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredentialStatusList2021Entry;
import org.eclipse.tractusx.ssi.lib.model.verifiable.presentation.VerifiablePresentation;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils;

/** The type Test resource util. */
public class TestResourceUtil {
Expand Down Expand Up @@ -201,4 +203,18 @@ private static InputStream readResource(String resource) {

return Objects.requireNonNull(inputStream, "Resource not found: " + resource);
}

/**
* @return verifiableCredentialStatusList2021Entry
*/
public static VerifiableCredentialStatusList2021Entry getStatusListEntry() {
int index = RandomUtils.nextInt();
return new VerifiableCredentialStatusList2021Entry(
Map.of(
"id", "https://example.com/credentials/status/3#" + index,
"type", "BitstringStatusListEntry",
"statusPurpose", "revocation",
"statusListIndex", String.valueOf(index),
"statusListCredential", "https://example.com/credentials/status/3"));
}
}

0 comments on commit caed90f

Please sign in to comment.