]> source.dussan.org Git - gitblit.git/commitdiff
Update SSHD dependency to version 1.1.0.
authorFlorian Zschocke <florian.zschocke@devolo.de>
Fri, 8 Nov 2019 16:26:06 +0000 (17:26 +0100)
committerFlorian Zschocke <florian.zschocke@devolo.de>
Sun, 10 Nov 2019 12:03:20 +0000 (13:03 +0100)
.classpath
build.moxie
gitblit.iml
src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java
src/main/java/com/gitblit/transport/ssh/SshDaemon.java
src/main/java/com/gitblit/transport/ssh/SshServerSessionFactory.java
src/test/java/com/gitblit/tests/SshDaemonTest.java
src/test/java/com/gitblit/tests/SshUnitTest.java

index 46210ac34f70e0fc1f47abc506629433fd91650d..de9f91727d8d414db2d75fa63e98225283fa42a1 100644 (file)
@@ -54,7 +54,7 @@
        <classpathentry kind="lib" path="ext/bcprov-jdk15on-1.57.jar" sourcepath="ext/src/bcprov-jdk15on-1.57.jar" />
        <classpathentry kind="lib" path="ext/bcmail-jdk15on-1.57.jar" sourcepath="ext/src/bcmail-jdk15on-1.57.jar" />
        <classpathentry kind="lib" path="ext/bcpkix-jdk15on-1.57.jar" sourcepath="ext/src/bcpkix-jdk15on-1.57.jar" />
-       <classpathentry kind="lib" path="ext/sshd-core-1.0.0.jar" sourcepath="ext/src/sshd-core-1.0.0.jar" />
+       <classpathentry kind="lib" path="ext/sshd-core-1.1.0.jar" sourcepath="ext/src/sshd-core-1.1.0.jar" />
        <classpathentry kind="lib" path="ext/mina-core-2.0.21.jar" sourcepath="ext/src/mina-core-2.0.21.jar" />
        <classpathentry kind="lib" path="ext/rome-0.9.jar" sourcepath="ext/src/rome-0.9.jar" />
        <classpathentry kind="lib" path="ext/jdom-1.0.jar" sourcepath="ext/src/jdom-1.0.jar" />
