From cbb01013593e73661a96d682a3dc2e2e1791b6dd Mon Sep 17 00:00:00 2001 From: Richard Treier Date: Fri, 25 Oct 2024 13:52:23 +0200 Subject: [PATCH] feat: show cx config in dashboard --- docs/api/sovity-edc-api-wrapper.yaml | 50 +++++++------ .../api/ui/model/DashboardCxDidConfig.java | 26 +++++++ .../api/ui/model/DashboardMiwConfig.java | 20 ------ .../wrapper/api/ui/model/DashboardPage.java | 4 +- .../WrapperExtensionContextBuilder.java | 10 +-- .../dashboard/DashboardPageApiService.java | 6 +- .../services/CxDidConfigService.java | 70 +++++++++++++++++++ .../dashboard/services/MiwConfigService.java | 54 -------------- .../DashboardPageApiServiceTest.java | 19 +++-- 9 files changed, 147 insertions(+), 112 deletions(-) create mode 100644 extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardCxDidConfig.java delete mode 100644 extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardMiwConfig.java create mode 100644 extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/CxDidConfigService.java delete mode 100644 extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/MiwConfigService.java diff --git a/docs/api/sovity-edc-api-wrapper.yaml b/docs/api/sovity-edc-api-wrapper.yaml index 80d783835..5fc12b080 100644 --- a/docs/api/sovity-edc-api-wrapper.yaml +++ b/docs/api/sovity-edc-api-wrapper.yaml @@ -627,11 +627,11 @@ components: DataSourceType: type: string description: Supported Data Source Types by UiDataSource + default: CUSTOM enum: - HTTP_DATA - ON_REQUEST - CUSTOM - default: CUSTOM SecretValue: type: object properties: @@ -839,6 +839,7 @@ components: UiDataSourceHttpDataMethod: type: string description: Supported HTTP Methods by UiDataSource + default: GET enum: - GET - POST @@ -846,7 +847,6 @@ components: - PATCH - DELETE - OPTIONS - default: GET UiDataSourceOnRequest: required: - contactEmail @@ -1673,6 +1673,31 @@ components: state: $ref: "#/components/schemas/ContractNegotiationState" description: Contract Negotiation Information + DashboardCxDidConfig: + required: + - bdrsUrl + - dimUrl + - myDid + - trustedVcIssuer + - walletTokenUrl + type: object + properties: + myDid: + type: string + description: My DID / edc.iam.issuer.id + walletTokenUrl: + type: string + description: Wallet Token Url / edc.iam.sts.oauth.token.url + trustedVcIssuer: + type: string + description: Trusted VC Issuer / edc.iam.trusted-issuer.cofinity.id + bdrsUrl: + type: string + description: BDRS Url / tx.iam.iatp.bdrs.server.url + dimUrl: + type: string + description: STS DIM Url / edc.iam.sts.dim.url + description: Managed Identity Wallet (MIW) Config DashboardDapsConfig: required: - jwksUrl @@ -1686,23 +1711,6 @@ components: type: string description: Your Connector's DAPS JWKS URL description: DAPS Config - DashboardMiwConfig: - required: - - authorityId - - tokenUrl - - url - type: object - properties: - url: - type: string - description: Your Connector's MIW's URL - tokenUrl: - type: string - description: Your Connector's MIW's Token URL - authorityId: - type: string - description: Your Connector's MIW's Authority ID - description: Managed Identity Wallet (MIW) Config DashboardPage: required: - connectorCuratorName @@ -1772,8 +1780,8 @@ components: description: Your Connector's Maintainer's Organization Name connectorDapsConfig: $ref: "#/components/schemas/DashboardDapsConfig" - connectorMiwConfig: - $ref: "#/components/schemas/DashboardMiwConfig" + connectorCxDidConfig: + $ref: "#/components/schemas/DashboardCxDidConfig" description: Data as required by the UI's Dashboard Page DashboardTransferAmounts: required: diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardCxDidConfig.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardCxDidConfig.java new file mode 100644 index 000000000..b1b656bc3 --- /dev/null +++ b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardCxDidConfig.java @@ -0,0 +1,26 @@ +package de.sovity.edc.ext.wrapper.api.ui.model; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@NoArgsConstructor +@Schema(description = "Managed Identity Wallet (MIW) Config") +public class DashboardCxDidConfig { + @Schema(description = "My DID / edc.iam.issuer.id", requiredMode = Schema.RequiredMode.REQUIRED) + private String myDid; + + @Schema(description = "Wallet Token Url / edc.iam.sts.oauth.token.url", requiredMode = Schema.RequiredMode.REQUIRED) + private String walletTokenUrl; + + @Schema(description = "Trusted VC Issuer / edc.iam.trusted-issuer.cofinity.id", requiredMode = Schema.RequiredMode.REQUIRED) + private String trustedVcIssuer; + + @Schema(description = "BDRS Url / tx.iam.iatp.bdrs.server.url", requiredMode = Schema.RequiredMode.REQUIRED) + private String bdrsUrl; + + @Schema(description = "STS DIM Url / edc.iam.sts.dim.url", requiredMode = Schema.RequiredMode.REQUIRED) + private String dimUrl; +} diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardMiwConfig.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardMiwConfig.java deleted file mode 100644 index 05b24fa1d..000000000 --- a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardMiwConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.sovity.edc.ext.wrapper.api.ui.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.NoArgsConstructor; - - -@Data -@NoArgsConstructor -@Schema(description = "Managed Identity Wallet (MIW) Config") -public class DashboardMiwConfig { - @Schema(description = "Your Connector's MIW's URL", requiredMode = Schema.RequiredMode.REQUIRED) - private String url; - - @Schema(description = "Your Connector's MIW's Token URL", requiredMode = Schema.RequiredMode.REQUIRED) - private String tokenUrl; - - @Schema(description = "Your Connector's MIW's Authority ID", requiredMode = Schema.RequiredMode.REQUIRED) - private String authorityId; -} diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardPage.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardPage.java index 78056c9a7..490a8e087 100644 --- a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardPage.java +++ b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/DashboardPage.java @@ -64,6 +64,6 @@ public class DashboardPage { @Schema(description = "Your Connector's DAPS Configuration (if present)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private DashboardDapsConfig connectorDapsConfig; - @Schema(description = "Your Connector's MIW Configuration (if present)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - private DashboardMiwConfig connectorMiwConfig; + @Schema(description = "Your Connector's Catena-X Web-DID Configuration (if present)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private DashboardCxDidConfig connectorCxDidConfig; } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java index dff0e527f..0cbc20909 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java @@ -59,9 +59,9 @@ import de.sovity.edc.ext.wrapper.api.ui.pages.contract_negotiations.ContractNegotiationStateService; import de.sovity.edc.ext.wrapper.api.ui.pages.contract_negotiations.ContractOfferMapper; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.DashboardPageApiService; +import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.CxDidConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.DapsConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.DashboardDataFetcher; -import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.MiwConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.OwnConnectorEndpointServiceImpl; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.SelfDescriptionService; import de.sovity.edc.ext.wrapper.api.ui.pages.data_offer.DataOfferPageApiService; @@ -249,8 +249,8 @@ public static WrapperExtensionContext buildContext( contractNegotiationBuilder, contractNegotiationStateService ); - var miwConfigBuilder = new MiwConfigService(config); - var dapsConfigBuilder = new DapsConfigService(config); + var cxDidConfigService = new CxDidConfigService(config); + var dapsConfigService = new DapsConfigService(config); var dashboardDataFetcher = new DashboardDataFetcher( contractNegotiationStore, transferProcessService, @@ -261,8 +261,8 @@ public static WrapperExtensionContext buildContext( var dashboardApiService = new DashboardPageApiService( dashboardDataFetcher, transferProcessStateService, - dapsConfigBuilder, - miwConfigBuilder, + dapsConfigService, + cxDidConfigService, selfDescriptionService ); var alwaysTruePolicyService = new AlwaysTruePolicyDefinitionService( diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiService.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiService.java index 832c9c976..9aef2059d 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiService.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiService.java @@ -16,9 +16,9 @@ import de.sovity.edc.ext.wrapper.api.ui.model.DashboardPage; import de.sovity.edc.ext.wrapper.api.ui.model.DashboardTransferAmounts; +import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.CxDidConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.DapsConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.DashboardDataFetcher; -import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.MiwConfigService; import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.SelfDescriptionService; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferProcessStateService; import lombok.RequiredArgsConstructor; @@ -41,7 +41,7 @@ public class DashboardPageApiService { private final DashboardDataFetcher dashboardDataFetcher; private final TransferProcessStateService transferProcessStateService; private final DapsConfigService dapsConfigService; - private final MiwConfigService miwConfigService; + private final CxDidConfigService cxDidConfigService; private final SelfDescriptionService selfDescriptionService; @NotNull @@ -83,7 +83,7 @@ public DashboardPage dashboardPage() { dashboardPage.setConnectorMaintainerUrl(selfDescriptionService.getMaintainerUrl()); dashboardPage.setConnectorMaintainerName(selfDescriptionService.getMaintainerName()); - dashboardPage.setConnectorMiwConfig(miwConfigService.buildMiwConfigOrNull()); + dashboardPage.setConnectorCxDidConfig(cxDidConfigService.buildCxDidConfigOrNull()); dashboardPage.setConnectorDapsConfig(dapsConfigService.buildDapsConfigOrNull()); return dashboardPage; } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/CxDidConfigService.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/CxDidConfigService.java new file mode 100644 index 000000000..a5c5e6457 --- /dev/null +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/CxDidConfigService.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 sovity GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + +package de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services; + +import de.sovity.edc.ext.wrapper.api.ui.model.DashboardCxDidConfig; +import lombok.RequiredArgsConstructor; +import org.eclipse.edc.spi.system.configuration.Config; + +import static com.apicatalog.jsonld.StringUtils.isBlank; + +@RequiredArgsConstructor +public class CxDidConfigService { + private final Config config; + + /** + * Wallet Token Url + */ + private static final String EDC_IAM_STS_OAUTH_TOKEN_URL = "edc.iam.sts.oauth.token.url"; + + + /** + * Trusted VC Issuer + */ + private static final String EDC_IAM_TRUSTED_ISSUER_COFINITY_ID = "edc.iam.trusted-issuer.cofinity.id"; + + + /** + * BDRS Url + */ + + private static final String TX_IAM_IATP_BDRS_SERVER_URL = "tx.iam.iatp.bdrs.server.url"; + + + /** + * My DID + */ + private static final String EDC_IAM_ISSUER_ID = "edc.iam.issuer.id"; + + + /** + * DIM Url + */ + private static final String EDC_IAM_STS_DIM_URL = "edc.iam.sts.dim.url"; + + public DashboardCxDidConfig buildCxDidConfigOrNull() { + var cxDidConfig = new DashboardCxDidConfig(); + cxDidConfig.setMyDid(configValue(EDC_IAM_ISSUER_ID)); + cxDidConfig.setWalletTokenUrl(configValue(EDC_IAM_STS_OAUTH_TOKEN_URL)); + cxDidConfig.setTrustedVcIssuer(configValue(EDC_IAM_TRUSTED_ISSUER_COFINITY_ID)); + cxDidConfig.setDimUrl(configValue(EDC_IAM_STS_DIM_URL)); + cxDidConfig.setBdrsUrl(configValue(TX_IAM_IATP_BDRS_SERVER_URL)); + return isBlank(cxDidConfig.getMyDid()) ? null : cxDidConfig; + } + + private String configValue(String configKey) { + return config.getString(configKey, ""); + } +} diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/MiwConfigService.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/MiwConfigService.java deleted file mode 100644 index 61e6556f4..000000000 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/services/MiwConfigService.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 sovity GmbH - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * sovity GmbH - initial API and implementation - * - */ - -package de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services; - -import de.sovity.edc.ext.wrapper.api.ui.model.DashboardMiwConfig; -import lombok.RequiredArgsConstructor; -import org.eclipse.edc.spi.system.configuration.Config; - -import static com.apicatalog.jsonld.StringUtils.isBlank; - -@RequiredArgsConstructor -public class MiwConfigService { - private final Config config; - - private static final String MIW_AUTHORITY_ID = configKey("TX_SSI_MIW_AUTHORITY_ID"); - - private static final String MIW_URL = configKey("TX_SSI_MIW_URL"); - - private static final String MIW_TOKEN_URL = configKey("TX_SSI_OAUTH_TOKEN_URL"); - - public DashboardMiwConfig buildMiwConfigOrNull() { - var miwConfig = new DashboardMiwConfig(); - miwConfig.setUrl(configValue(MIW_URL)); - miwConfig.setAuthorityId(configValue(MIW_AUTHORITY_ID)); - miwConfig.setTokenUrl(configValue(MIW_TOKEN_URL)); - return isBlank(miwConfig.getUrl()) ? null : miwConfig; - } - - String configValue(String configKey) { - return config.getString(configKey, ""); - } - - /** - * Maps a {@literal CONFIG_KEY} to {@literal config.key} - * - * @param envVarKey {@literal CONFIG_KEY} - * @return {@literal config.key} - */ - public static String configKey(String envVarKey) { - return String.join(".", envVarKey.split("_")).toLowerCase(); - } -} diff --git a/tests/src/test/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiServiceTest.java b/tests/src/test/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiServiceTest.java index 08c5fc3ce..389f91c03 100644 --- a/tests/src/test/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiServiceTest.java +++ b/tests/src/test/java/de/sovity/edc/ext/wrapper/api/ui/pages/dashboard/DashboardPageApiServiceTest.java @@ -65,9 +65,12 @@ class DashboardPageApiServiceTest { .configOverrides(config -> config .property(CeConfigProps.EDC_OAUTH_TOKEN_URL, "https://token-url.daps") .property(CeConfigProps.EDC_OAUTH_PROVIDER_JWKS_URL, "https://jwks-url.daps") - .property("tx.ssi.oauth.token.url", "https://token.miw") - .property("tx.ssi.miw.url", "https://miw") - .property("tx.ssi.miw.authority.id", "my-authority-id")) + .property("edc.iam.sts.oauth.token.url", "tokenUrl") + .property("edc.iam.trusted-issuer.cofinity.id", "myTrustedIssuer") + .property("edc.iam.issuer.id", "myDid") + .property("tx.iam.iatp.bdrs.server.url", "bdrsUrl") + .property("edc.iam.sts.dim.url", "dimUrl") + ) .beforeEdcStartup(runtime -> { runtime.registerServiceMock(AssetIndex.class, assetIndex); runtime.registerServiceMock(PolicyDefinitionService.class, policyDefinitionService); @@ -143,10 +146,12 @@ void testConnectorMetadata(EdcClient client, Config config) { assertThat(dashboardPage.getConnectorDapsConfig().getTokenUrl()).isEqualTo("https://token-url.daps"); assertThat(dashboardPage.getConnectorDapsConfig().getJwksUrl()).isEqualTo("https://jwks-url.daps"); - assertThat(dashboardPage.getConnectorMiwConfig()).isNotNull(); - assertThat(dashboardPage.getConnectorMiwConfig().getAuthorityId()).isEqualTo("my-authority-id"); - assertThat(dashboardPage.getConnectorMiwConfig().getUrl()).isEqualTo("https://miw"); - assertThat(dashboardPage.getConnectorMiwConfig().getTokenUrl()).isEqualTo("https://token.miw"); + assertThat(dashboardPage.getConnectorCxDidConfig()).isNotNull(); + assertThat(dashboardPage.getConnectorCxDidConfig().getMyDid()).isEqualTo("myDid"); + assertThat(dashboardPage.getConnectorCxDidConfig().getWalletTokenUrl()).isEqualTo("tokenUrl"); + assertThat(dashboardPage.getConnectorCxDidConfig().getTrustedVcIssuer()).isEqualTo("myTrustedIssuer"); + assertThat(dashboardPage.getConnectorCxDidConfig().getBdrsUrl()).isEqualTo("bdrsUrl"); + assertThat(dashboardPage.getConnectorCxDidConfig().getDimUrl()).isEqualTo("dimUrl"); } private ContractNegotiation mockContractNegotiation(int contract, ContractNegotiation.Type type) {