Skip to content

Commit

Permalink
fix: add if statement for creating VC
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasalfiti committed Jan 16, 2024
1 parent fb499d0 commit 0092728
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ public VerifiableCredential issueCredential(Map<String, Object> data, String cal
// get Key
byte[] privateKeyBytes = walletKeyService.getPrivateKeyByWalletIdentifierAsBytes(issuerWallet.getId());

// check if the expiryDate is set
Date expiryDate = null;
if (verifiableCredential.getExpirationDate() != null) {
expiryDate = Date.from(verifiableCredential.getExpirationDate());
}
// Create Credential
HoldersCredential credential = CommonUtils.getHoldersCredential(verifiableCredential.getCredentialSubject().get(0),
verifiableCredential.getTypes(), issuerWallet.getDidDocument(),
privateKeyBytes, issuerWallet.getDid(),
verifiableCredential.getContext(), Date.from(verifiableCredential.getExpirationDate()), true);
verifiableCredential.getContext(), expiryDate, true);

//Store Credential in holder table
credential = create(credential);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,21 @@ private static VerifiableCredential createVerifiableCredential(DidDocument issue
contexts.add(jwsUri);
}

// check if the expiryDate is set
Instant expiryInstant = null;
if (expiryDate != null) {
expiryInstant = expiryDate.toInstant();
}

URI id = URI.create(UUID.randomUUID().toString());
VerifiableCredentialBuilder builder =
new VerifiableCredentialBuilder()
.context(contexts)
.id(URI.create(issuerDoc.getId() + "#" + id))
.type(verifiableCredentialType)
.issuer(issuerDoc.getId())
.expirationDate(expiryDate.toInstant())
.issuanceDate(Instant.now())
.credentialSubject(verifiableCredentialSubject);
VerifiableCredentialBuilder builder = new VerifiableCredentialBuilder()
.context(contexts)
.id(URI.create(issuerDoc.getId() + "#" + id))
.type(verifiableCredentialType)
.issuer(issuerDoc.getId())
.expirationDate(expiryInstant)
.issuanceDate(Instant.now())
.credentialSubject(verifiableCredentialSubject);


LinkedDataProofGenerator generator = LinkedDataProofGenerator.newInstance(SignatureType.JWS);
Expand Down

0 comments on commit 0092728

Please sign in to comment.