Skip to content

Commit abb041d

Browse files
committed
Update SSHD dependency to version 1.1.0.
1 parent c0e836d commit abb041d

File tree

8 files changed

+25
-18
lines changed

8 files changed

+25
-18
lines changed

.classpath

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<classpathentry kind="lib" path="ext/bcprov-jdk15on-1.57.jar" sourcepath="ext/src/bcprov-jdk15on-1.57.jar" />
5555
<classpathentry kind="lib" path="ext/bcmail-jdk15on-1.57.jar" sourcepath="ext/src/bcmail-jdk15on-1.57.jar" />
5656
<classpathentry kind="lib" path="ext/bcpkix-jdk15on-1.57.jar" sourcepath="ext/src/bcpkix-jdk15on-1.57.jar" />
57-
<classpathentry kind="lib" path="ext/sshd-core-1.0.0.jar" sourcepath="ext/src/sshd-core-1.0.0.jar" />
57+
<classpathentry kind="lib" path="ext/sshd-core-1.1.0.jar" sourcepath="ext/src/sshd-core-1.1.0.jar" />
5858
<classpathentry kind="lib" path="ext/mina-core-2.0.21.jar" sourcepath="ext/src/mina-core-2.0.21.jar" />
5959
<classpathentry kind="lib" path="ext/rome-0.9.jar" sourcepath="ext/src/rome-0.9.jar" />
6060
<classpathentry kind="lib" path="ext/jdom-1.0.jar" sourcepath="ext/src/jdom-1.0.jar" />

