diff --git a/edc-extensions/iatp/tx-iatp-sts-dim/src/main/java/org/eclipse/tractusx/edc/iam/iatp/sts/dim/DimStsConfigurationExtension.java b/edc-extensions/iatp/tx-iatp-sts-dim/src/main/java/org/eclipse/tractusx/edc/iam/iatp/sts/dim/DimStsConfigurationExtension.java index c02e004bd..ba17b9b45 100644 --- a/edc-extensions/iatp/tx-iatp-sts-dim/src/main/java/org/eclipse/tractusx/edc/iam/iatp/sts/dim/DimStsConfigurationExtension.java +++ b/edc-extensions/iatp/tx-iatp-sts-dim/src/main/java/org/eclipse/tractusx/edc/iam/iatp/sts/dim/DimStsConfigurationExtension.java @@ -26,7 +26,8 @@ import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.tractusx.edc.core.utils.PathUtils; -import static org.eclipse.tractusx.edc.core.utils.ConfigUtil.propertyCompatibility; +import static java.util.Optional.ofNullable; +import static org.eclipse.tractusx.edc.core.utils.ConfigUtil.missingMandatoryProperty; /** * Configuration Extension for the STS OAuth2 client @@ -35,19 +36,13 @@ public class DimStsConfigurationExtension implements ServiceExtension { @Setting(value = "STS OAuth2 endpoint for requesting a token") - public static final String TOKEN_URL = "tx.edc.iam.sts.oauth.token.url"; - @Deprecated(since = "0.7.1") - public static final String TOKEN_URL_DEPRECATED = "edc.iam.sts.oauth.token.url"; + public static final String TOKEN_URL = "edc.iam.sts.oauth.token.url"; @Setting(value = "STS OAuth2 client id") - public static final String CLIENT_ID = "tx.edc.iam.sts.oauth.client.id"; - @Deprecated(since = "0.7.1") - public static final String CLIENT_ID_DEPRECATED = "edc.iam.sts.oauth.client.id"; + public static final String CLIENT_ID = "edc.iam.sts.oauth.client.id"; @Setting(value = "Vault alias of STS OAuth2 client secret") - public static final String CLIENT_SECRET_ALIAS = "tx.edc.iam.sts.oauth.client.secret.alias"; - @Deprecated(since = "0.7.1") - public static final String CLIENT_SECRET_ALIAS_DEPRECATED = "edc.iam.sts.oauth.client.secret.alias"; + public static final String CLIENT_SECRET_ALIAS = "edc.iam.sts.oauth.client.secret.alias"; protected static final String NAME = "DIM STS client configuration extension"; @@ -60,12 +55,21 @@ public String name() { @Provider public StsRemoteClientConfiguration clientConfiguration(ServiceExtensionContext context) { - var tokenUrl = PathUtils.removeTrailingSlash(propertyCompatibility(context, TOKEN_URL, TOKEN_URL_DEPRECATED)); - var clientId = propertyCompatibility(context, CLIENT_ID, CLIENT_ID_DEPRECATED); - var clientSecretAlias = propertyCompatibility(context, CLIENT_SECRET_ALIAS, CLIENT_SECRET_ALIAS_DEPRECATED); + var tokenUrl = ofNullable(context.getConfig().getString(TOKEN_URL, null)) + .map(PathUtils::removeTrailingSlash).orElse(null); + var clientId = context.getConfig().getString(CLIENT_ID, null); + var clientSecretAlias = context.getConfig().getString(CLIENT_SECRET_ALIAS, null); var monitor = context.getMonitor().withPrefix("STS Client for DIM"); - + if (tokenUrl == null) { + missingMandatoryProperty(monitor, TOKEN_URL); + } + if (clientId == null) { + missingMandatoryProperty(monitor, CLIENT_ID); + } + if (clientSecretAlias == null) { + missingMandatoryProperty(monitor, CLIENT_SECRET_ALIAS); + } return new StsRemoteClientConfiguration(tokenUrl, clientId, clientSecretAlias); } diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/participant/TractusxIatpParticipantBase.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/participant/TractusxIatpParticipantBase.java index 462ec1738..69dfaf4d0 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/participant/TractusxIatpParticipantBase.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/participant/TractusxIatpParticipantBase.java @@ -54,7 +54,7 @@ public Map iatpConfiguration(TractusxIatpParticipantBase... othe }; Stream.concat(Stream.of(this), Arrays.stream(others)).forEach(p -> { - var prefix = "tx.iam.iatp.audiences.%s".formatted(p.getName().toLowerCase()); + var prefix = "tx.edc.iam.iatp.audiences.%s".formatted(p.getName().toLowerCase()); iatpConfiguration.put("%s.from".formatted(prefix), p.getBpn()); iatpConfiguration.put("%s.to".formatted(prefix), p.getDid()); });