8000 Update dependencies MINA to 2.0.21 and SSHD to 1.2.0 by flaix · Pull Request #1322 · gitblit-org/gitblit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update dependencies MINA to 2.0.21 and SSHD to 1.2.0 #1322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<classpathentry kind="lib" path="ext/guice-servlet-4.0-gb2.jar" sourcepath="ext/src/guice-servlet-4.0-gb2.jar" />
<classpathentry kind="lib" path="ext/annotations-12.0.jar" sourcepath="ext/src/annotations-12.0.jar" />
<classpathentry kind="lib" path="ext/log4j-1.2.17.jar" sourcepath="ext/src/log4j-1.2.17.jar" />
<classpathentry kind="lib" path="ext/slf4j-api-1.7.12.jar" sourcepath="ext/src/slf4j-api-1.7.12.jar" />
<classpathentry kind="lib" path="ext/slf4j-log4j12-1.7.12.jar" sourcepath="ext/src/slf4j-log4j12-1.7.12.jar" />
<classpathentry kind="lib" path="ext/slf4j-api-1.7.29.jar" sourcepath="ext/src/slf4j-api-1.7.29.jar" />
<classpathentry kind="lib" path="ext/slf4j-log4j12-1.7.29.jar" sourcepath="ext/src/slf4j-log4j12-1.7.29.jar" />
<classpathentry kind="lib" path="ext/javax.mail-1.5.1.jar" sourcepath="ext/src/javax.mail-1.5.1.jar" />
<classpathentry kind="lib" path="ext/javax.servlet-api-3.1.0.jar" sourcepath="ext/src/javax.servlet-api-3.1.0.jar" />
<classpathentry kind="lib" path="ext/jetty-all-9.2.13.v20150730.jar" sourcepath="ext/src/jetty-all-9.2.13.v20150730.jar" />
Expand Down Expand Up @@ -54,8 +54,8 @@
<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/mina-core-2.0.9.jar" sourcepath="ext/src/mina-core-2.0.9.jar" />
<classpathentry kind="lib" path="ext/sshd-core-1.2.0.jar" sourcepath="ext/src/sshd-core-1.2.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" />
<classpathentry kind="lib" path="ext/gson-2.3.1.jar" sourcepath="ext/src/gson-2.3.1.jar" />
Expand Down
6 changes: 3 additions & 3 deletions build.moxie
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ repositories: central, eclipse-snapshots, eclipse, gitblit
# Convenience properties for dependencies
properties: {
jetty.version : 9.2.13.v20150730
slf4j.version : 1.7.12
slf4j.version : 1.7.29
wicket.version : 1.4.22
lucene.version : 5.5.2
jgit.version : 4.1.1.201511131810-r
groovy.version : 2.4.4
bouncycastle.version : 1.57
selenium.version : 2.28.0
wikitext.version : 1.4
sshd.version: 1.0.0
mina.version: 2.0.9
sshd.version: 1.2.0
mina.version: 2.0.21
guice.version : 4.0
# Gitblit maintains a fork of guice-servlet
guice-servlet.version : 4.0-gb2
Expand Down
24 changes: 12 additions & 12 deletions gitblit.iml
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,24 @@
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="slf4j-api-1.7.12.jar">
<library name="slf4j-api-1.7.29.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/ext/slf4j-api-1.7.12.jar!/" />
<root url="jar://$MODULE_DIR$/ext/slf4j-api-1.7.29.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/ext/src/slf4j-api-1.7.12.jar!/" />
<root url="jar://$MODULE_DIR$/ext/src/slf4j-api-1.7.29.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="slf4j-log4j12-1.7.12.jar">
<library name="slf4j-log4j12-1.7.29.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/ext/slf4j-log4j12-1.7.12.jar!/" />
<root url="jar://$MODULE_DIR$/ext/slf4j-log4j12-1.7.29.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/ext/src/slf4j-log4j12-1.7.12.jar!/" />
<root url="jar://$MODULE_DIR$/ext/src/slf4j-log4j12-1.7.29.jar!/" />
</SOURCES>
</library>
</orderEntry>
Expand Down Expand Up @@ -541,24 +541,24 @@
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="sshd-core-1.0.0.jar">
<library name="sshd-core-1.2.0.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/ext/sshd-core-1.0.0.jar!/" />
<root url="jar://$MODULE_DIR$/ext/sshd-core-1.2.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.2.0.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mina-core-2.0.9.jar">
<library name="mina-core-2.0.21.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/ext/mina-core-2.0.9.jar!/" />
<root url="jar://$MODULE_DIR$/ext/mina-core-2.0.21.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/ext/src/mina-core-2.0.9.jar!/" />
<root url="jar://$MODULE_DIR$/ext/src/mina-core-2.0.21.jar!/" />
</SOURCES>
</library>
</orderEntry>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gitblit/transport/ssh/LdapKeyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
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;
Expand Down Expand Up @@ -212,7 +212,7 @@ protected List<SshKey> getKeysImpl(String username) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gitblit/transport/ssh/SshDaemon.java
Original file line number Diff line number Diff line change
2E18 Expand Up @@ -31,7 +31,7 @@
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;
Expand Down Expand Up @@ -158,7 +158,7 @@ public SshDaemon(IGitblit gitblit, WorkQueue workQueue) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.net.SocketAddress;

import org.apache.sshd.common.session.Session.AttributeKey;
import org.apache.sshd.common.AttributeStore.AttributeKey;

import com.gitblit.models.UserModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
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;
Expand All @@ -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) {
Expand All @@ -66,7 +68,7 @@ public void operationComplete(CloseFuture future) {
}

@Override
protected AbstractSession doCreateSession(IoSession ioSession) throws Exception {
protected ServerSessionImpl doCreateSession(IoSession ioSession) throws Exception {
return new SshServerSession(getServer(), ioSession);
}
}
5 changes: 3 additions & 2 deletions src/test/java/com/gitblit/tests/SshDaemonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -64,6 +64,7 @@ public void testCloneCommand() throws Exception {

// 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);
Expand Down
26 changes: 22 additions & 4 deletions src/test/java/com/gitblit/tests/SshUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@
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;
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.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;
Expand Down Expand Up @@ -96,6 +102,16 @@ public void tearDown() {

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) {
Expand All @@ -112,9 +128,11 @@ protected String testSshCommand(String cmd) throws IOException, InterruptedExcep

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();
Expand All @@ -131,7 +149,7 @@ protected String testSshCommand(String cmd, String stdin) throws IOException, In
channel.setErr(err);
channel.open();

channel.waitFor(ClientChannel.CLOSED, 0);
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0);

String result = out.toString().trim();
channel.close(false);
Expand Down
0