Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed May 14, 2024
1 parent 52acfb2 commit 3370b18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Map<String, String> 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());
});
Expand Down

0 comments on commit 3370b18

Please sign in to comment.