You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/02/19 07:42:06 UTC
[camel] branch vault created (now e310f81)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch vault
in repository https://gitbox.apache.org/repos/asf/camel.git.
at e310f81 CAMEL-17644: camel-core - Add VaultConfiguration SPI
This branch includes the following new commits:
new db10304 CAMEL-17644: camel-core - Add VaultConfiguration SPI
new e310f81 CAMEL-17644: camel-core - Add VaultConfiguration SPI
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[camel] 02/02: CAMEL-17644: camel-core - Add VaultConfiguration SPI
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch vault
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e310f812b3e52c62af9ec9bf4b20456fbf233438
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 19 08:41:18 2022 +0100
CAMEL-17644: camel-core - Add VaultConfiguration SPI
---
.../camel-main-configuration-metadata.json | 6 +-
core/camel-main/src/main/docs/main.adoc | 11 ++++
.../java/org/apache/camel/main/MainVaultTest.java | 75 ++++++++++++++++++++++
.../maven/packaging/PrepareCamelMainMojo.java | 14 ++++
4 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index a3fef16..5404d48 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -4,6 +4,7 @@
{ "name": "camel.threadpool", "description": "Camel Thread Pool configurations", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties" },
{ "name": "camel.health", "description": "Camel Health Check configurations", "sourceType": "org.apache.camel.main.HealthConfigurationProperties" },
{ "name": "camel.rest", "description": "Camel Rest-DSL configurations", "sourceType": "org.apache.camel.spi.RestConfiguration" },
+ { "name": "camel.vault", "description": "Camel Vault configurations", "sourceType": "org.apache.camel.spi.VaultConfiguration" },
{ "name": "camel.faulttolerance", "description": "Fault Tolerance EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.FaultToleranceConfigurationProperties" },
{ "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties" },
{ "name": "camel.hystrix", "description": "Hystrix (deprecated) EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.HystrixConfigurationProperties" },
@@ -227,6 +228,9 @@
{ "name": "camel.threadpool.maxQueueSize", "description": "Sets the default maximum number of tasks in the work queue. Use -1 or an unbounded queue", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer" },
{ "name": "camel.threadpool.poolSize", "description": "Sets the default core pool size (threads to keep minimum in pool)", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer" },
{ "name": "camel.threadpool.rejectedPolicy", "description": "Sets the default handler for tasks which cannot be executed by the thread pool.", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "enum": [ "Abort", "CallerRuns", "DiscardOldest", "Discard" ] },
- { "name": "camel.threadpool.timeUnit", "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit" }
+ { "name": "camel.threadpool.timeUnit", "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit" },
+ { "name": "camel.vault.awsAccessKey", "description": "The AWS access key", "sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.vault.awsRegion", "description": "The AWS region", "sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.vault.awsSecretKey", "description": "The AWS secret key", "sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", "javaType": "java.lang.String" }
]
}
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index a29a394..8621ec1 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -200,6 +200,17 @@ The camel.rest supports 28 options, which are listed below.
| *camel.rest.xmlDataFormat* | Sets a custom xml data format to be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance. | | String
|===
+=== Camel Vault configurations
+The camel.vault supports 3 options, which are listed below.
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *camel.vault.awsAccessKey* | The AWS access key | | String
+| *camel.vault.awsRegion* | The AWS region | | String
+| *camel.vault.awsSecretKey* | The AWS secret key | | String
+|===
+
=== Fault Tolerance EIP Circuit Breaker configurations
The camel.faulttolerance supports 13 options, which are listed below.
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java
new file mode 100644
index 0000000..ac7b43e
--- /dev/null
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.CamelContext;
+import org.apache.camel.spi.VaultConfiguration;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class MainVaultTest {
+
+ @Test
+ public void testMain() throws Exception {
+ Main main = new Main();
+
+ main.addInitialProperty("camel.vault.awsAccessKey", "myKey");
+ main.addInitialProperty("camel.vault.awsSecretKey", "mySecret");
+ main.addInitialProperty("camel.vault.awsRegion", "myRegion");
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ VaultConfiguration cfg = context.getVaultConfiguration();
+ assertNotNull(cfg);
+
+ Assertions.assertEquals("myKey", cfg.getAwsAccessKey());
+ Assertions.assertEquals("mySecret", cfg.getAwsSecretKey());
+ Assertions.assertEquals("myRegion", cfg.getAwsRegion());
+
+ main.stop();
+ }
+
+ @Test
+ public void testMainFluent() throws Exception {
+ Main main = new Main();
+ main.configure().vault()
+ .withAwsAccessKey("myKey")
+ .withAwsSecretKey("mySecret")
+ .withAwsRegion("myRegion")
+ .end();
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ VaultConfiguration cfg = context.getVaultConfiguration();
+ assertNotNull(cfg);
+
+ Assertions.assertEquals("myKey", cfg.getAwsAccessKey());
+ Assertions.assertEquals("mySecret", cfg.getAwsSecretKey());
+ Assertions.assertEquals("myRegion", cfg.getAwsRegion());
+
+ main.stop();
+ }
+
+}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
index 5eedad6..a405f4f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
@@ -195,6 +195,8 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
prefix = "camel.faulttolerance.";
} else if (file.getName().contains("Rest")) {
prefix = "camel.rest.";
+ } else if (file.getName().contains("Vault")) {
+ prefix = "camel.vault.";
} else if (file.getName().contains("Health")) {
prefix = "camel.health.";
} else if (file.getName().contains("Lra")) {
@@ -225,6 +227,15 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
} catch (Exception e) {
throw new MojoFailureException("Error parsing file " + restConfig + " due " + e.getMessage(), e);
}
+ // include additional vault configuration from camel-api
+ File vaultConfig = new File(camelApiDir, "src/main/java/org/apache/camel/spi/VaultConfiguration.java");
+ try {
+ List<MainModel.MainOptionModel> model = parseConfigurationSource(vaultConfig);
+ model.forEach(m -> m.setName("camel.vault." + m.getName()));
+ data.addAll(model);
+ } catch (Exception e) {
+ throw new MojoFailureException("Error parsing file " + restConfig + " due " + e.getMessage(), e);
+ }
// lets sort so they are always ordered (but camel.main in top)
data.sort((o1, o2) -> {
@@ -252,6 +263,9 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
model.getGroups().add(
new MainGroupModel(
"camel.rest", "Camel Rest-DSL configurations", "org.apache.camel.spi.RestConfiguration"));
+ model.getGroups().add(
+ new MainGroupModel(
+ "camel.vault", "Camel Vault configurations", "org.apache.camel.spi.VaultConfiguration"));
model.getGroups()
.add(new MainGroupModel(
"camel.faulttolerance", "Fault Tolerance EIP Circuit Breaker configurations",
[camel] 01/02: CAMEL-17644: camel-core - Add VaultConfiguration SPI
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch vault
in repository https://gitbox.apache.org/repos/asf/camel.git
commit db103040bd90bb3a8c249931ebb0c3f779f1577d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 19 08:33:14 2022 +0100
CAMEL-17644: camel-core - Add VaultConfiguration SPI
---
.../main/java/org/apache/camel/CamelContext.java | 15 +++++
.../org/apache/camel/spi/VaultConfiguration.java | 64 ++++++++++++++++++
.../camel/impl/engine/AbstractCamelContext.java | 12 ++++
.../camel/impl/ExtendedCamelContextConfigurer.java | 6 ++
.../camel/impl/lw/LightweightCamelContext.java | 11 ++++
.../impl/lw/LightweightRuntimeCamelContext.java | 11 ++++
.../VaultConfigurationPropertiesConfigurer.java | 61 +++++++++++++++++
....apache.camel.main.VaultConfigurationProperties | 2 +
.../org/apache/camel/main/BaseMainSupport.java | 20 ++++++
.../camel/main/MainConfigurationProperties.java | 22 +++++++
.../camel/main/VaultConfigurationProperties.java | 76 ++++++++++++++++++++++
11 files changed, 300 insertions(+)
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
index bedcd7d..669b56c 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
@@ -52,6 +52,7 @@ import org.apache.camel.spi.TypeConverterRegistry;
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.spi.Validator;
import org.apache.camel.spi.ValidatorRegistry;
+import org.apache.camel.spi.VaultConfiguration;
import org.apache.camel.support.jsse.SSLContextParameters;
/**
@@ -673,6 +674,20 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
RestConfiguration getRestConfiguration();
/**
+ * Sets a custom {@link org.apache.camel.spi.VaultConfiguration}
+ *
+ * @param vaultConfiguration the vault configuration
+ */
+ void setVaultConfiguration(VaultConfiguration vaultConfiguration);
+
+ /**
+ * Gets the vault configuration
+ *
+ * @return the configuration, or <tt>null</tt> if none has been configured.
+ */
+ VaultConfiguration getVaultConfiguration();
+
+ /**
* Gets the {@link org.apache.camel.spi.RestRegistry} to use
*/
RestRegistry getRestRegistry();
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/VaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/spi/VaultConfiguration.java
new file mode 100644
index 0000000..b50ee0c
--- /dev/null
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/VaultConfiguration.java
@@ -0,0 +1,64 @@
+/*
+ * 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.spi;
+
+/**
+ * Configuration for access to Vaults.
+ */
+public class VaultConfiguration {
+
+ @Metadata(secret = true)
+ private String awsAccessKey;
+ @Metadata(secret = true)
+ private String awsSecretKey;
+ @Metadata
+ private String awsRegion;
+
+ public String getAwsAccessKey() {
+ return awsAccessKey;
+ }
+
+ /**
+ * The AWS access key
+ */
+ public void setAwsAccessKey(String awsAccessKey) {
+ this.awsAccessKey = awsAccessKey;
+ }
+
+ public String getAwsSecretKey() {
+ return awsSecretKey;
+ }
+
+ /**
+ * The AWS secret key
+ */
+ public void setAwsSecretKey(String awsSecretKey) {
+ this.awsSecretKey = awsSecretKey;
+ }
+
+ public String getAwsRegion() {
+ return awsRegion;
+ }
+
+ /**
+ * The AWS region
+ */
+ public void setAwsRegion(String awsRegion) {
+ this.awsRegion = awsRegion;
+ }
+
+}
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 6524e76..9ebd16c 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -169,6 +169,7 @@ import org.apache.camel.spi.UriFactoryResolver;
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.spi.Validator;
import org.apache.camel.spi.ValidatorRegistry;
+import org.apache.camel.spi.VaultConfiguration;
import org.apache.camel.spi.XMLRoutesDefinitionLoader;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.EndpointHelper;
@@ -245,6 +246,7 @@ public abstract class AbstractCamelContext extends BaseService
private ClassLoader applicationContextClassLoader;
private boolean autoCreateComponents = true;
private volatile RestConfiguration restConfiguration;
+ private volatile VaultConfiguration vaultConfiguration = new VaultConfiguration();
private List<InterceptStrategy> interceptStrategies = new ArrayList<>();
private List<RoutePolicyFactory> routePolicyFactories = new ArrayList<>();
// special flags to control the first startup which can are special
@@ -2158,6 +2160,16 @@ public abstract class AbstractCamelContext extends BaseService
}
@Override
+ public VaultConfiguration getVaultConfiguration() {
+ return vaultConfiguration;
+ }
+
+ @Override
+ public void setVaultConfiguration(VaultConfiguration vaultConfiguration) {
+ this.vaultConfiguration = vaultConfiguration;
+ }
+
+ @Override
public List<InterceptStrategy> getInterceptStrategies() {
return interceptStrategies;
}
diff --git a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
index 5189be9..8eeef0d 100644
--- a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
+++ b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
@@ -211,6 +211,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "UseMDCLogging": target.setUseMDCLogging(property(camelContext, java.lang.Boolean.class, value)); return true;
case "uuidgenerator":
case "UuidGenerator": target.setUuidGenerator(property(camelContext, org.apache.camel.spi.UuidGenerator.class, value)); return true;
+ case "vaultconfiguration":
+ case "VaultConfiguration": target.setVaultConfiguration(property(camelContext, org.apache.camel.spi.VaultConfiguration.class, value)); return true;
case "xmlroutesdefinitionloader":
case "XMLRoutesDefinitionLoader": target.setXMLRoutesDefinitionLoader(property(camelContext, org.apache.camel.spi.XMLRoutesDefinitionLoader.class, value)); return true;
default: return false;
@@ -410,6 +412,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "UseMDCLogging": return java.lang.Boolean.class;
case "uuidgenerator":
case "UuidGenerator": return org.apache.camel.spi.UuidGenerator.class;
+ case "vaultconfiguration":
+ case "VaultConfiguration": return org.apache.camel.spi.VaultConfiguration.class;
case "xmlroutesdefinitionloader":
case "XMLRoutesDefinitionLoader": return org.apache.camel.spi.XMLRoutesDefinitionLoader.class;
default: return null;
@@ -610,6 +614,8 @@ public class ExtendedCamelContextConfigurer extends org.apache.camel.support.com
case "UseMDCLogging": return target.isUseMDCLogging();
case "uuidgenerator":
case "UuidGenerator": return target.getUuidGenerator();
+ case "vaultconfiguration":
+ case "VaultConfiguration": return target.getVaultConfiguration();
case "xmlroutesdefinitionloader":
case "XMLRoutesDefinitionLoader": return target.getXMLRoutesDefinitionLoader();
default: return null;
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
index bcccc6a..b5c5dff 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
@@ -149,6 +149,7 @@ import org.apache.camel.spi.UriFactoryResolver;
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.spi.Validator;
import org.apache.camel.spi.ValidatorRegistry;
+import org.apache.camel.spi.VaultConfiguration;
import org.apache.camel.spi.XMLRoutesDefinitionLoader;
import org.apache.camel.support.DefaultRegistry;
import org.apache.camel.support.jsse.SSLContextParameters;
@@ -589,6 +590,16 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
}
@Override
+ public void setVaultConfiguration(VaultConfiguration vaultConfiguration) {
+ delegate.setVaultConfiguration(vaultConfiguration);
+ }
+
+ @Override
+ public VaultConfiguration getVaultConfiguration() {
+ return delegate.getVaultConfiguration();
+ }
+
+ @Override
public RestRegistry getRestRegistry() {
return delegate.getRestRegistry();
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
index 0e3c9ad..e344bc5 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
@@ -144,6 +144,7 @@ import org.apache.camel.spi.UriFactoryResolver;
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.spi.Validator;
import org.apache.camel.spi.ValidatorRegistry;
+import org.apache.camel.spi.VaultConfiguration;
import org.apache.camel.spi.XMLRoutesDefinitionLoader;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.NormalizedUri;
@@ -898,6 +899,16 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
}
@Override
+ public void setVaultConfiguration(VaultConfiguration vaultConfiguration) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public VaultConfiguration getVaultConfiguration() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public RestRegistry getRestRegistry() {
throw new UnsupportedOperationException();
}
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/VaultConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/VaultConfigurationPropertiesConfigurer.java
new file mode 100644
index 0000000..ba2c389
--- /dev/null
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/VaultConfigurationPropertiesConfigurer.java
@@ -0,0 +1,61 @@
+/* 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.VaultConfigurationProperties;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class VaultConfigurationPropertiesConfigurer 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.VaultConfigurationProperties target = (org.apache.camel.main.VaultConfigurationProperties) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "awsaccesskey":
+ case "AwsAccessKey": target.setAwsAccessKey(property(camelContext, java.lang.String.class, value)); return true;
+ case "awsregion":
+ case "AwsRegion": target.setAwsRegion(property(camelContext, java.lang.String.class, value)); return true;
+ case "awssecretkey":
+ case "AwsSecretKey": target.setAwsSecretKey(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 "awsaccesskey":
+ case "AwsAccessKey": return java.lang.String.class;
+ case "awsregion":
+ case "AwsRegion": return java.lang.String.class;
+ case "awssecretkey":
+ case "AwsSecretKey": return java.lang.String.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ org.apache.camel.main.VaultConfigurationProperties target = (org.apache.camel.main.VaultConfigurationProperties) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "awsaccesskey":
+ case "AwsAccessKey": return target.getAwsAccessKey();
+ case "awsregion":
+ case "AwsRegion": return target.getAwsRegion();
+ case "awssecretkey":
+ case "AwsSecretKey": return target.getAwsSecretKey();
+ default: return null;
+ }
+ }
+}
+
diff --git a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.VaultConfigurationProperties b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.VaultConfigurationProperties
new file mode 100644
index 0000000..42521d4
--- /dev/null
+++ b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.VaultConfigurationProperties
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.main.VaultConfigurationPropertiesConfigurer
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 48822f1..8639020 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -760,6 +760,7 @@ public abstract class BaseMainSupport extends BaseService {
Map<String, Object> resilience4jProperties = new LinkedHashMap<>();
Map<String, Object> faultToleranceProperties = new LinkedHashMap<>();
Map<String, Object> restProperties = new LinkedHashMap<>();
+ Map<String, Object> vaultProperties = new LinkedHashMap<>();
Map<String, Object> threadPoolProperties = new LinkedHashMap<>();
Map<String, Object> healthProperties = new LinkedHashMap<>();
Map<String, Object> lraProperties = new LinkedHashMap<>();
@@ -798,6 +799,12 @@ public abstract class BaseMainSupport extends BaseService {
String option = key.substring(11);
validateOptionAndValue(key, option, value);
restProperties.put(optionKey(option), value);
+ } else if (key.startsWith("camel.vault.")) {
+ // grab the value
+ String value = prop.getProperty(key);
+ String option = key.substring(12);
+ validateOptionAndValue(key, option, value);
+ vaultProperties.put(optionKey(option), value);
} else if (key.startsWith("camel.threadpool.")) {
// grab the value
String value = prop.getProperty(key);
@@ -868,6 +875,14 @@ public abstract class BaseMainSupport extends BaseService {
camelContext.setRestConfiguration(rest);
}
+ if (!vaultProperties.isEmpty() || mainConfigurationProperties.hasVaultConfiguration()) {
+ VaultConfigurationProperties vault = mainConfigurationProperties.vault();
+ LOG.debug("Auto-configuring Vault from loaded properties: {}", vaultProperties.size());
+ setPropertiesOnTarget(camelContext, vault, vaultProperties, "camel.vault.",
+ mainConfigurationProperties.isAutoConfigurationFailFast(), true, autoConfiguredProperties);
+ camelContext.setVaultConfiguration(vault);
+ }
+
if (!threadPoolProperties.isEmpty() || mainConfigurationProperties.hasThreadPoolConfiguration()) {
LOG.debug("Auto-configuring Thread Pool from loaded properties: {}", threadPoolProperties.size());
MainSupportModelConfigurer.setThreadPoolProperties(camelContext, mainConfigurationProperties, threadPoolProperties,
@@ -932,6 +947,11 @@ public abstract class BaseMainSupport extends BaseService {
LOG.warn("Property not auto-configured: camel.rest.{}={}", k, v);
});
}
+ if (!vaultProperties.isEmpty()) {
+ vaultProperties.forEach((k, v) -> {
+ LOG.warn("Property not auto-configured: camel.vault.{}={}", k, v);
+ });
+ }
if (!threadPoolProperties.isEmpty()) {
threadPoolProperties.forEach((k, v) -> {
LOG.warn("Property not auto-configured: camel.threadpool.{}={}", k, v);
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index 8138bef..b4aefb2 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -56,6 +56,7 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
private Resilience4jConfigurationProperties resilience4jConfigurationProperties;
private FaultToleranceConfigurationProperties faultToleranceConfigurationProperties;
private RestConfigurationProperties restConfigurationProperties;
+ private VaultConfigurationProperties vaultConfigurationProperties;
@Override
public void close() {
@@ -87,6 +88,10 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
restConfigurationProperties.close();
restConfigurationProperties = null;
}
+ if (vaultConfigurationProperties != null) {
+ vaultConfigurationProperties.close();
+ vaultConfigurationProperties = null;
+ }
if (routesBuilders != null) {
routesBuilders.clear();
routesBuilders = null;
@@ -220,6 +225,23 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
return restConfigurationProperties != null;
}
+ /**
+ * To configure access to vaults
+ */
+ public VaultConfigurationProperties vault() {
+ if (vaultConfigurationProperties == null) {
+ vaultConfigurationProperties = new VaultConfigurationProperties(this);
+ }
+ return vaultConfigurationProperties;
+ }
+
+ /**
+ * Whether there has been any rest configuration specified
+ */
+ public boolean hasVaultConfiguration() {
+ return vaultConfigurationProperties != null;
+ }
+
// getter and setters
// --------------------------------------------------------------
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/VaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/VaultConfigurationProperties.java
new file mode 100644
index 0000000..7901a29
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/VaultConfigurationProperties.java
@@ -0,0 +1,76 @@
+/*
+ * 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.spi.VaultConfiguration;
+
+/**
+ * Global configuration for accessing secrets in vaults.
+ */
+@Configurer(bootstrap = true)
+public class VaultConfigurationProperties extends VaultConfiguration implements BootstrapCloseable {
+
+ private MainConfigurationProperties parent;
+
+ public VaultConfigurationProperties(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 AWS access key
+ */
+ public VaultConfigurationProperties withAwsAccessKey(String awsAccessKey) {
+ setAwsAccessKey(awsAccessKey);
+ return this;
+ }
+
+ /**
+ * The AWS secret key
+ */
+ public VaultConfigurationProperties withAwsSecretKey(String awsSecretKey) {
+ setAwsSecretKey(awsSecretKey);
+ return this;
+ }
+
+ /**
+ * The AWS region
+ */
+ public VaultConfigurationProperties withAwsRegion(String awsRegion) {
+ setAwsRegion(awsRegion);
+ return this;
+ }
+
+}