You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/07/05 11:53:09 UTC
[camel] 01/03: CAMEL-18257 - Camel-Hashicorp-vault: Support list secrets operation
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 e99f68716eb8d6b2b8b7cf703a3f978776e20670
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 5 13:43:34 2022 +0200
CAMEL-18257 - Camel-Hashicorp-vault: Support list secrets operation
---
.../camel/component/hashicorp/vault/hashicorp-vault.json | 2 +-
.../component/hashicorp/vault/HashicorpVaultOperation.java | 3 ++-
.../component/hashicorp/vault/HashicorpVaultProducer.java | 10 ++++++++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/components/camel-hashicorp-vault/src/generated/resources/org/apache/camel/component/hashicorp/vault/hashicorp-vault.json b/components/camel-hashicorp-vault/src/generated/resources/org/apache/camel/component/hashicorp/vault/hashicorp-vault.json
index 11dbe253dbe..f81d73d5f55 100644
--- a/components/camel-hashicorp-vault/src/generated/resources/org/apache/camel/component/hashicorp/vault/hashicorp-vault.json
+++ b/components/camel-hashicorp-vault/src/generated/resources/org/apache/camel/component/hashicorp/vault/hashicorp-vault.json
@@ -33,7 +33,7 @@
"properties": {
"secretsEngine": { "kind": "path", "displayName": "Secrets Engine", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Vault Name to be used" },
"host": { "kind": "parameter", "displayName": "Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Hashicorp Vault instance host to be used" },
- "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.hashicorp.vault.HashicorpVaultOperation", "enum": [ "createSecret", "getSecret", "deleteSecret" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description" [...]
+ "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.hashicorp.vault.HashicorpVaultOperation", "enum": [ "createSecret", "getSecret", "deleteSecret", "listSecrets" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration" [...]
"port": { "kind": "parameter", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "8200", "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Hashicorp Vault instance port to be used" },
"scheme": { "kind": "parameter", "displayName": "Scheme", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https", "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Hashicorp Vault instance scheme to be used" },
"secretPath": { "kind": "parameter", "displayName": "Secret Path", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Hashicorp Vault instance secret Path to be used" },
diff --git a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultOperation.java b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultOperation.java
index bc1ed613a84..9565c37e345 100644
--- a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultOperation.java
+++ b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultOperation.java
@@ -19,5 +19,6 @@ package org.apache.camel.component.hashicorp.vault;
public enum HashicorpVaultOperation {
createSecret,
getSecret,
- deleteSecret
+ deleteSecret,
+ listSecrets
}
diff --git a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
index 30a0355a4c1..9798a729fe3 100644
--- a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
+++ b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
@@ -27,6 +27,8 @@ import org.springframework.vault.core.VaultKeyValueOperations;
import org.springframework.vault.core.VaultKeyValueOperationsSupport;
import org.springframework.vault.support.VaultResponse;
+import java.util.List;
+
public class HashicorpVaultProducer extends DefaultProducer {
private static final Logger LOG = LoggerFactory.getLogger(HashicorpVaultProducer.class);
@@ -58,6 +60,9 @@ public class HashicorpVaultProducer extends DefaultProducer {
case deleteSecret:
deleteSecret();
break;
+ case listSecrets:
+ listSecrets(exchange);
+ break;
default:
throw new IllegalArgumentException("Unsupported operation");
}
@@ -96,6 +101,11 @@ public class HashicorpVaultProducer extends DefaultProducer {
keyValue.delete(getEndpoint().getConfiguration().getSecretPath());
}
+ private void listSecrets(Exchange exchange) {
+ List<String> secretsList = getEndpoint().getVaultTemplate().list(getEndpoint().getConfiguration().getSecretsEngine() + "/" + "metadata" + "/");
+ exchange.getMessage().setBody(secretsList);
+ }
+
@Override
public HashicorpVaultEndpoint getEndpoint() {
return (HashicorpVaultEndpoint) super.getEndpoint();