Skip to content

Commit

Permalink
feat: updated issuer credential api and test cases as per new api spec
Browse files Browse the repository at this point in the history
  • Loading branch information
thackerronak committed Jun 7, 2023
1 parent 1ff463d commit ff20227
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public ResponseEntity<Map<String, Object>> credentialsValidation(@RequestBody Ma
}
"""))
})
public ResponseEntity<VerifiableCredential> issueCredential(@RequestBody Map<String, Object> data, Principal principal) {
return ResponseEntity.status(HttpStatus.CREATED).body(issuersCredentialService.issueCredentialUsingBaseWallet(data, getBPNFromToken(principal)));
public ResponseEntity<VerifiableCredential> issueCredential(@RequestParam String holderDid, @RequestBody Map<String, Object> data, Principal principal) {
return ResponseEntity.status(HttpStatus.CREATED).body(issuersCredentialService.issueCredentialUsingBaseWallet(holderDid, data, getBPNFromToken(principal)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ public VerifiableCredential issueMembershipCredential(IssueMembershipCredentialR
* @param callerBpn the caller bpn
* @return the verifiable credential
*/
public VerifiableCredential issueCredentialUsingBaseWallet(Map<String, Object> data, String callerBpn) {
public VerifiableCredential issueCredentialUsingBaseWallet(String holderDid, Map<String, Object> data, String callerBpn) {
//Fetch Holder Wallet
Wallet holderWallet = walletService.getWalletByIdentifier(holderDid);

VerifiableCredential verifiableCredential = new VerifiableCredential(data);

Wallet issuerWallet = walletService.getWalletByIdentifier(verifiableCredential.getIssuer().toString());
Expand All @@ -332,13 +335,13 @@ public VerifiableCredential issueCredentialUsingBaseWallet(Map<String, Object> d
// get Key
byte[] privateKeyBytes = walletKeyService.getPrivateKeyByWalletIdentifierAsBytes(issuerWallet.getId());

boolean isSelfIssued = isSelfIssued(issuerWallet.getBpn()); //TODO need to pass holder bpn
boolean isSelfIssued = isSelfIssued(holderWallet.getBpn());

// Create Credential
HoldersCredential holdersCredential = CommonUtils.getHoldersCredential(verifiableCredential.getCredentialSubject().get(0),
verifiableCredential.getTypes(), issuerWallet.getDidDocument(),
privateKeyBytes,
issuerWallet.getDid(), //TODO need to check, how we can identify holder of VC, need to m
holderWallet.getDid(),
verifiableCredential.getContext(), Date.from(verifiableCredential.getExpirationDate()), isSelfIssued);


Expand Down

0 comments on commit ff20227

Please sign in to comment.