You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2026/02/27 08:51:18 UTC
(camel) 01/01: CAMEL-23043 - Generalize Google services authentication with common module - Google Secrets Manager
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch 23043
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 96e34e8c49f4d271d0213ba2e157f6aa740e6ebf
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 27 09:50:32 2026 +0100
CAMEL-23043 - Generalize Google services authentication with common module - Google Secrets Manager
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../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;
}