Skip to content

Commit

Permalink
chore: self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Oct 1, 2024
1 parent 3171f7d commit 642885d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.edc.spi.EdcException;
import org.eclipse.edc.spi.monitor.ConsoleMonitor;
import org.eclipse.edc.spi.result.Failure;
import org.eclipse.edc.util.string.StringUtils;

import java.time.Duration;
import java.util.Map;
Expand Down Expand Up @@ -340,7 +339,7 @@ public RequestSpecification prepareManagementApiCall() {
var apiUrl = config.getManagementApiUrl();
var request = given().baseUri(apiUrl);

var header = config.getManagementApiAuthHeader();
var header = config.getManagementApiAuthHeaderFactory().get();
if (header != null) {
request = request.header(new Header(header.getLeft(), header.getRight()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ public class ConnectorConfig {
@Setter
private Map<String, String> properties;

private Supplier<Pair<String, String>> managementApiAuthHeader;
private Supplier<Pair<String, String>> managementApiAuthHeaderFactory;

@Nullable
public Pair<String, String> getManagementApiAuthHeader() {
if (managementApiAuthHeader != null) {
return managementApiAuthHeader.get();
public Supplier<Pair<String, String>> getManagementApiAuthHeaderFactory() {
if (managementApiAuthHeaderFactory == null) {
return () -> Pair.of("X-Api-Key", ConfigUtils.getManagementApiKey(properties));
}

return Pair.of("X-Api-Key", ConfigUtils.getManagementApiKey(properties));
return managementApiAuthHeaderFactory;
}

public ConnectorConfig setProperty(ConfigProp property, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ConnectorRemoteConfig {
private final String managementApiUrl;

@Nullable
private final Pair<String, String> managementApiAuthHeader;
private final Supplier<Pair<String, String>> managementApiAuthHeaderFactory;

@NonNull
private final String protocolApiUrl;
Expand All @@ -51,7 +51,7 @@ public static ConnectorRemoteConfig fromConnectorConfig(ConnectorConfig connecto
return builder()
.participantId(connectorConfig.getParticipantId())
.managementApiUrl(connectorConfig.getManagementApiUrl())
.managementApiAuthHeader(connectorConfig.getManagementApiAuthHeader())
.managementApiAuthHeaderFactory(connectorConfig.getManagementApiAuthHeaderFactory())
.protocolApiUrl(connectorConfig.getProtocolApiUrl())
.publicApiUrl(connectorConfig.getPublicApiUrl())
.defaultApiUrl(connectorConfig.getDefaultApiUrl())
Expand Down

0 comments on commit 642885d

Please sign in to comment.