David Ostrovsky
2014-03-13 9ba6bc127276f4b092849336f793aac2135f7887
Bump SSHD version to 0.10.1

Change-Id: Ic7e204fb7ee2eb172f4c8424fc3d4b7e6c631ddd
1 files added
7 files modified
113 ■■■■ changed files
.classpath 4 ●●●● patch | view | raw | blame | history
build.moxie 4 ●●● patch | view | raw | blame | history
gitblit.iml 12 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/transport/ssh/DisabledFilesystemFactory.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/transport/ssh/GitblitServerSession.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java 15 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/transport/ssh/SshDaemon.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/gitblit/transport/ssh/SshSessionFactory.java 35 ●●●●● patch | view | raw | blame | history
.classpath
@@ -52,8 +52,8 @@
    <classpathentry kind="lib" path="ext/bcprov-jdk15on-1.49.jar" sourcepath="ext/src/bcprov-jdk15on-1.49.jar" />
    <classpathentry kind="lib" path="ext/bcmail-jdk15on-1.49.jar" sourcepath="ext/src/bcmail-jdk15on-1.49.jar" />
    <classpathentry kind="lib" path="ext/bcpkix-jdk15on-1.49.jar" sourcepath="ext/src/bcpkix-jdk15on-1.49.jar" />
    <classpathentry kind="lib" path="ext/sshd-core-0.6.0.jar" sourcepath="ext/src/sshd-core-0.6.0.jar" />
    <classpathentry kind="lib" path="ext/mina-core-2.0.2.jar" sourcepath="ext/src/mina-core-2.0.2.jar" />
    <classpathentry kind="lib" path="ext/sshd-core-0.10.1.jar" sourcepath="ext/src/sshd-core-0.10.1.jar" />
    <classpathentry kind="lib" path="ext/mina-core-2.0.7.jar" sourcepath="ext/src/mina-core-2.0.7.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-1.7.2.jar" sourcepath="ext/src/gson-1.7.2.jar" />
build.moxie
@@ -109,7 +109,8 @@
  bouncycastle.version : 1.49
  selenium.version : 2.28.0
  wikitext.version : 1.4
  sshd.version: 0.6.0
  sshd.version: 0.10.1
  mina.version: 2.0.7
  }
# Dependencies
@@ -157,6 +158,7 @@
- compile 'org.bouncycastle:bcmail-jdk15on:${bouncycastle.version}' :war :authority
- compile 'org.bouncycastle:bcpkix-jdk15on:${bouncycastle.version}' :war :authority
- compile 'org.apache.sshd:sshd-core:${sshd.version}' :war !org.easymock
- compile 'org.apache.mina:mina-core:${mina.version}' :war !org.easymock
- compile 'rome:rome:0.9' :war :manager :api
- compile 'com.google.code.gson:gson:1.7.2' :war :fedclient :manager :api
- compile 'org.codehaus.groovy:groovy-all:${groovy.version}' :war
gitblit.iml
@@ -529,24 +529,24 @@
      </library>
    </orderEntry>
    <orderEntry type="module-library">
      <library name="sshd-core-0.6.0.jar">
      <library name="sshd-core-0.10.1.jar">
        <CLASSES>
          <root url="jar://$MODULE_DIR$/ext/sshd-core-0.6.0.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/sshd-core-0.10.1.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://$MODULE_DIR$/ext/src/sshd-core-0.6.0.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/src/sshd-core-0.10.1.jar!/" />
        </SOURCES>
      </library>
    </orderEntry>
    <orderEntry type="module-library">
      <library name="mina-core-2.0.2.jar">
      <library name="mina-core-2.0.7.jar">
        <CLASSES>
          <root url="jar://$MODULE_DIR$/ext/mina-core-2.0.2.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/mina-core-2.0.7.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://$MODULE_DIR$/ext/src/mina-core-2.0.2.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/src/mina-core-2.0.7.jar!/" />
        </SOURCES>
      </library>
    </orderEntry>
