This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new c7749c5  CAMEL-17644 - Support ability to load properties from 
Vault/Secrets cloud services - aws secrets manager
c7749c5 is described below

commit c7749c5ec629ae7af8a4eb0d0a3b0eeebd232599
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Feb 21 10:08:03 2022 +0100

    CAMEL-17644 - Support ability to load properties from Vault/Secrets cloud 
services - aws secrets manager
---
 .../src/main/docs/spring-boot.json                 | 23 ++++++++
 .../boot/vault/AwsVaultAutoConfiguration.java      | 42 +++++++++++++++
 .../vault/AwsVaultConfigurationProperties.java     | 62 ++++++++++++++++++++++
 .../src/main/resources/META-INF/spring.factories   |  3 +-
 .../boot/vault/AwsVaultConfigurationTest.java      | 34 ++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)

diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json 
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 4627190f..62d997a 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -115,6 +115,11 @@
       "sourceType": 
"org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties"
     },
     {
+      "name": "camel.vault.aws",
+      "type": 
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
+    },
+    {
       "name": "management.endpoint.camelroutecontroller",
       "type": 
"org.apache.camel.spring.boot.actuate.endpoint.CamelRouteControllerEndpoint",
       "sourceType": 
"org.apache.camel.spring.boot.actuate.endpoint.CamelRouteControllerEndpoint"
@@ -1296,6 +1301,24 @@
       "sourceType": 
"org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties"
     },
     {
+      "name": "camel.vault.aws.access-key",
+      "type": "java.lang.String",
+      "description": "The AWS access key",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.aws.region",
+      "type": "java.lang.String",
+      "description": "The AWS region",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.aws.secret-key",
+      "type": "java.lang.String",
+      "description": "The AWS secret key",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
+    },
+    {
       "name": "management.endpoint.camelroutecontroller.cache.time-to-live",
       "type": "java.time.Duration",
       "description": "Maximum time that a response can be cached.",
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
new file mode 100644
index 0000000..ff956dc
--- /dev/null
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.vault;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.vault.AwsVaultConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(AwsVaultConfigurationProperties.class)
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class AwsVaultAutoConfiguration {
+
+    @Bean
+    public AwsVaultConfiguration 
awsVaultConfiguration(AwsVaultConfigurationProperties config) {
+        AwsVaultConfiguration answer = new AwsVaultConfiguration();
+        answer.setAccessKey(config.getAccessKey());
+        answer.setSecretKey(config.getSecretKey());
+        answer.setRegion(config.getRegion());
+        return answer;
+    }
+
+}
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
new file mode 100644
index 0000000..14352f2
--- /dev/null
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.vault;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.vault.aws")
+public class AwsVaultConfigurationProperties {
+
+    /**
+     * The AWS access key
+     */
+    private String accessKey;
+
+    /**
+     * The AWS secret key
+     */
+    private String secretKey;
+
+    /**
+     * The AWS region
+     */
+    private String region;
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+}
diff --git 
a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories 
b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
index ba07de0..dff7aee 100644
--- a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -46,5 +46,6 @@ 
org.apache.camel.spring.boot.cluster.ClusteredRouteControllerAutoConfiguration,\
 org.apache.camel.spring.boot.properties.PropertiesComponentAutoConfiguration,\
 org.apache.camel.spring.boot.security.CamelSSLAutoConfiguration,\
 org.apache.camel.spring.boot.threadpool.CamelThreadPoolAutoConfiguration,\
-org.apache.camel.spring.boot.routetemplate.CamelRouteTemplateAutoConfiguration
+org.apache.camel.spring.boot.routetemplate.CamelRouteTemplateAutoConfiguration,\
+org.apache.camel.spring.boot.vault.AwsVaultAutoConfiguration
 
diff --git 
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
 
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
new file mode 100644
index 0000000..655b0ff
--- /dev/null
+++ 
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
@@ -0,0 +1,34 @@
+package org.apache.camel.spring.boot.vault;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+
+@DirtiesContext
+@CamelSpringBootTest
+@EnableAutoConfiguration
+@SpringBootTest(
+        classes = {
+                AwsVaultConfigurationTest.class},
+        properties = {
+                "camel.vault.aws.accessKey=myAccessKey",
+                "camel.vault.aws.secretKey=mySecretKey",
+                "camel.vault.aws.region=myRegion"}
+)
+public class AwsVaultConfigurationTest {
+
+    @Autowired
+    private CamelContext camelContext;
+
+    @Test
+    public void testAwsVault() throws Exception {
+        Assertions.assertEquals("myAccessKey", 
camelContext.getVaultConfiguration().aws().getAccessKey());
+        Assertions.assertEquals("mySecretKey", 
camelContext.getVaultConfiguration().aws().getSecretKey());
+        Assertions.assertEquals("myRegion", 
camelContext.getVaultConfiguration().aws().getRegion());
+    }
+}

Reply via email to