From 15dda8f5c6238710626e1091d4c98fe457d55d4d Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Fri, 8 Nov 2019 19:19:54 +0100 Subject: [PATCH] Update SSHD dependency to version 1.2.0. --- .classpath | 2 +- build.moxie | 2 +- gitblit.iml | 6 +++--- .../gitblit/transport/ssh/LdapKeyManager.java | 2 +- .../transport/ssh/NonForwardingFilter.java | 2 +- .../gitblit/transport/ssh/SshDaemonClient.java | 2 +- src/test/java/com/gitblit/tests/SshUnitTest.java | 16 +++++++++++++++- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.classpath b/.classpath index de9f9172..72a6b6c3 100644 --- a/.classpath +++ b/.classpath @@ -54,7 +54,7 @@ - + diff --git a/build.moxie b/build.moxie index 9deb2fbd..5f5aa63e 100644 --- a/build.moxie +++ b/build.moxie @@ -112,7 +112,7 @@ properties: { bouncycastle.version : 1.57 selenium.version : 2.28.0 wikitext.version : 1.4 - sshd.version: 1.1.0 + sshd.version: 1.2.0 mina.version: 2.0.21 guice.version : 4.0 # Gitblit maintains a fork of guice-servlet diff --git a/gitblit.iml b/gitblit.iml index 07dc10a9..44d79c53 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -541,13 +541,13 @@ - + - + - + diff --git a/src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java b/src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java index 45b692db..9b494027 100644 --- a/src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java +++ b/src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java @@ -26,9 +26,9 @@ import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.sshd.common.config.keys.AuthorizedKeyEntry; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.server.config.keys.AuthorizedKeyEntry; import com.gitblit.IStoredSettings; import com.gitblit.Keys; diff --git a/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java b/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java index 29f7750d..f2176cb0 100644 --- a/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java +++ b/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java @@ -15,8 +15,8 @@ */ package com.gitblit.transport.ssh; -import org.apache.sshd.common.SshdSocketAddress; import org.apache.sshd.common.session.Session; +import org.apache.sshd.common.util.net.SshdSocketAddress; import org.apache.sshd.server.forward.ForwardingFilter; public class NonForwardingFilter implements ForwardingFilter { diff --git a/src/main/java/com/gitblit/transport/ssh/SshDaemonClient.java b/src/main/java/com/gitblit/transport/ssh/SshDaemonClient.java index af25251b..7024a9a9 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshDaemonClient.java +++ b/src/main/java/com/gitblit/transport/ssh/SshDaemonClient.java @@ -17,7 +17,7 @@ package com.gitblit.transport.ssh; import java.net.SocketAddress; -import org.apache.sshd.common.session.Session.AttributeKey; +import org.apache.sshd.common.AttributeStore.AttributeKey; import com.gitblit.models.UserModel; diff --git a/src/test/java/com/gitblit/tests/SshUnitTest.java b/src/test/java/com/gitblit/tests/SshUnitTest.java index dd354d85..075ab43a 100644 --- a/src/test/java/com/gitblit/tests/SshUnitTest.java +++ b/src/test/java/com/gitblit/tests/SshUnitTest.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.SocketAddress; +import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PublicKey; @@ -29,9 +30,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.client.SshClient; import org.apache.sshd.client.channel.ClientChannel; +import org.apache.sshd.client.channel.ClientChannelEvent; +import org.apache.sshd.client.config.keys.ClientIdentityLoader; import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.keyverifier.ServerKeyVerifier; import org.apache.sshd.client.session.ClientSession; +import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.util.SecurityUtils; import org.junit.After; import org.junit.AfterClass; @@ -98,6 +102,16 @@ public abstract class SshUnitTest extends GitblitUnitTest { protected SshClient getClient() { SshClient client = SshClient.setUpDefaultClient(); + client.setClientIdentityLoader(new ClientIdentityLoader() { // Ignore the files under ~/.ssh + @Override + public boolean isValidLocation(String location) throws IOException { + return true; + } + @Override + public KeyPair loadClientIdentity(String location, FilePasswordProvider provider) throws IOException, GeneralSecurityException { + return null; + } + }); client.setServerKeyVerifier(new ServerKeyVerifier() { @Override public boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) { @@ -135,7 +149,7 @@ public abstract class SshUnitTest extends GitblitUnitTest { channel.setErr(err); channel.open(); - channel.waitFor(EnumSet.of(ClientChannel.ClientChannelEvent.CLOSED), 0); + channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0); String result = out.toString().trim(); channel.close(false); -- 2.39.5