From 132b36ed70e26d64a8226710f0b7759a4d5dbdf3 Mon Sep 17 00:00:00 2001 From: Sean Daniels Date: Thu, 19 Jun 2025 14:01:04 -0400 Subject: [PATCH 1/2] Switch to Apache MINA SSHD for JGit --- build/build.xml | 14 ++++++------- .../jgit/GenericSessionFactory.java | 20 +++++++++---------- .../commandbox/jgit/SSHCallback.java | 3 ++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build/build.xml b/build/build.xml index af91cc51a..a4ff4792f 100644 --- a/build/build.xml +++ b/build/build.xml @@ -1028,13 +1028,13 @@ External Dependencies: - - - - - - - + + + + + + + diff --git a/src/java/com/ortussolutions/commandbox/jgit/GenericSessionFactory.java b/src/java/com/ortussolutions/commandbox/jgit/GenericSessionFactory.java index 0f4e096ff..feee1aa39 100644 --- a/src/java/com/ortussolutions/commandbox/jgit/GenericSessionFactory.java +++ b/src/java/com/ortussolutions/commandbox/jgit/GenericSessionFactory.java @@ -9,19 +9,17 @@ */ package com.ortussolutions.commandbox.jgit; -import org.eclipse.jgit.transport.JschConfigSessionFactory; -import org.eclipse.jgit.transport.OpenSshConfig; -import com.jcraft.jsch.Session; +import org.eclipse.jgit.transport.sshd.SshdSessionFactory; -public class GenericSessionFactory extends JschConfigSessionFactory { +public class GenericSessionFactory extends SshdSessionFactory { - @Override - protected void configure( OpenSshConfig.Host host, Session session ) { - // This prevents users from having the host in "~/.ssh/known_hosts" - java.util.Properties config = new java.util.Properties(); - config.put("StrictHostKeyChecking", "no"); - session.setConfig( config ); - } + /** + * Construct a session factory using the Apache MINA implementation. + * The default configuration matches the previous JSCH behavior of JGit. + */ + public GenericSessionFactory() { + super(); + } } diff --git a/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java b/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java index b4761abb0..e995fdd86 100644 --- a/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java +++ b/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java @@ -11,13 +11,14 @@ import org.eclipse.jgit.api.TransportConfigCallback; import org.eclipse.jgit.transport.*; +import org.eclipse.jgit.transport.sshd.SshdSessionFactory; import com.ortussolutions.commandbox.jgit.GenericSessionFactory; public class SSHCallback implements TransportConfigCallback { public void configure(Transport transport) { - JschConfigSessionFactory genericSessionFactory = new GenericSessionFactory(); + SshdSessionFactory genericSessionFactory = new GenericSessionFactory(); SshTransport sshTransport = ( SshTransport )transport; sshTransport.setSshSessionFactory( genericSessionFactory ); From 110113b5550335c98df28b3a44df3025f0d3aaaa Mon Sep 17 00:00:00 2001 From: Sean Daniels Date: Thu, 19 Jun 2025 14:12:34 -0400 Subject: [PATCH 2/2] Tab & comment fix --- build/build.properties | 2 +- src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/build.properties b/build/build.properties index d38dd09ee..4bb757e66 100644 --- a/build/build.properties +++ b/build/build.properties @@ -26,7 +26,7 @@ runwar.version=5.1.1 # Need to log a ticket with JLine to fix this jline.version=3.21.0 jansi.version=2.4.1 -// TODO: There is a 6.x version of JGit, but I think it's not compat with Java 8 +# TODO: There is a 6.x version of JGit, but I think it's not compat with Java 8 jgit.version=5.13.3.202401111512-r json-smart-mini.version=1.3.2 diff --git a/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java b/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java index e995fdd86..7c5481f2b 100644 --- a/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java +++ b/src/java/com/ortussolutions/commandbox/jgit/SSHCallback.java @@ -18,7 +18,7 @@ public class SSHCallback implements TransportConfigCallback { public void configure(Transport transport) { - SshdSessionFactory genericSessionFactory = new GenericSessionFactory(); + SshdSessionFactory genericSessionFactory = new GenericSessionFactory(); SshTransport sshTransport = ( SshTransport )transport; sshTransport.setSshSessionFactory( genericSessionFactory );