This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 3a7e1f3b774 CAMEL-21657: camel-ftp - Add dev console to dump jsch
config
3a7e1f3b774 is described below
commit 3a7e1f3b774aa1d7f125f573073fe0df9f043bf4
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jan 27 18:22:19 2025 +0100
CAMEL-21657: camel-ftp - Add dev console to dump jsch config
---
.../apache/camel/catalog/dev-consoles.properties | 1 +
.../apache/camel/catalog/dev-consoles/sftp.json | 15 +++++
.../org/apache/camel/dev-console/sftp.json | 15 +++++
.../services/org/apache/camel/dev-console/sftp | 2 +
.../org/apache/camel/dev-consoles.properties | 7 +++
.../component/file/remote/SftpDevConsole.java | 68 ++++++++++++++++++++++
6 files changed, 108 insertions(+)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
index 41c1ba05629..c2b95c3bd17 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
@@ -39,6 +39,7 @@ route-controller
route-dump
send
service
+sftp
source
startup-recorder
stub
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/sftp.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/sftp.json
new file mode 100644
index 00000000000..6f218bfa4dc
--- /dev/null
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/sftp.json
@@ -0,0 +1,15 @@
+{
+ "console": {
+ "kind": "console",
+ "group": "camel",
+ "name": "sftp",
+ "title": "SFTP",
+ "description": "Secure FTP using JSCH",
+ "deprecated": false,
+ "javaType": "org.apache.camel.component.file.remote.SftpDevConsole",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-ftp",
+ "version": "4.10.0-SNAPSHOT"
+ }
+}
+
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/dev-console/sftp.json
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/dev-console/sftp.json
new file mode 100644
index 00000000000..6f218bfa4dc
--- /dev/null
+++
b/components/camel-ftp/src/generated/resources/META-INF/org/apache/camel/dev-console/sftp.json
@@ -0,0 +1,15 @@
+{
+ "console": {
+ "kind": "console",
+ "group": "camel",
+ "name": "sftp",
+ "title": "SFTP",
+ "description": "Secure FTP using JSCH",
+ "deprecated": false,
+ "javaType": "org.apache.camel.component.file.remote.SftpDevConsole",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-ftp",
+ "version": "4.10.0-SNAPSHOT"
+ }
+}
+
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-console/sftp
b/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-console/sftp
new file mode 100644
index 00000000000..c396079e798
--- /dev/null
+++
b/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-console/sftp
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.file.remote.SftpDevConsole
diff --git
a/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
b/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
new file mode 100644
index 00000000000..2b097be644a
--- /dev/null
+++
b/components/camel-ftp/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+dev-consoles=sftp
+groupId=org.apache.camel
+artifactId=camel-ftp
+version=4.10.0-SNAPSHOT
+projectName=Camel :: FTP
+projectDescription=Camel FTP support
diff --git
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
new file mode 100644
index 00000000000..5f2cca61d65
--- /dev/null
+++
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpDevConsole.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import com.jcraft.jsch.JSch;
+import org.apache.camel.spi.annotations.DevConsole;
+import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.json.JsonObject;
+
+@DevConsole(name = "sftp", displayName = "SFTP", description = "Secure FTP
using JSCH")
+public class SftpDevConsole extends AbstractDevConsole {
+
+ public SftpDevConsole() {
+ super("camel", "sftp", "SFTP", "Secure FTP using JSCH");
+ }
+
+ @Override
+ protected String doCallText(Map<String, Object> options) {
+ StringBuilder sb = new StringBuilder();
+
+ // sort configs
+ Map<String, Object> map = new TreeMap<>(String::compareToIgnoreCase);
+ map.putAll(JSch.getConfig());
+
+ sb.append("SFTP Configuration\n");
+ for (var e : map.entrySet()) {
+ String v = e.getValue() != null ? e.getValue().toString() : "";
+ sb.append(String.format("\n %s = %s", e.getKey(), v));
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ protected Map<String, Object> doCallJson(Map<String, Object> options) {
+ JsonObject root = new JsonObject();
+
+ // sort configs
+ Map<String, Object> map = new TreeMap<>(String::compareToIgnoreCase);
+ map.putAll(JSch.getConfig());
+
+ JsonObject jo = new JsonObject();
+ for (var e : map.entrySet()) {
+ String v = e.getValue() != null ? e.getValue().toString() : "";
+ jo.put(e.getKey(), e.getValue());
+ }
+ root.put("config", jo);
+
+ return root;
+ }
+}