From fc6c07759d3f5adc4cd9c8be8684915a0a19f038 Mon Sep 17 00:00:00 2001 From: Mustafa Alsalfiti Date: Tue, 27 Feb 2024 14:40:26 +0100 Subject: [PATCH] fix: exceptions --- .../managedidentitywallets/service/CommonService.java | 2 -- .../managedidentitywallets/service/WalletService.java | 1 + .../tractusx/managedidentitywallets/utils/CommonUtils.java | 6 +----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/CommonService.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/CommonService.java index e30130142..178736ac2 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/CommonService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/CommonService.java @@ -23,14 +23,12 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.text.StringEscapeUtils; import org.eclipse.tractusx.managedidentitywallets.constant.StringPool; import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet; import org.eclipse.tractusx.managedidentitywallets.dao.repository.WalletRepository; import org.eclipse.tractusx.managedidentitywallets.exception.WalletNotFoundProblem; import org.eclipse.tractusx.managedidentitywallets.utils.CommonUtils; import org.eclipse.tractusx.managedidentitywallets.utils.Validate; -import org.eclipse.tractusx.ssi.lib.exception.did.DidParseException; import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential; import org.springframework.stereotype.Service; 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 7f118ef30..34d989198 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java @@ -237,6 +237,7 @@ private Wallet createWallet(CreateWalletRequest request, boolean authority, Stri //create private key pair IKeyGenerator keyGenerator = new X25519Generator(); + KeyPair keyPair = keyGenerator.generateKey(); //create did json diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/utils/CommonUtils.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/utils/CommonUtils.java index 7b3c058e3..a4a7eadb6 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/utils/CommonUtils.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/utils/CommonUtils.java @@ -31,7 +31,6 @@ import org.eclipse.tractusx.managedidentitywallets.constant.SupportedAlgorithms; import org.eclipse.tractusx.managedidentitywallets.dao.entity.HoldersCredential; import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet; -import org.eclipse.tractusx.managedidentitywallets.dao.entity.WalletKey; import org.eclipse.tractusx.managedidentitywallets.dto.SecureTokenRequest; import org.eclipse.tractusx.managedidentitywallets.exception.BadDataException; import org.eclipse.tractusx.managedidentitywallets.service.WalletKeyService; @@ -187,16 +186,13 @@ public static String vcAsJwt(Wallet issuerWallet, Wallet holderWallet, Verifiabl Did issuerDid = DidParser.parse(issuerWallet.getDid()); Did holderDid = DidParser.parse(holderWallet.getDid()); - - WalletKey walletKey = walletKeyService.get(issuerWallet.getId()); - + // JWT Factory SerializedJwtVCFactoryImpl vcFactory = new SerializedJwtVCFactoryImpl( new SignedJwtFactory(new OctetKeyPairFactory())); X25519PrivateKey privateKey = (X25519PrivateKey) walletKeyService.getPrivateKeyByWalletIdAndAlgorithm(issuerWallet.getId(), SupportedAlgorithms.ED25519); // JWT Factory - SignedJWT vcJWT = vcFactory.createVCJwt(issuerDid, holderDid, vc, privateKey, walletKeyService.getWalletKeyIdByWalletId(issuerWallet.getId())