diff --git a/bundle/camunda-saas-bundle/src/main/java/io/camunda/connector/runtime/saas/ZeebeClientSaaSConfiguration.java b/bundle/camunda-saas-bundle/src/main/java/io/camunda/connector/runtime/saas/ZeebeClientSaaSConfiguration.java index de506e56c4..9e0cedf113 100644 --- a/bundle/camunda-saas-bundle/src/main/java/io/camunda/connector/runtime/saas/ZeebeClientSaaSConfiguration.java +++ b/bundle/camunda-saas-bundle/src/main/java/io/camunda/connector/runtime/saas/ZeebeClientSaaSConfiguration.java @@ -2,13 +2,20 @@ import io.camunda.connector.api.secret.SecretProvider; import io.camunda.zeebe.client.CredentialsProvider; +import io.camunda.zeebe.client.ZeebeClientConfiguration; +import io.camunda.zeebe.client.api.JsonMapper; import io.camunda.zeebe.client.impl.oauth.OAuthCredentialsProviderBuilder; -import java.io.IOException; +import io.camunda.zeebe.spring.client.configuration.ZeebeClientConfigurationImpl; +import io.camunda.zeebe.spring.client.jobhandling.ZeebeClientExecutorService; +import io.camunda.zeebe.spring.client.properties.CamundaClientProperties; +import io.camunda.zeebe.spring.client.properties.ZeebeClientConfigurationProperties; +import io.grpc.ClientInterceptor; +import java.util.List; +import org.apache.hc.client5.http.async.AsyncExecChainHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; @Configuration public class ZeebeClientSaaSConfiguration { @@ -25,9 +32,42 @@ public ZeebeClientSaaSConfiguration(@Autowired SaaSConfiguration saaSConfigurati this.internalSecretProvider = saaSConfiguration.getInternalSecretProvider(); } + private static class SaaSZeebeClientConfiguration extends ZeebeClientConfigurationImpl { + + private final CredentialsProvider customCredentialsProvider; + + public SaaSZeebeClientConfiguration( + ZeebeClientConfigurationProperties properties, + CamundaClientProperties camundaClientProperties, + JsonMapper jsonMapper, + List interceptors, + List chainHandlers, + ZeebeClientExecutorService zeebeClientExecutorService, + CredentialsProvider credentialsProvider) { + super(properties, camundaClientProperties, jsonMapper, interceptors, chainHandlers, + zeebeClientExecutorService); + this.customCredentialsProvider = credentialsProvider; + } + + @Override + public CredentialsProvider getCredentialsProvider() { + return customCredentialsProvider; + } + } + @Bean - @Primary - public CredentialsProvider credentialsProvider() { + public ZeebeClientConfiguration zeebeClientConfiguration( + final ZeebeClientConfigurationProperties properties, + final CamundaClientProperties camundaClientProperties, + final JsonMapper jsonMapper, + final List interceptors, + final List chainHandlers, + final ZeebeClientExecutorService zeebeClientExecutorService) { + return new SaaSZeebeClientConfiguration(properties, camundaClientProperties, jsonMapper, + interceptors, chainHandlers, zeebeClientExecutorService, credentialsProvider()); + } + + private CredentialsProvider credentialsProvider() { final var builder = new OAuthCredentialsProviderBuilder(); builder.clientId(internalSecretProvider.getSecret(SECRET_NAME_CLIENT_ID)); builder.clientSecret(internalSecretProvider.getSecret(SECRET_NAME_SECRET)); @@ -35,5 +75,4 @@ public CredentialsProvider credentialsProvider() { builder.audience("zeebe.dev.ultrawombat.com"); return builder.build(); } - }