build.moxie

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ properties: {
112112
bouncycastle.version : 1.57
113113
selenium.version : 2.28.0
114114
wikitext.version : 1.4
115-
sshd.version: 1.0.0
115+
sshd.version: 1.1.0
116116
mina.version: 2.0.21
117117
guice.version : 4.0
118118
# Gitblit maintains a fork of guice-servlet

gitblit.iml

+3-3
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,13 @@
541541
</library>
542542
</orderEntry>
543543
<orderEntry type="module-library">
544-
<library name="sshd-core-1.0.0.jar">
544+
<library name="sshd-core-1.1.0.jar">
545545
<CLASSES>
546-
<root url="jar://$MODULE_DIR$/ext/sshd-core-1.0.0.jar!/" />
546+
<root url="jar://$MODULE_DIR$/ext/sshd-core-1.1.0.jar!/" />
547547
</CLASSES>
548548
<JAVADOC />
549549
<SOURCES>
550-
<root url="jar://$MODULE_DIR$/ext/src/sshd-core-1.0.0.jar!/" />
550+
<root url="jar://$MODULE_DIR$/ext/src/sshd-core-1.1.0.jar!/" />
551551
</SOURCES>
552552
</library>
553553
</orderEntry>

src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected List<SshKey> getKeysImpl(String username) {
212212
List<SshKey> keyList = new ArrayList<>(authorizedKeys.size());
213213
for (GbAuthorizedKeyEntry keyEntry : authorizedKeys) {
214214
try {
215-
SshKey key = new SshKey(keyEntry.resolvePublicKey());
215+
SshKey key = new SshKey(keyEntry.resolvePublicKey(null));
216216
key.setComment(keyEntry.getComment());
217217
setKeyPermissions(key, keyEntry);
218218
keyList.add(key);

src/main/java/com/gitblit/transport/ssh/SshDaemon.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
3232
import org.apache.sshd.common.util.SecurityUtils;
3333
import org.apache.sshd.server.SshServer;
34-
import org.apache.sshd.server.auth.CachingPublicKeyAuthenticator;
34+
import org.apache.sshd.server.auth.pubkey.CachingPublicKeyAuthenticator;
3535
import org.bouncycastle.openssl.PEMWriter;
3636
import org.eclipse.jgit.internal.JGitText;
3737
import org.slf4j.Logger;
@@ -158,7 +158,7 @@ public SshDaemon(IGitblit gitblit, WorkQueue workQueue) {
158158
log.info("SSH: adding GSSAPI authentication method.");
159159
}
160160

161-
sshd.setSessionFactory(new SshServerSessionFactory());
161+
sshd.setSessionFactory(new SshServerSessionFactory(sshd));
162162
sshd.setFileSystemFactory(new DisabledFilesystemFactory());
163163
sshd.setTcpipForwardingFilter(new NonForwardingFilter());
164164
sshd.setCommandFactory(new SshCommandFactory(gitblit, workQueue));

src/main/java/com/gitblit/transport/ssh/SshServerSessionFactory.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import org.apache.sshd.common.future.SshFutureListener;
2323
import org.apache.sshd.common.io.IoSession;
2424
import org.apache.sshd.common.io.mina.MinaSession;
25-
import org.apache.sshd.common.session.AbstractSession;
25+
import org.apache.sshd.server.ServerFactoryManager;
26+
import org.apache.sshd.server.session.ServerSessionImpl;
2627
import org.apache.sshd.server.session.SessionFactory;
2728
import org.slf4j.Logger;
2829
import org.slf4j.LoggerFactory;
@@ -36,11 +37,12 @@ public class SshServerSessionFactory extends SessionFactory {
3637

3738
private final Logger log = LoggerFactory.getLogger(getClass());
3839

39-
public SshServerSessionFactory() {
40+
public SshServerSessionFactory(ServerFactoryManager server) {
41+
super(server);
4042
}
4143

4244
@Override
43-
protected AbstractSession createSession(final IoSession io) throws Exception {
45+
protected ServerSessionImpl createSession(final IoSession io) throws Exception {
4446
log.info("creating ssh session from {}", io.getRemoteAddress());
4547

4648
if (io instanceof MinaSession) {
@@ -66,7 +68,7 @@ public void operationComplete(CloseFuture future) {
6668
}
6769

6870
@Override
69-
protected AbstractSession doCreateSession(IoSession ioSession) throws Exception {
71+
protected ServerSessionImpl doCreateSession(IoSession ioSession) throws Exception {
7072
return new SshServerSession(getServer(), ioSession);
7173
}
7274
}

src/test/java/com/gitblit/tests/SshDaemonTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public class SshDaemonTest extends SshUnitTest {
4444
@Test
4545
public void testPublicKeyAuthentication() throws Exception {
4646
SshClient client = getClient();
47-
ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).await().getSession();
47+
ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).verify().getSession();
4848
session.addPublicKeyIdentity(rwKeyPair);
49-
assertTrue(session.auth().await().isSuccess());
49+
assertTrue(session.auth().await());
5050
}
5151

5252
@Test
@@ -64,6 +64,7 @@ public void testCloneCommand() throws Exception {
6464

6565
// set clone restriction
6666
RepositoryModel model = repositories().getRepositoryModel("ticgit.git");
67+
assertNotNull("Could not get repository modle for ticgit.git", model);
6768
model.accessRestriction = AccessRestrictionType.CLONE;
6869
model.authorizationControl = AuthorizationControl.NAMED;
6970
repositories().updateRepositoryModel(model.name, model, false);

src/test/java/com/gitblit/tests/SshUnitTest.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
import java.security.KeyPair;
2525
import java.security.KeyPairGenerator;
2626
import java.security.PublicKey;
27+
import java.util.EnumSet;
2728
import java.util.concurrent.atomic.AtomicBoolean;
2829

29-
import org.apache.sshd.client.ServerKeyVerifier;
3030
import org.apache.sshd.client.SshClient;
3131
import org.apache.sshd.client.channel.ClientChannel;
32+
import org.apache.sshd.client.future.AuthFuture;
33+
import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
3234
import org.apache.sshd.client.session.ClientSession;
3335
import org.apache.sshd.common.util.SecurityUtils;
3436
import org.junit.After;
@@ -112,9 +114,11 @@ protected String testSshCommand(String cmd) throws IOException, InterruptedExcep
112114

113115
protected String testSshCommand(String cmd, String stdin) throws IOException, InterruptedException {
114116
SshClient client = getClient();
115-
ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).await().getSession();
117+
ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).verify().getSession();
116118
session.addPublicKeyIdentity(rwKeyPair);
117-
assertTrue(session.auth().await().isSuccess());
119+
AuthFuture authFuture = session.auth();
120+
assertTrue(authFuture.await());
121+
assertTrue(authFuture.isSuccess());
118122

119123
ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, cmd);
120124
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -131,7 +135,7 @@ protected String testSshCommand(String cmd, String stdin) throws IOException, In
131135
channel.setErr(err);
132136
channel.open();
133137

134-
channel.waitFor(ClientChannel.CLOSED, 0);
138+
channel.waitFor(EnumSet.of(ClientChannel.ClientChannelEvent.CLOSED), 0);
135139

136140
String result = out.toString().trim();
137141
channel.close(false);

0 commit comments

Comments
 (0)