Skip to content

Commit 6b2a873

Browse files
committed
Switch uses of JSch library to the com.github.mwiede:jsch fork
The original Jcraft version of the JSch library has not seen updates in over a decade. The current fork with the most active maintenance is the com.github.mwiede:jsch library and it is largely compatible with the original but with secure defaults. It also absorbed the Jzlib implementation in its own code base and eliminated the need to have the extra dependencies. As this is only a test dependency for this code base I feel adding this update is an improvement.
1 parent de46a15 commit 6b2a873

File tree

12 files changed

+22
-61
lines changed

12 files changed

+22
-61
lines changed

pom.xml

+2-7
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,9 @@
504504
</dependency>
505505

506506
<dependency>
507-
<groupId>com.jcraft</groupId>
507+
<groupId>com.github.mwiede</groupId>
508508
<artifactId>jsch</artifactId>
509-
<version>0.1.55</version>
510-
</dependency>
511-
<dependency>
512-
<groupId>com.jcraft</groupId>
513-
<artifactId>jzlib</artifactId>
514-
<version>1.1.3</version>
509+
<version>0.2.17</version>
515510
</dependency>
516511

517512
<!-- Transitive dependencies by various 3rd party packages -->

sshd-cli/pom.xml

+1-6
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,10 @@
9292
</dependency>
9393

9494
<dependency>
95-
<groupId>com.jcraft</groupId>
95+
<groupId>com.github.mwiede</groupId>
9696
<artifactId>jsch</artifactId>
9797
<scope>test</scope>
9898
</dependency>
99-
<dependency>
100-
<groupId>com.jcraft</groupId>
101-
<artifactId>jzlib</artifactId>
102-
<scope>test</scope>
103-
</dependency>
10499
</dependencies>
105100

106101
<build>

sshd-core/pom.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,10 @@
8181
<scope>test</scope>
8282
</dependency>
8383
<dependency>
84-
<groupId>com.jcraft</groupId>
84+
<groupId>com.github.mwiede</groupId>
8585
<artifactId>jsch</artifactId>
8686
<scope>test</scope>
8787
</dependency>
88-
<dependency>
89-
<groupId>com.jcraft</groupId>
90-
<artifactId>jzlib</artifactId>
91-
<scope>test</scope>
92-
</dependency>
9388
<dependency>
9489
<groupId>org.springframework</groupId>
9590
<artifactId>spring-context</artifactId>
@@ -246,6 +241,8 @@
246241
<configuration>
247242
<reportsDirectory>${project.build.directory}/surefire-reports-jce</reportsDirectory>
248243
<systemProperties>
244+
<!-- Enable using deprecated ssh-rsa signature keys with JSch 0.2.x -->
245+
<jsch.server_host_key>ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa</jsch.server_host_key>
249246
<org.apache.sshd.security.provider.BC.enabled>false</org.apache.sshd.security.provider.BC.enabled>
250247
<!-- deprecated -->
251248
<org.apache.sshd.registerBouncyCastle>false</org.apache.sshd.registerBouncyCastle>

sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public void setUp() throws Exception {
121121
String name = factory.getName();
122122
JSch.setConfig("compression.s2c", name);
123123
JSch.setConfig("compression.c2s", name);
124-
JSch.setConfig("zlib", com.jcraft.jsch.jcraft.Compression.class.getName());
125-
JSch.setConfig("zlib@openssh.com", com.jcraft.jsch.jcraft.Compression.class.getName());
124+
JSch.setConfig("zlib", com.jcraft.jsch.jzlib.Compression.class.getName());
125+
JSch.setConfig("zlib@openssh.com", com.jcraft.jsch.jzlib.Compression.class.getName());
126126
}
127127

128128
@After

sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthInteractiveTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,10 @@ public void showMessage(String s) {
8282
session.connect();
8383
} catch (JSchException e) {
8484
String reason = e.getMessage();
85-
switch (reason) {
86-
case "Auth cancel":
87-
case "Auth fail":
88-
return false;
89-
default:
90-
throw e;
85+
if (reason != null && (reason.startsWith("Auth cancel") || reason.startsWith("Auth fail"))) {
86+
return false;
9187
}
88+
throw e;
9289
}
9390

9491
try {

sshd-core/src/test/java/org/apache/sshd/server/auth/AsyncAuthTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.apache.sshd.server.auth;
2020

21-
import java.util.Objects;
22-
2321
import com.jcraft.jsch.ChannelShell;
2422
import com.jcraft.jsch.JSch;
2523
import com.jcraft.jsch.JSchException;
@@ -86,7 +84,7 @@ public void showMessage(String s) {
8684
session.connect();
8785
} catch (JSchException e) {
8886
String reason = e.getMessage();
89-
if (Objects.equals(reason, "Auth cancel")) {
87+
if (reason != null && reason.startsWith("Auth cancel")) {
9088
return false;
9189
} else {
9290
throw e;

sshd-git/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<scope>test</scope>
118118
</dependency>
119119
<dependency>
120-
<groupId>com.jcraft</groupId>
120+
<groupId>com.github.mwiede</groupId>
121121
<artifactId>jsch</artifactId>
122122
<scope>test</scope>
123123
</dependency>

sshd-mina/pom.xml

+1-6
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@
7575
<scope>test</scope>
7676
</dependency>
7777
<dependency>
78-
<groupId>com.jcraft</groupId>
78+
<groupId>com.github.mwiede</groupId>
7979
<artifactId>jsch</artifactId>
8080
<scope>test</scope>
8181
</dependency>
82-
<dependency>
83-
<groupId>com.jcraft</groupId>
84-
<artifactId>jzlib</artifactId>
85-
<scope>test</scope>
86-
</dependency>
8782
<dependency>
8883
<groupId>org.springframework</groupId>
8984
<artifactId>spring-context</artifactId>

sshd-netty/pom.xml

+1-6
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,10 @@
9696
<scope>test</scope>
9797
</dependency>
9898
<dependency>
99-
<groupId>com.jcraft</groupId>
99+
<groupId>com.github.mwiede</groupId>
100100
<artifactId>jsch</artifactId>
101101
<scope>test</scope>
102102
</dependency>
103-
<dependency>
104-
<groupId>com.jcraft</groupId>
105-
<artifactId>jzlib</artifactId>
106-
<scope>test</scope>
107-
</dependency>
108103
<dependency>
109104
<groupId>org.springframework</groupId>
110105
<artifactId>spring-context</artifactId>

sshd-scp/pom.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<scope>test</scope>
5757
</dependency>
5858
<dependency>
59-
<groupId>com.jcraft</groupId>
59+
<groupId>com.github.mwiede</groupId>
6060
<artifactId>jsch</artifactId>
6161
<scope>test</scope>
6262
</dependency>
@@ -65,11 +65,6 @@
6565
<artifactId>ganymed-ssh2</artifactId>
6666
<scope>test</scope>
6767
</dependency>
68-
<dependency>
69-
<groupId>com.jcraft</groupId>
70-
<artifactId>jzlib</artifactId>
71-
<scope>test</scope>
72-
</dependency>
7368
<dependency>
7469
<groupId>org.testcontainers</groupId>
7570
<artifactId>testcontainers</artifactId>
@@ -105,6 +100,8 @@
105100
<redirectTestOutputToFile>true</redirectTestOutputToFile>
106101
<reportsDirectory>${project.build.directory}/surefire-reports-nio2</reportsDirectory>
107102
<systemProperties>
103+
<!-- Enable using deprecated ssh-rsa signature keys with JSch 0.2.x -->
104+
<jsch.server_host_key>ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa</jsch.server_host_key>
108105
<org.apache.sshd.common.io.IoServiceFactoryFactory>org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory</org.apache.sshd.common.io.IoServiceFactoryFactory>
109106
</systemProperties>
110107
</configuration>

sshd-sftp/pom.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,10 @@
5656
<scope>test</scope>
5757
</dependency>
5858
<dependency>
59-
<groupId>com.jcraft</groupId>
59+
<groupId>com.github.mwiede</groupId>
6060
<artifactId>jsch</artifactId>
6161
<scope>test</scope>
6262
</dependency>
63-
<dependency>
64-
<groupId>com.jcraft</groupId>
65-
<artifactId>jzlib</artifactId>
66-
<scope>test</scope>
67-
</dependency>
6863
<dependency>
6964
<groupId>org.testcontainers</groupId>
7065
<artifactId>testcontainers</artifactId>
@@ -112,6 +107,8 @@
112107
<redirectTestOutputToFile>true</redirectTestOutputToFile>
113108
<reportsDirectory>${project.build.directory}/surefire-reports-nio2</reportsDirectory>
114109
<systemProperties>
110+
<!-- Enable using deprecated ssh-rsa signature keys with JSch 0.2.x -->
111+
<jsch.server_host_key>ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa</jsch.server_host_key>
115112
<org.apache.sshd.common.io.IoServiceFactoryFactory>org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory</org.apache.sshd.common.io.IoServiceFactoryFactory>
116113
</systemProperties>
117114
</configuration>

sshd-spring-sftp/pom.xml

+1-6
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@
7575
<scope>test</scope>
7676
</dependency>
7777
<dependency>
78-
<groupId>com.jcraft</groupId>
78+
<groupId>com.github.mwiede</groupId>
7979
<artifactId>jsch</artifactId>
8080
<scope>test</scope>
8181
</dependency>
82-
<dependency>
83-
<groupId>com.jcraft</groupId>
84-
<artifactId>jzlib</artifactId>
85-
<scope>test</scope>
86-
</dependency>
8782
<dependency>
8883
<groupId>org.apache.sshd</groupId>
8984
<artifactId>sshd-core</artifactId>

0 commit comments

Comments
 (0)