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-spring-boot.git
commit 0c49882ff8a8ebb6a0b02a323612b2e58899bfcd Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon Sep 19 12:42:01 2022 +0200 CAMEL-18518 - Support Secrets Reload from Vault/Cloud Service in camel-spring-boot - Azure Key Vault Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../boot/vault/AzureVaultAutoConfiguration.java | 7 ++ .../vault/AzureVaultConfigurationProperties.java | 92 ++++++++++++++++++++++ .../boot/vault/AzureVaultConfigurationTest.java | 4 +- 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultAutoConfiguration.java index e9cc0396db2..16621be1e6e 100644 --- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultAutoConfiguration.java +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultAutoConfiguration.java @@ -37,6 +37,13 @@ public class AzureVaultAutoConfiguration { answer.setClientSecret(config.getClientSecret()); answer.setVaultName(config.getVaultName()); answer.setTenantId(config.getTenantId()); + answer.setRefreshEnabled(config.isRefreshEnabled()); + answer.setRefreshPeriod(config.getRefreshPeriod()); + answer.setSecrets(config.getSecrets()); + answer.setEventhubConnectionString(config.getEventhubConnectionString()); + answer.setBlobAccessKey(config.getBlobAccessKey()); + answer.setBlobAccountName(config.getBlobAccountName()); + answer.setBlobContainerName(config.getBlobContainerName()); return answer; } diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationProperties.java index e44bf4dcca7..492611bec93 100644 --- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationProperties.java +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationProperties.java @@ -16,6 +16,7 @@ */ package org.apache.camel.spring.boot.vault; +import org.apache.camel.spi.Metadata; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "camel.vault.azure") @@ -40,6 +41,41 @@ public class AzureVaultConfigurationProperties { * The tenant Id */ private String tenantId; + + /** + * Whether to automatically reload Camel upon secrets being updated in Azure. + */ + private boolean refreshEnabled; + + /** + * The period (millis) between checking Azure for updated secrets. + */ + private long refreshPeriod = 30000; + + /** + * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. + */ + private String secrets; + + /** + * The Eventhubs connection String for Key Vault Secret events notifications + */ + private String eventhubConnectionString; + + /** + * The Eventhubs Blob Access Key for CheckpointStore purpose + */ + private String blobAccessKey; + + /** + * The Eventhubs Blob Account Name for CheckpointStore purpose + */ + private String blobAccountName; + + /** + * The Eventhubs Blob Container Name for CheckpointStore purpose + */ + private String blobContainerName; public String getVaultName() { return vaultName; @@ -72,4 +108,60 @@ public class AzureVaultConfigurationProperties { public void setTenantId(String tenantId) { this.tenantId = tenantId; } + + public boolean isRefreshEnabled() { + return refreshEnabled; + } + + public void setRefreshEnabled(boolean refreshEnabled) { + this.refreshEnabled = refreshEnabled; + } + + public long getRefreshPeriod() { + return refreshPeriod; + } + + public void setRefreshPeriod(long refreshPeriod) { + this.refreshPeriod = refreshPeriod; + } + + public String getSecrets() { + return secrets; + } + + public void setSecrets(String secrets) { + this.secrets = secrets; + } + + public String getEventhubConnectionString() { + return eventhubConnectionString; + } + + public void setEventhubConnectionString(String eventhubConnectionString) { + this.eventhubConnectionString = eventhubConnectionString; + } + + public String getBlobAccessKey() { + return blobAccessKey; + } + + public void setBlobAccessKey(String blobAccessKey) { + this.blobAccessKey = blobAccessKey; + } + + public String getBlobAccountName() { + return blobAccountName; + } + + public void setBlobAccountName(String blobAccountName) { + this.blobAccountName = blobAccountName; + } + + public String getBlobContainerName() { + return blobContainerName; + } + + public void setBlobContainerName(String blobContainerName) { + this.blobContainerName = blobContainerName; + } } diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationTest.java index d5834431d04..d42c964aec0 100644 --- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationTest.java +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AzureVaultConfigurationTest.java @@ -35,7 +35,8 @@ import org.springframework.test.annotation.DirtiesContext; "camel.vault.azure.vaultName=myVault", "camel.vault.azure.clientId=myClientId", "camel.vault.azure.clientSecret=myClientSecret", - "camel.vault.azure.tenantId=myTenantId"} + "camel.vault.azure.tenantId=myTenantId", + "camel.vault.azure.eventhubConnectionString=connString"} ) public class AzureVaultConfigurationTest { @@ -48,5 +49,6 @@ public class AzureVaultConfigurationTest { Assertions.assertEquals("myClientSecret", camelContext.getVaultConfiguration().azure().getClientSecret()); Assertions.assertEquals("myClientId", camelContext.getVaultConfiguration().azure().getClientId()); Assertions.assertEquals("myTenantId", camelContext.getVaultConfiguration().azure().getTenantId()); + Assertions.assertEquals("connString", camelContext.getVaultConfiguration().azure().getEventhubConnectionString()); } }