src/main/java/com/gitblit/transport/ssh/DisabledFilesystemFactory.java
@@ -3,9 +3,9 @@
import java.io.IOException;
import org.apache.sshd.common.Session;
import org.apache.sshd.server.FileSystemFactory;
import org.apache.sshd.server.FileSystemView;
import org.apache.sshd.server.SshFile;
import org.apache.sshd.common.file.FileSystemFactory;
import org.apache.sshd.common.file.FileSystemView;
import org.apache.sshd.common.file.SshFile;
public class DisabledFilesystemFactory implements FileSystemFactory {
src/main/java/com/gitblit/transport/ssh/GitblitServerSession.java
New file
@@ -0,0 +1,35 @@
/*
 * Copyright 2014 gitblit.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitblit.transport.ssh;
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.server.ServerFactoryManager;
import org.apache.sshd.server.session.ServerSession;
// Expose addition of close session listeners
class GitblitServerSession extends ServerSession {
    GitblitServerSession(ServerFactoryManager server, IoSession ioSession)
            throws Exception {
        super(server, ioSession);
    }
    void addCloseSessionListener(SshFutureListener<CloseFuture> l) {
        closeFuture.addListener(l);
    }
}
src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java
@@ -1,28 +1,27 @@
package com.gitblit.transport.ssh;
import java.net.InetSocketAddress;
import org.apache.sshd.server.ForwardingFilter;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.common.ForwardingFilter;
import org.apache.sshd.common.Session;
import org.apache.sshd.common.SshdSocketAddress;
public class NonForwardingFilter implements ForwardingFilter {
    @Override
    public boolean canForwardAgent(ServerSession session) {
    public boolean canConnect(SshdSocketAddress address, Session session) {
        return false;
    }
    @Override
    public boolean canForwardX11(ServerSession session) {
    public boolean canForwardAgent(Session session) {
        return false;
    }
    @Override
    public boolean canConnect(InetSocketAddress address, ServerSession session) {
    public boolean canForwardX11(Session session) {
        return false;
    }
    @Override
    public boolean canListen(InetSocketAddress address, ServerSession session) {
    public boolean canListen(SshdSocketAddress address, Session session) {
        return false;
    }
}
src/main/java/com/gitblit/transport/ssh/SshDaemon.java
@@ -107,7 +107,7 @@
        sshd.setPasswordAuthenticator(new SshPasswordAuthenticator(gitblit));
        sshd.setSessionFactory(new SshSessionFactory(idGenerator));
        sshd.setFileSystemFactory(new DisabledFilesystemFactory());
        sshd.setForwardingFilter(new NonForwardingFilter());
        sshd.setTcpipForwardingFilter(new NonForwardingFilter());
        DispatchCommand gitblitCmd = new DispatchCommand();
        gitblitCmd.registerCommand(CreateRepository.class);
src/main/java/com/gitblit/transport/ssh/SshSessionFactory.java
@@ -17,11 +17,12 @@
import java.net.SocketAddress;
import org.apache.mina.core.future.IoFuture;
import org.apache.mina.core.future.IoFutureListener;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.transport.socket.SocketSessionConfig;
import org.apache.sshd.server.session.ServerSession;
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.session.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,25 +46,37 @@
    }
    @Override
    protected ServerSession createSession(final IoSession io) throws Exception {
    protected AbstractSession createSession(final IoSession io)
            throws Exception {
        log.info("connection accepted on " + io);
        if (io.getConfig() instanceof SocketSessionConfig) {
            final SocketSessionConfig c = (SocketSessionConfig) io.getConfig();
            c.setKeepAlive(true);
        if (io instanceof MinaSession) {
            if (((MinaSession) io).getSession().getConfig() instanceof SocketSessionConfig) {
                ((SocketSessionConfig) ((MinaSession) io).getSession()
                        .getConfig()).setKeepAlive(true);
            }
        }
        final ServerSession s = (ServerSession) super.createSession(io);
        final GitblitServerSession s = (GitblitServerSession) super
                .createSession(io);
        SocketAddress peer = io.getRemoteAddress();
        SshSession session = new SshSession(idGenerator.next(), peer);
        s.setAttribute(SshSession.KEY, session);
        io.getCloseFuture().addListener(new IoFutureListener<IoFuture>() {
        // TODO(davido): Log a session close without authentication as a
        // failure.
        s.addCloseSessionListener(new SshFutureListener<CloseFuture>() {
            @Override
            public void operationComplete(IoFuture future) {
            public void operationComplete(CloseFuture future) {
                log.info("connection closed on " + io);
            }
        });
        return s;
    }
    @Override
    protected AbstractSession doCreateSession(IoSession ioSession)
            throws Exception {
        return new GitblitServerSession(server, ioSession);
    }
}