This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c2794674d4e2 CAMEL-23043 - Generalize Google services authentication
with common module - Google Secrets Manager (#21625)
c2794674d4e2 is described below
commit c2794674d4e23cb78516c853db5fb959f4f0bf4d
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Feb 27 10:33:20 2026 +0100
CAMEL-23043 - Generalize Google services authentication with common module
- Google Secrets Manager (#21625)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../camel-google-secret-manager/pom.xml | 4 ++++
.../manager/GoogleSecretManagerClientFactory.java | 23 ++++++++--------------
.../manager/GoogleSecretManagerConfiguration.java | 4 +++-
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/components/camel-google/camel-google-secret-manager/pom.xml
b/components/camel-google/camel-google-secret-manager/pom.xml
index 70255e7b8083..063e9a5cfa0b 100644
--- a/components/camel-google/camel-google-secret-manager/pom.xml
+++ b/components/camel-google/camel-google-secret-manager/pom.xml
@@ -38,6 +38,10 @@
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-google-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
diff --git
a/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerClientFactory.java
b/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerClientFactory.java
index ab190b919f8c..df2b1622980f 100644
---
a/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerClientFactory.java
+++
b/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerClientFactory.java
@@ -16,16 +16,12 @@
*/
package org.apache.camel.component.google.secret.manager;
-import java.io.InputStream;
-
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.Credentials;
-import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import com.google.cloud.secretmanager.v1.SecretManagerServiceSettings;
-import com.google.common.base.Strings;
import org.apache.camel.CamelContext;
-import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.component.google.common.GoogleCredentialsHelper;
public final class GoogleSecretManagerClientFactory {
/**
@@ -38,22 +34,19 @@ public final class GoogleSecretManagerClientFactory {
CamelContext context,
GoogleSecretManagerConfiguration configuration)
throws Exception {
- SecretManagerServiceClient secretManagerServiceClient = null;
- if (!Strings.isNullOrEmpty(configuration.getServiceAccountKey())) {
- InputStream resolveMandatoryResourceAsInputStream
- =
ResourceHelper.resolveMandatoryResourceAsInputStream(context,
configuration.getServiceAccountKey());
- Credentials myCredentials = ServiceAccountCredentials
- .fromStream(resolveMandatoryResourceAsInputStream);
+
+ Credentials credentials =
GoogleCredentialsHelper.getCredentials(context, configuration);
+
+ if (credentials != null) {
SecretManagerServiceSettings settings =
SecretManagerServiceSettings.newBuilder()
-
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
- secretManagerServiceClient =
SecretManagerServiceClient.create(settings);
+
.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
+ return SecretManagerServiceClient.create(settings);
} else {
// it needs to define the environment variable
GOOGLE_APPLICATION_CREDENTIALS
// with the service account file
// more info at
https://cloud.google.com/docs/authentication/production
SecretManagerServiceSettings settings =
SecretManagerServiceSettings.newBuilder().build();
- secretManagerServiceClient =
SecretManagerServiceClient.create(settings);
+ return SecretManagerServiceClient.create(settings);
}
- return secretManagerServiceClient;
}
}
diff --git
a/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerConfiguration.java
b/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerConfiguration.java
index 28a9df6a066b..b8bbbe09979d 100644
---
a/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerConfiguration.java
+++
b/components/camel-google/camel-google-secret-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerConfiguration.java
@@ -18,13 +18,14 @@ package org.apache.camel.component.google.secret.manager;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.google.common.GoogleCommonConfiguration;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
@UriParams
-public class GoogleSecretManagerConfiguration implements Cloneable {
+public class GoogleSecretManagerConfiguration implements Cloneable,
GoogleCommonConfiguration {
@UriPath(label = "common", description = "The Google Cloud Project Id name
related to the Secret Manager")
@Metadata(required = true)
@@ -44,6 +45,7 @@ public class GoogleSecretManagerConfiguration implements
Cloneable {
@Metadata(autowired = true)
private SecretManagerServiceClient client;
+ @Override
public String getServiceAccountKey() {
return serviceAccountKey;
}