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/11/22 15:07:18 UTC

[camel-kamelets] 02/03: SFTP connectors missing authentication options to use a private key

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

acosentino pushed a commit to branch 1167
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit 507a05e8e6ac4391dc2ddaaa4bc528b195a23db2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 22 13:11:12 2022 +0100

    SFTP connectors missing authentication options to use a private key
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../main/resources/kamelets/sftp-sink.kamelet.yaml | 37 ++++++++++++++++---
 .../resources/kamelets/sftp-source.kamelet.yaml    | 41 ++++++++++++++++++----
 2 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/library/camel-kamelets/src/main/resources/kamelets/sftp-sink.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/sftp-sink.kamelet.yaml
index cfa4dbd3..fb178fd8 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/sftp-sink.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/sftp-sink.kamelet.yaml
@@ -38,8 +38,6 @@ spec:
     required:
       - connectionHost
       - connectionPort
-      - username
-      - password
       - directoryName
     type: object
     properties:
@@ -89,6 +87,31 @@ spec:
         default: false
         x-descriptors:
         - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
+      privateKeyFile:
+        title: Private Key File
+        description: Set the private key file so that the SFTP endpoint can do private key verification.
+        type: string
+      privateKeyPassphrase:
+        title: Private Key Passphrase
+        description: Set the private key file passphrase so that the SFTP endpoint can do private key verification.
+        type: string
+      privateKeyUri:
+        title: Private Key URI
+        description: Set the private key file (loaded from classpath by default) so that the SFTP endpoint can do private key verification.
+        type: string
+        pattern: "^(http|https|file|classpath)://.*"
+      strictHostKeyChecking:
+        title: Strict Host Checking
+        description: Sets whether to use strict host key checking.
+        type: string
+        default: no
+      useUserKnownHostsFile:
+        title: Use User Known Hosts File
+        description: If knownHostFile has not been explicit configured then use the host file from System.getProperty(user.home)/.ssh/known_hosts.
+        type: boolean
+        default: true
+        x-descriptors:
+        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
   dependencies:
     - "camel:ftp"
     - "camel:core"
@@ -110,9 +133,15 @@ spec:
                 name: CamelFileName
                 simple: "${header[ce-file]}"
       - to:
-          uri: "sftp:{{username}}@{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
+          uri: "sftp:{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
           parameters:
-            password: "{{password}}"
+            username: "{{?username}}"
+            password: "{{?password}}"
+            privateKeyFile: "{{?privateKeyFile}}"
+            privateKeyPassphrase: "{{?privateKeyPassphrase}}"
+            privateKeyUri: "{{?privateKeyUri}}"
+            strictHostKeyChecking: "{{?strictHostKeyChecking}}"
+            useUserKnownHostsFile: "{{?useUserKnownHostsFile}}"            
             passiveMode: "{{passiveMode}}"
             fileExist: "{{fileExist}}"
             binary: "{{binary}}"
diff --git a/library/camel-kamelets/src/main/resources/kamelets/sftp-source.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/sftp-source.kamelet.yaml
index 8ef6d183..d65d18fe 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/sftp-source.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/sftp-source.kamelet.yaml
@@ -34,8 +34,6 @@ spec:
     required:
       - connectionHost
       - connectionPort
-      - username
-      - password
       - directoryName
     type: object
     properties:
@@ -101,27 +99,58 @@ spec:
         default: false
         x-descriptors:
         - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
+      privateKeyFile:
+        title: Private Key File
+        description: Set the private key file so that the SFTP endpoint can do private key verification.
+        type: string
+      privateKeyPassphrase:
+        title: Private Key Passphrase
+        description: Set the private key file passphrase so that the SFTP endpoint can do private key verification.
+        type: string
+      privateKeyUri:
+        title: Private Key URI
+        description: Set the private key file (loaded from classpath by default) so that the SFTP endpoint can do private key verification.
+        type: string
+        pattern: "^(http|https|file|classpath)://.*"
+      strictHostKeyChecking:
+        title: Strict Host Checking
+        description: Sets whether to use strict host key checking.
+        type: string
+        default: no
+      useUserKnownHostsFile:
+        title: Use User Known Hosts File
+        description: If knownHostFile has not been explicit configured then use the host file from System.getProperty(user.home)/.ssh/known_hosts.
+        type: boolean
+        default: true
+        x-descriptors:
+        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
   dependencies:
     - "camel:ftp"
     - "camel:core"
     - "camel:kamelet"
   template:
     from:
-      uri: "sftp:{{username}}@{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
+      uri: "sftp:{{connectionHost}}:{{connectionPort}}/{{directoryName}}"
       parameters:
-        password: "{{password}}"
+        username: "{{?username}}"
+        password: "{{?password}}"
+        privateKeyFile: "{{?privateKeyFile}}"
+        privateKeyPassphrase: "{{?privateKeyPassphrase}}"
+        privateKeyUri: "{{?privateKeyUri}}"
+        strictHostKeyChecking: "{{?strictHostKeyChecking}}"
+        useUserKnownHostsFile: "{{?useUserKnownHostsFile}}"   
         passiveMode: "{{passiveMode}}"
         recursive: "{{recursive}}"
         idempotent: "{{idempotent}}"
         ignoreFileNotFoundOrPermissionError: "{{ignoreFileNotFoundOrPermissionError}}"
         binary: "{{binary}}"
       steps:
+      - set-body:
+          simple: "${body.getBody()}"
       - set-header:
           name: file
           simple: "${header[CamelFileName]}"
       - set-header:
           name: ce-file
           simple: "${header[CamelFileName]}"
-      - convert-body-to:
-          type: "java.io.InputStream"
       - to: "kamelet:sink"