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

commit 3f7dd164eefc509d50ba1898158f916158d735b5
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Jul 13 18:29:52 2022 +0200

    CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud 
services - Hashicorp Vault
---
 .../camel/vault/HashicorpVaultConfiguration.java   | 91 ++++++++++++++++++++
 ...corpVaultConfigurationPropertiesConfigurer.java | 97 ++++++++++++++++++++++
 ...amel.main.HashicorpVaultConfigurationProperties |  2 +
 .../HashicorpVaultConfigurationProperties.java     | 93 +++++++++++++++++++++
 4 files changed, 283 insertions(+)

diff --git 
a/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java
 
b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java
new file mode 100644
index 00000000000..d3215fcb311
--- /dev/null
+++ 
b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java
@@ -0,0 +1,91 @@
+/*
+ * 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.vault;
+
+import org.apache.camel.spi.Metadata;
+
+/**
+ * Configuration for access to Hashicorp Vault Secrets.
+ */
+public class HashicorpVaultConfiguration extends VaultConfiguration {
+
+    @Metadata(secret = true)
+    private String token;
+    @Metadata(secret = true)
+    private String engine;
+    @Metadata
+    private String host;
+    @Metadata
+    private String port;
+    @Metadata
+    private String scheme;
+
+    /**
+     * Token to access hashicorp vault
+     */
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    /**
+     * Engine to look at hashicorp vault
+     */
+    public String getEngine() {
+        return engine;
+    }
+
+    public void setEngine(String engine) {
+        this.engine = engine;
+    }
+
+    /**
+     * Host to access hashicorp vault
+     */
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * Port to access hashicorp vault
+     */
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    /**
+     * Scheme to access hashicorp vault
+     */
+    public String getScheme() {
+        return scheme;
+    }
+
+    public void setScheme(String scheme) {
+        this.scheme = scheme;
+    }
+}
diff --git 
a/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java
 
