Skip to content

Commit

Permalink
Prepare JobHandler to get SecurityProvider injected (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
berndruecker authored and chillleader committed Jul 31, 2023
1 parent ba73c52 commit b8a3b43
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ConnectorJobHandler implements JobHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnectorJobHandler.class);

protected final OutboundConnectorFunction call;
protected SecretProvider secretProvider;

/**
* Create a handler wrapper for the specified connector function.
Expand All @@ -48,6 +49,12 @@ public ConnectorJobHandler(final OutboundConnectorFunction call) {
this.call = call;
}

public ConnectorJobHandler(
final OutboundConnectorFunction call, final SecretProvider secretProvider) {
this.call = call;
this.secretProvider = secretProvider;
}

@Override
public void handle(final JobClient client, final ActivatedJob job) {

Expand Down Expand Up @@ -89,6 +96,15 @@ public void handle(final JobClient client, final ActivatedJob job) {
}

protected SecretProvider getSecretProvider() {
if (secretProvider != null) {
return secretProvider;
}
// Initialize in legacy scenario where this is not provided by the environment with every call
// to not break former behavior
return loadOrCreateSecretProvider();
}

protected SecretProvider loadOrCreateSecretProvider() {
Iterator<SecretProvider> secretProviders = ServiceLoader.load(SecretProvider.class).iterator();
if (!secretProviders.hasNext()) {
getEnvSecretProvider();
Expand Down

0 comments on commit b8a3b43

Please sign in to comment.