index 85e2f492ef5e3d17248cf6671d34f8bcc010428c..9deb2fbd1387ec24f6912f06d21bb4fcce6b8c7c 100644 (file)
@@ -112,7 +112,7 @@ properties: {
   bouncycastle.version : 1.57
   selenium.version : 2.28.0
   wikitext.version : 1.4
-  sshd.version: 1.0.0
+  sshd.version: 1.1.0
   mina.version: 2.0.21
   guice.version : 4.0
   # Gitblit maintains a fork of guice-servlet
index f935fc17e180d967e412299aa403f193aa2d9b9e..07dc10a94a1ba22a2dd64d37d727ee926cffd6ad 100644 (file)
       </library>
     </orderEntry>
     <orderEntry type="module-library">
-      <library name="sshd-core-1.0.0.jar">
+      <library name="sshd-core-1.1.0.jar">
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/ext/sshd-core-1.0.0.jar!/" />
+          <root url="jar://$MODULE_DIR$/ext/sshd-core-1.1.0.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES>
-          <root url="jar://$MODULE_DIR$/ext/src/sshd-core-1.0.0.jar!/" />
+          <root url="jar://$MODULE_DIR$/ext/src/sshd-core-1.1.0.jar!/" />
         </SOURCES>
       </library>
     </orderEntry>
index c62c4dee2d05fe4b91eb6f7a02cc0ecf14048536..45b692db91e180dfd09fa0703e02fdae9ca1cd5c 100644 (file)
@@ -212,7 +212,7 @@ public class LdapKeyManager extends IPublicKeyManager {
                                        List<SshKey> keyList = new ArrayList<>(authorizedKeys.size());
                                        for (GbAuthorizedKeyEntry keyEntry : authorizedKeys) {
                                                try {
-                                                       SshKey key = new SshKey(keyEntry.resolvePublicKey());
+                                                       SshKey key = new SshKey(keyEntry.resolvePublicKey(null));
                                                        key.setComment(keyEntry.getComment());
                                                        setKeyPermissions(key, keyEntry);
                                                        keyList.add(key);
index 5a0537812af9682e4a2748d00d7d533d87b23665..63fa51dd04439747c9775e6d4530abfe331477c3 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory;
 import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
 import org.apache.sshd.common.util.SecurityUtils;
 import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.auth.CachingPublicKeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.CachingPublicKeyAuthenticator;
 import org.bouncycastle.openssl.PEMWriter;
 import org.eclipse.jgit.internal.JGitText;
 import org.slf4j.Logger;
@@ -158,7 +158,7 @@ public class SshDaemon {
                        log.info("SSH: adding GSSAPI authentication method.");
                }
 
-               sshd.setSessionFactory(new SshServerSessionFactory());
+               sshd.setSessionFactory(new SshServerSessionFactory(sshd));
                sshd.setFileSystemFactory(new DisabledFilesystemFactory());
                sshd.setTcpipForwardingFilter(new NonForwardingFilter());
                sshd.setCommandFactory(new SshCommandFactory(gitblit, workQueue));
index bc67cec0cf5ea9b207212874be0c7803a42a1e6b..fb85781ab7149d89d4b0b9d4c1adc923bad14b32 100644 (file)
@@ -22,7 +22,8 @@ import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.io.mina.MinaSession;
-import org.apache.sshd.common.session.AbstractSession;
+import org.apache.sshd.server.ServerFactoryManager;
+import org.apache.sshd.server.session.ServerSessionImpl;
 import org.apache.sshd.server.session.SessionFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,11 +37,12 @@ public class SshServerSessionFactory extends SessionFactory {
 
        private final Logger log = LoggerFactory.getLogger(getClass());
 
-       public SshServerSessionFactory() {
+       public SshServerSessionFactory(ServerFactoryManager server) {
+               super(server);
        }
 
        @Override
-       protected AbstractSession createSession(final IoSession io) throws Exception {
+       protected ServerSessionImpl createSession(final IoSession io) throws Exception {
                log.info("creating ssh session from {}", io.getRemoteAddress());
 
                if (io instanceof MinaSession) {
@@ -66,7 +68,7 @@ public class SshServerSessionFactory extends SessionFactory {
        }
 
        @Override
-       protected AbstractSession doCreateSession(IoSession ioSession) throws Exception {
+       protected ServerSessionImpl doCreateSession(IoSession ioSession) throws Exception {
                return new SshServerSession(getServer(), ioSession);
        }
 }
index c5deb7d514463da5bda509b7d76cdd90f4f66d73..c7d06198aaaccc8b2818bda9e0593d1d76bb93dd 100644 (file)
@@ -44,9 +44,9 @@ public class SshDaemonTest extends SshUnitTest {
        @Test
        public void testPublicKeyAuthentication() throws Exception {
                SshClient client = getClient();
-               ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).await().getSession();
+               ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).verify().getSession();
                session.addPublicKeyIdentity(rwKeyPair);
-               assertTrue(session.auth().await().isSuccess());
+               assertTrue(session.auth().await());
        }
 
        @Test
@@ -64,6 +64,7 @@ public class SshDaemonTest extends SshUnitTest {
 
                // set clone restriction
                RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
+               assertNotNull("Could not get repository modle for ticgit.git", model);
                model.accessRestriction = AccessRestrictionType.CLONE;
                model.authorizationControl = AuthorizationControl.NAMED;
                repositories().updateRepositoryModel(model.name, model, false);
index 27b4ec73b645637831c0bd68a2617919d25442f9..dd354d85afe08c19339e9989b80a00749a7c184d 100644 (file)
@@ -24,11 +24,13 @@ import java.net.SocketAddress;
 import java.security.KeyPair;
 import java.security.KeyPairGenerator;
 import java.security.PublicKey;
+import java.util.EnumSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.sshd.client.ServerKeyVerifier;
 import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.channel.ClientChannel;
+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.util.SecurityUtils;
 import org.junit.After;
@@ -112,9 +114,11 @@ public abstract class SshUnitTest extends GitblitUnitTest {
 
        protected String testSshCommand(String cmd, String stdin) throws IOException, InterruptedException {
                SshClient client = getClient();
-               ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).await().getSession();
+               ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).verify().getSession();
                session.addPublicKeyIdentity(rwKeyPair);
-               assertTrue(session.auth().await().isSuccess());
+               AuthFuture authFuture = session.auth();
+               assertTrue(authFuture.await());
+               assertTrue(authFuture.isSuccess());
 
                ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, cmd);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -131,7 +135,7 @@ public abstract class SshUnitTest extends GitblitUnitTest {
                channel.setErr(err);
                channel.open();
 
-               channel.waitFor(ClientChannel.CLOSED, 0);
+               channel.waitFor(EnumSet.of(ClientChannel.ClientChannelEvent.CLOSED), 0);
 
                String result = out.toString().trim();
                channel.close(false);