b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java
new file mode 100644
index 00000000000..e099997c287
--- /dev/null
+++ 
b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java
@@ -0,0 +1,97 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.main;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.main.HashicorpVaultConfigurationProperties;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class HashicorpVaultConfigurationPropertiesConfigurer extends 
org.apache.camel.support.component.PropertyConfigurerSupport implements 
GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+    @Override
+    public boolean configure(CamelContext camelContext, Object obj, String 
name, Object value, boolean ignoreCase) {
+        org.apache.camel.main.HashicorpVaultConfigurationProperties target = 
(org.apache.camel.main.HashicorpVaultConfigurationProperties) obj;
+        switch (ignoreCase ? name.toLowerCase() : name) {
+        case "awsvaultconfiguration":
+        case "AwsVaultConfiguration": 
target.setAwsVaultConfiguration(property(camelContext, 
org.apache.camel.vault.AwsVaultConfiguration.class, value)); return true;
+        case "azurevaultconfiguration":
+        case "AzureVaultConfiguration": 
target.setAzureVaultConfiguration(property(camelContext, 
org.apache.camel.vault.AzureVaultConfiguration.class, value)); return true;
+        case "engine":
+        case "Engine": target.setEngine(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "gcpvaultconfiguration":
+        case "GcpVaultConfiguration": 
target.setGcpVaultConfiguration(property(camelContext, 
org.apache.camel.vault.GcpVaultConfiguration.class, value)); return true;
+        case "hashicorp":
+        case "Hashicorp": target.setHashicorp(property(camelContext, 
org.apache.camel.vault.HashicorpVaultConfiguration.class, value)); return true;
+        case "host":
+        case "Host": target.setHost(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "port":
+        case "Port": target.setPort(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "scheme":
+        case "Scheme": target.setScheme(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "token":
+        case "Token": target.setToken(property(camelContext, 
java.lang.String.class, value)); return true;
+        default: return false;
+        }
+    }
+
+    @Override
+    public Class<?> getOptionType(String name, boolean ignoreCase) {
+        switch (ignoreCase ? name.toLowerCase() : name) {
+        case "awsvaultconfiguration":
+        case "AwsVaultConfiguration": return 
org.apache.camel.vault.AwsVaultConfiguration.class;
+        case "azurevaultconfiguration":
+        case "AzureVaultConfiguration": return 
org.apache.camel.vault.AzureVaultConfiguration.class;
+        case "engine":
+        case "Engine": return java.lang.String.class;
+        case "gcpvaultconfiguration":
+        case "GcpVaultConfiguration": return 
org.apache.camel.vault.GcpVaultConfiguration.class;
+        case "hashicorp":
+        case "Hashicorp": return 
org.apache.camel.vault.HashicorpVaultConfiguration.class;
+        case "host":
+        case "Host": return java.lang.String.class;
+        case "port":
+        case "Port": return java.lang.String.class;
+        case "scheme":
+        case "Scheme": return java.lang.String.class;
+        case "token":
+        case "Token": return java.lang.String.class;
+        default: return null;
+        }
+    }
+
+    @Override
+    public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+        org.apache.camel.main.HashicorpVaultConfigurationProperties target = 
(org.apache.camel.main.HashicorpVaultConfigurationProperties) obj;
+        switch (ignoreCase ? name.toLowerCase() : name) {
+        case "awsvaultconfiguration":
+        case "AwsVaultConfiguration": return target.getAwsVaultConfiguration();
+        case "azurevaultconfiguration":
+        case "AzureVaultConfiguration": return 
target.getAzureVaultConfiguration();
+        case "engine":
+        case "Engine": return target.getEngine();
+        case "gcpvaultconfiguration":
+        case "GcpVaultConfiguration": return target.getGcpVaultConfiguration();
+        case "hashicorp":
+        case "Hashicorp": return target.getHashicorp();
+        case "host":
+        case "Host": return target.getHost();
+        case "port":
+        case "Port": return target.getPort();
+        case "scheme":
+        case "Scheme": return target.getScheme();
+        case "token":
+        case "Token": return target.getToken();
+        default: return null;
+        }
+    }
+}
+
diff --git 
a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.HashicorpVaultConfigurationProperties
 
b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.HashicorpVaultConfigurationProperties
new file mode 100644
index 00000000000..c96e69216ba
--- /dev/null
+++ 
b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.HashicorpVaultConfigurationProperties
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.main.HashicorpVaultConfigurationPropertiesConfigurer
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java
new file mode 100644
index 00000000000..863542932c1
--- /dev/null
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java
@@ -0,0 +1,93 @@
+/*
+ * 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.main;
+
+import org.apache.camel.spi.BootstrapCloseable;
+import org.apache.camel.spi.Configurer;
+import org.apache.camel.vault.AwsVaultConfiguration;
+import org.apache.camel.vault.HashicorpVaultConfiguration;
+
+/**
+ * Configuration for access to AWS Secret.
+ */
+@Configurer(bootstrap = true)
+public class HashicorpVaultConfigurationProperties extends 
HashicorpVaultConfiguration implements BootstrapCloseable {
+
+    private MainConfigurationProperties parent;
+
+    public HashicorpVaultConfigurationProperties(MainConfigurationProperties 
parent) {
+        this.parent = parent;
+    }
+
+    public MainConfigurationProperties end() {
+        return parent;
+    }
+
+    @Override
+    public void close() {
+        parent = null;
+    }
+
+    // getter and setters
+    // --------------------------------------------------------------
+
+    // these are inherited from the parent class
+
+    // fluent builders
+    // --------------------------------------------------------------
+
+    /**
+     * The Hashicorp Vault token
+     */
+    public HashicorpVaultConfigurationProperties withToken(String token) {
+        setToken(token);
+        return this;
+    }
+
+    /**
+     * The Hashicorp vault Engine to look at
+     */
+    public HashicorpVaultConfigurationProperties withEngine(String engine) {
+        setEngine(engine);
+        return this;
+    }
+
+    /**
+     * The Hashicorp Vault host
+     */
+    public HashicorpVaultConfigurationProperties withHost(String host) {
+        setHost(host);
+        return this;
+    }
+
+    /**
+     * The Hashicorp Vault port
+     */
+    public HashicorpVaultConfigurationProperties withPort(String port) {
+        setPort(port);
+        return this;
+    }
+
+    /**
+     * The Hashicorp Vault scheme
+     */
+    public HashicorpVaultConfigurationProperties withScheme(String scheme) {
+        setScheme(scheme);
+        return this;
+    }
+
+}

Reply via email to