From f1e5289abe321a7c1153bbbb831035821bf2f1a4 Mon Sep 17 00:00:00 2001 From: Ronak Thacker Date: Mon, 12 Jun 2023 12:10:40 +0530 Subject: [PATCH] feat: updated store credential api --- .../managedidentitywallets/service/WalletService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java index 0aab5de9f..0b55c00bd 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java @@ -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; @@ -126,13 +127,13 @@ public Map storeCredential(Map 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 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)