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/06/09 09:56:45 UTC

[camel] branch main updated (c6053f9e454 -> 5ed03d60b88)

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

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from c6053f9e454 (chores) ci: fixed incorrect name for the alternative OS build
     new 4bbf1273a83 Upgrade JT400 to version 11.0
     new 84b0ec77185 Sync deps
     new 432f3b8c1b7 CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read secret operation
     new 5ed03d60b88 CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read Secret operation

The 4 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.


Summary of changes:
 camel-dependencies/pom.xml                         |  2 +-
 .../component/hashicorp/vault/hashicorp-vault.json |  5 +-
 .../hashicorp/vault/HashicorpVaultConstants.java   |  6 +-
 .../hashicorp/vault/HashicorpVaultOperation.java   |  3 +-
 .../hashicorp/vault/HashicorpVaultProducer.java    | 17 ++++++
 .../operations/HashicorpProducerReadSecretIT.java  | 66 ++++++++++++++++++++++
 parent/pom.xml                                     |  2 +-
 7 files changed, 95 insertions(+), 6 deletions(-)
 create mode 100644 components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java


[camel] 01/04: Upgrade JT400 to version 11.0

Posted by ac...@apache.org.
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 4bbf1273a83de105e133a9cb52945fbca52fa672
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jun 9 10:03:49 2022 +0200

    Upgrade JT400 to version 11.0
---
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 8263f5c0c3b..c28091e43c9 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -337,7 +337,7 @@
         <json-schema-validator-version>2.2.14</json-schema-validator-version>
         <json-unit-version>2.32.0</json-unit-version>
         <jsoup-version>1.14.3</jsoup-version>
-        <jt400-version>10.7</jt400-version>
+        <jt400-version>11.0</jt400-version>
         <junit-toolbox-version>2.4</junit-toolbox-version>
         <junit-version>4.13.2</junit-version>
         <junit-jupiter-version>5.8.2</junit-jupiter-version>


[camel] 04/04: CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read Secret operation

Posted by ac...@apache.org.
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 5ed03d60b88d0e7d60966eebfa78f573b80515c1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jun 9 10:52:32 2022 +0200

    CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read Secret operation
---
 .../operations/HashicorpProducerReadSecretIT.java  | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java
new file mode 100644
index 00000000000..045092a9070
--- /dev/null
+++ b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java
@@ -0,0 +1,66 @@
+package org.apache.camel.component.hashicorp.vault.integration.operations;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.hashicorp.vault.HashicorpVaultConstants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@Disabled("Disabled until we'll have a Camel-Hashicorp-vault test-infra module")
+public class HashicorpProducerReadSecretIT extends CamelTestSupport {
+
+    @EndpointInject("mock:result")
+    private MockEndpoint mock;
+
+    @Test
+    public void createSecretTest() throws InterruptedException {
+
+        mock.expectedMessageCount(1);
+        Exchange exchange = template.request("direct:readSecret", new Processor() {
+            @Override
+            public void process(Exchange exchange) {
+                exchange.getMessage().setHeader(HashicorpVaultConstants.SECRET_PATH, "myapp");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+        Exchange ret = mock.getExchanges().get(0);
+        assertNotNull(ret);
+        assertEquals(((Map)ret.getMessage().getBody(Map.class).get("data")).get("id"), "12");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:readSecret")
+                        .to("hashicorp-vault://secret?operation=getSecret&token=RAW(token)&host=localhost&scheme=http")
+                        .to("mock:result");
+            }
+        };
+    }
+
+    class Secrets {
+
+        String username;
+        String password;
+
+        public String getUsername() {
+            return username;
+        }
+
+        public String getPassword() {
+            return password;
+        }
+    }
+}


[camel] 03/04: CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read secret operation

Posted by ac...@apache.org.
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 432f3b8c1b7082dea64a60fbf59365100d032ccc
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jun 9 10:50:54 2022 +0200

    CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read secret operation
---
 .../component/hashicorp/vault/hashicorp-vault.json      |  5 +++--
 .../hashicorp/vault/HashicorpVaultConstants.java        |  6 +++++-
 .../hashicorp/vault/HashicorpVaultOperation.java        |  3 ++-
 .../hashicorp/vault/HashicorpVaultProducer.java         | 17 +++++++++++++++++
 4 files changed, 27 insertions(+), 4 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 30add6e5bd2..c622121c0ec 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
@@ -26,13 +26,14 @@
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
   },
   "headers": {
-    "CamelHashicorpVaultProducerOperation": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.azure.key.vault.KeyVaultOperationDefinition", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Overrides the desired operation to be used in the producer.", "constantName": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConstants#OPERATION" }
+    "CamelHashicorpVaultProducerOperation": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Overrides the desired operation to be used in the producer.", "constantName": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConstants#OPERATION" },
+    "CamelHashicorpVaultSecretPath": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Set the desired secret path as header.", "constantName": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConstants#SECRET_PATH" }
   },
   "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" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...]
