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 2020/08/10 12:20:33 UTC

[camel-kafka-connector] branch master updated: Building endpoint uris should for secret options automatic use RAW() syntax for the value so we wont have encoding issue for passwords or access tokens etc.

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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git


The following commit(s) were added to refs/heads/master by this push:
     new f58ad26  Building endpoint uris should for secret options automatic use RAW() syntax for the value so we wont have encoding issue for passwords or access tokens etc.
f58ad26 is described below

commit f58ad263ee34e1a429e9d0d23b1030d7667af67b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 10 14:20:17 2020 +0200

    Building endpoint uris should for secret options automatic use RAW() syntax for the value so we wont have encoding issue for passwords or access tokens etc.
---
 .../org/apache/camel/kafkaconnector/utils/TaskHelper.java |  2 +-
 .../apache/camel/kafkaconnector/CamelSinkTaskTest.java    | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java b/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
index 321fd8d..6fbeb20 100644
--- a/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
+++ b/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
@@ -58,7 +58,7 @@ public final class TaskHelper {
             for (String k : filteredProps.keySet()) {
                 if (isSecretOption(rcc, cm, k)) {
                     String value = filteredProps.get(k);
-                    if (value != null && !value.startsWith("RAW(")) {
+                    if (value != null && !value.startsWith("#") && !value.startsWith("RAW(")) {
                         value = "RAW(" + value + ")";
                         filteredProps.put(k, value);
                     }
diff --git a/core/src/test/java/org/apache/camel/kafkaconnector/CamelSinkTaskTest.java b/core/src/test/java/org/apache/camel/kafkaconnector/CamelSinkTaskTest.java
index b9af651..f4bb812 100644
--- a/core/src/test/java/org/apache/camel/kafkaconnector/CamelSinkTaskTest.java
+++ b/core/src/test/java/org/apache/camel/kafkaconnector/CamelSinkTaskTest.java
@@ -646,4 +646,19 @@ public class CamelSinkTaskTest {
         sinkTask.stop();
     }
 
+    @Test
+    public void testSecretRawReference() {
+        Map<String, String> props = new HashMap<>();
+        props.put(CamelSinkConnectorConfig.TOPIC_CONF, TOPIC_NAME);
+        props.put("camel.sink.endpoint.secretKey", "#bean:mySecretKey");
+        props.put("camel.sink.endpoint.accessKey", "#property:myAccessKey");
+        props.put(CamelSinkConnectorConfig.CAMEL_SINK_COMPONENT_CONF, "aws2-sqs");
+        props.put("myAccessKey", "MoreSe+ret$");
+
+        CamelSinkTask sinkTask = new CamelSinkTask();
+        sinkTask.start(props);
+
+        sinkTask.stop();
+    }
+
 }