From c911d332579f669f347dcec3399b430e685baaf0 Mon Sep 17 00:00:00 2001 From: aleksandra-bel Date: Tue, 19 Mar 2024 09:50:30 +0100 Subject: [PATCH] feat: adapt request and wallet service --- .../dto/CreateWalletRequest.java | 2 ++ .../service/WalletService.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/dto/CreateWalletRequest.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/dto/CreateWalletRequest.java index 6c6f4d62e..4dc5bfd31 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/dto/CreateWalletRequest.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/dto/CreateWalletRequest.java @@ -45,4 +45,6 @@ public class CreateWalletRequest { @NotBlank(message = "Please provide name") @Size(min = 1, max = 255, message = "Please provide valid name") private String name; + + private String didUrl; } 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 f309fd0f7..ebcdc2f8b 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java @@ -68,6 +68,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; import static org.eclipse.tractusx.managedidentitywallets.constant.StringPool.ED_25519; @@ -239,7 +240,7 @@ private Wallet createWallet(CreateWalletRequest request, boolean authority, Stri KeyPair keyPair = keyGenerator.generateKey(); //create did json - Did did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), request.getBpn()); + Did did = createDidJson(request); String keyId = UUID.randomUUID().toString(); @@ -274,12 +275,18 @@ private Wallet createWallet(CreateWalletRequest request, boolean authority, Stri Wallet issuerWallet = walletRepository.getByBpn(miwSettings.authorityWalletBpn()); - //issue BPN credentials - issuersCredentialService.issueBpnCredential(issuerWallet, wallet, authority); + //TODO: issue BPN credentials omitted, will be implemented in a separate step return wallet; } + private Did createDidJson(CreateWalletRequest request) { + String didUrl = request.getDidUrl(); + String bpn = request.getBpn(); + didUrl = Objects.isNull(didUrl) ? miwSettings.host() : didUrl; + return DidWebFactory.fromHostnameAndPath(didUrl, bpn); + } + /** * Create authority wallet on application start up, skip if already created. */