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

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

commit ebf390a37a3efe94d9fcbe2a251ccd51d704d24f
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Tue Mar 4 15:15:01 2025 +0100

    CAMEL-21826 - Camel-IBM-Secrtes-manager: Support properties function in 
Spring boot
    
    Signed-off-by: Andrea Cosentino <anco...@gmail.com>
---
 .../src/main/docs/spring-boot.json                 | 17 ++++++++
 .../boot/vault/IBMVaultAutoConfiguration.java      | 41 ++++++++++++++++++
 .../vault/IBMVaultConfigurationProperties.java     | 49 ++++++++++++++++++++++
 ...rk.boot.autoconfigure.AutoConfiguration.imports |  1 +
 .../IBMSecretsManagerVaultConfigurationTest.java   | 44 +++++++++++++++++++
 5 files changed, 152 insertions(+)

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 83273ca07aa..ed5ae454e6d 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -161,6 +161,11 @@
       "type": 
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties",
       "sourceType": 
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
     },
+    {
+      "name": "camel.vault.ibm",
+      "type": 
"org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties"
+    },
     {
       "name": "camel.vault.kubernetes",
       "type": 
"org.apache.camel.spring.boot.vault.KubernetesVaultConfigurationProperties",
@@ -1926,6 +1931,18 @@
       "description": "The Hashicorp Vault Token for accessing the service",
       "sourceType": 
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
     },
+    {
+      "name": "camel.vault.ibm.service-url",
+      "type": "java.lang.String",
+      "description": "The IBM Secrets Manager Service URL",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.ibm.token",
+      "type": "java.lang.String",
+      "description": "The IBM Secrets Manager Token",
+      "sourceType": 
"org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties"
+    },
     {
       "name": "camel.vault.kubernetes.refresh-enabled",
       "type": "java.lang.Boolean",
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultAutoConfiguration.java
new file mode 100644
index 00000000000..d24f5c5dc25
--- /dev/null
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultAutoConfiguration.java
@@ -0,0 +1,41 @@
+/*
+ * 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.IBMSecretsManagerVaultConfiguration;
+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(IBMVaultConfigurationProperties.class)
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class IBMVaultAutoConfiguration {
+
+    @Bean
+    public IBMSecretsManagerVaultConfiguration 
ibmSecretsManagerVaultConfiguration(IBMVaultConfigurationProperties config) {
+        IBMSecretsManagerVaultConfiguration answer = new 
IBMSecretsManagerVaultConfiguration();
+        answer.setToken(config.getToken());
+        answer.setServiceUrl(config.getServiceUrl());
+        return answer;
+    }
+
+}
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultConfigurationProperties.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultConfigurationProperties.java
new file mode 100644
index 00000000000..7c92a8565ee
--- /dev/null
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/IBMVaultConfigurationProperties.java
@@ -0,0 +1,49 @@
+/*
+ * 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.ibm")
+public class IBMVaultConfigurationProperties {
+
+    /**
+     * The IBM Secrets Manager Token
+     */
+    private String token;
+
+    /**
+     * The IBM Secrets Manager Service URL
+     */
+    private String serviceUrl;
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public String getServiceUrl() {
+        return serviceUrl;
+    }
+
+    public void setServiceUrl(String serviceUrl) {
+        this.serviceUrl = serviceUrl;
+    }
+}
diff --git 
a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
 
b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index cf3819c1455..33babc9c09c 100644
--- 
a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ 
b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -41,3 +41,4 @@ org.apache.camel.spring.boot.vault.AzureVaultAutoConfiguration
 org.apache.camel.spring.boot.vault.HashicorpVaultAutoConfiguration
 org.apache.camel.spring.boot.vault.KubernetesVaultAutoConfiguration
 org.apache.camel.spring.boot.vault.KubernetesConfigMapVaultAutoConfiguration
+org.apache.camel.spring.boot.vault.IBMVaultAutoConfiguration
diff --git 
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/IBMSecretsManagerVaultConfigurationTest.java
 
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/IBMSecretsManagerVaultConfigurationTest.java
new file mode 100644
index 00000000000..b346c3220dc
--- /dev/null
+++ 
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/IBMSecretsManagerVaultConfigurationTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.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 = { IBMSecretsManagerVaultConfigurationTest.class }, 
properties = {
+        "camel.vault.ibm.token=myToken",
+        "camel.vault.ibm.service-url=http://myHost"; })
+public class IBMSecretsManagerVaultConfigurationTest {
+
+    @Autowired
+    private CamelContext camelContext;
+
+    @Test
+    public void testIBMSecretsManagerVault() throws Exception {
+        Assertions.assertEquals("myToken", 
camelContext.getVaultConfiguration().ibmSecretsManager().getToken());
+        Assertions.assertEquals("http://myHost";, 
camelContext.getVaultConfiguration().ibmSecretsManager().getServiceUrl());
+    }
+}

Reply via email to