Skip to content

Commit

Permalink
feat: updated store credential api
Browse files Browse the repository at this point in the history
  • Loading branch information
thackerronak committed Jun 12, 2023
1 parent 33135c1 commit f1e5289
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.eclipse.tractusx.ssi.lib.model.MultibaseString;
import org.eclipse.tractusx.ssi.lib.model.did.*;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredentialType;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
Expand Down Expand Up @@ -126,13 +127,13 @@ public Map<String, String> storeCredential(Map<String, Object> data, String iden
//check type
Validate.isTrue(verifiableCredential.getTypes().isEmpty()).launch(new BadDataException("Invalid types provided in credentials"));

if (verifiableCredential.getTypes().size() > 1) {
verifiableCredential.getTypes().remove("VerifiableCredential");
}
List<String> cloneTypes = new ArrayList<>(verifiableCredential.getTypes());
cloneTypes.remove(VerifiableCredentialType.VERIFIABLE_CREDENTIAL);

holdersCredentialRepository.save(HoldersCredential.builder()
.holderDid(wallet.getDid())
.issuerDid(URLDecoder.decode(verifiableCredential.getIssuer().toString(), Charset.defaultCharset()))
.type(verifiableCredential.getTypes().get(0))
.type(String.join(",", cloneTypes))
.data(verifiableCredential)
.selfIssued(false)
.stored(true) //credential is stored(not issued by MIW)
Expand Down

0 comments on commit f1e5289

Please sign in to comment.