-    "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.hashicorp.vault.HashicorpVaultOperation", "enum": [ "createSecret" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Operation to be performed" },
+    "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.hashicorp.vault.HashicorpVaultOperation", "enum": [ "createSecret", "getSecret" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.hashicorp.vault.HashicorpVaultConfiguration", "configurationField": "configuration", "description": "Operation to  [...]
     "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/HashicorpVaultConstants.java b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultConstants.java
index a6c7afc2e6b..3f3cb0d6e6e 100644
--- a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultConstants.java
+++ b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultConstants.java
@@ -23,9 +23,13 @@ public final class HashicorpVaultConstants {
 
     // headers set by the producer only
     @Metadata(label = "producer", description = "Overrides the desired operation to be used in the producer.",
-              javaType = "org.apache.camel.component.azure.key.vault.KeyVaultOperationDefinition")
+              javaType = "String")
     public static final String OPERATION = HEADER_PREFIX + "ProducerOperation";
 
+    // headers set by the producer only
+    @Metadata(label = "producer", description = "Set the desired secret path as header.",
+            javaType = "String")
+    public static final String SECRET_PATH = HEADER_PREFIX + "SecretPath";
     private HashicorpVaultConstants() {
     }
 }
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 70d314382e5..2023dd8ed52 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
@@ -17,5 +17,6 @@
 package org.apache.camel.component.hashicorp.vault;
 
 public enum HashicorpVaultOperation {
-    createSecret
+    createSecret,
+    getSecret
 }
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 e6e5582840b..7855be2bce1 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
@@ -21,10 +21,12 @@ import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.vault.core.VaultKeyValueOperations;
 import org.springframework.vault.core.VaultKeyValueOperationsSupport;
+import org.springframework.vault.support.VaultResponse;
 
 public class HashicorpVaultProducer extends DefaultProducer {
 
@@ -51,6 +53,9 @@ public class HashicorpVaultProducer extends DefaultProducer {
             case createSecret:
                 createSecret(exchange);
                 break;
+            case getSecret:
+                getSecret(exchange);
+                break;
             default:
                 throw new IllegalArgumentException("Unsupported operation");
         }
@@ -63,6 +68,18 @@ public class HashicorpVaultProducer extends DefaultProducer {
         keyValue.put(getEndpoint().getConfiguration().getSecretPath(), exchange.getMessage().getBody());
     }
 
+    private void getSecret(Exchange exchange) throws InvalidPayloadException {
+        String secretPath;
+        if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(HashicorpVaultConstants.SECRET_PATH))) {
+            secretPath = exchange.getMessage().getHeader(HashicorpVaultConstants.SECRET_PATH, String.class);
+        } else {
+        throw new IllegalArgumentException("Secret Path must be specified");
+        }
+        String completePath = getEndpoint().getConfiguration().getSecretsEngine() + "/" + "data" + "/" + secretPath;
+        VaultResponse rawSecret = getEndpoint().getVaultTemplate().read(completePath);
+        exchange.getMessage().setBody(rawSecret.getData());
+    }
+
     @Override
     public HashicorpVaultEndpoint getEndpoint() {
         return (HashicorpVaultEndpoint) super.getEndpoint();


[camel] 02/04: Sync deps

Posted by ac...@apache.org.
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 84b0ec7718562708b34354101713b1bdede6c6d4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jun 9 10:05:40 2022 +0200

    Sync deps
---
 camel-dependencies/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 77d4bf0893b..22a8c2b366b 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -352,7 +352,7 @@
     <jsonassert-version>1.5.0</jsonassert-version>
     <jsonata4java-version>1.5.8</jsonata4java-version>
     <jsoup-version>1.14.3</jsoup-version>
-    <jt400-version>10.7</jt400-version>
+    <jt400-version>11.0</jt400-version>
     <jta-api-1.2-version>1.2</jta-api-1.2-version>
     <junit-jupiter-version>5.8.2</junit-jupiter-version>
     <junit-toolbox-version>2.4</junit-toolbox-version>