mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgoldst...@apache.org
Subject [1/2] mina-sshd git commit: [SSHD-658] The server should support by default all compressions
Date Fri, 26 Feb 2016 15:00:41 GMT
Repository: mina-sshd
Updated Branches:
  refs/heads/master acb8e6f31 -> ce0582baa


[SSHD-658] The server should support by default all compressions


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/75d1bd64
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/75d1bd64
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/75d1bd64

Branch: refs/heads/master
Commit: 75d1bd6481485f3b545840c829d26b9e791d7cd1
Parents: acb8e6f
Author: Lyor Goldstein <lyor.goldstein@gmail.com>
Authored: Fri Feb 26 17:00:36 2016 +0200
Committer: Lyor Goldstein <lyor.goldstein@gmail.com>
Committed: Fri Feb 26 17:00:36 2016 +0200

----------------------------------------------------------------------
 .../org/apache/sshd/client/ClientBuilder.java   | 10 ++++++
 .../org/apache/sshd/common/BaseBuilder.java     | 10 ------
 .../org/apache/sshd/server/ServerBuilder.java   |  9 +++++
 .../java/org/apache/sshd/server/SshServer.java  |  7 ----
 .../common/compression/CompressionTest.java     | 37 ++++++++++++++++++++
 5 files changed, 56 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/75d1bd64/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java b/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
index 0129361..933ff42 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
@@ -35,6 +35,8 @@ import org.apache.sshd.common.BaseBuilder;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.compression.BuiltinCompressions;
+import org.apache.sshd.common.compression.CompressionFactory;
 import org.apache.sshd.common.config.keys.FilePasswordProvider;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KeyExchange;
@@ -60,6 +62,10 @@ public class ClientBuilder extends BaseBuilder<SshClient, ClientBuilder>
{
             }
         };
 
+    // Compression is not enabled by default for the client
+    public static final List<CompressionFactory> DEFAULT_COMPRESSION_FACTORIES =
+            Collections.unmodifiableList(Arrays.<CompressionFactory>asList(BuiltinCompressions.none));
+
     public static final List<NamedFactory<Channel>> DEFAULT_CHANNEL_FACTORIES
=
             Collections.unmodifiableList(Arrays.<NamedFactory<Channel>>asList(ForwardedTcpipFactory.INSTANCE));
     public static final List<RequestHandler<ConnectionService>> DEFAULT_GLOBAL_REQUEST_HANDLERS
=
@@ -104,6 +110,10 @@ public class ClientBuilder extends BaseBuilder<SshClient, ClientBuilder>
{
     protected ClientBuilder fillWithDefaultValues() {
         super.fillWithDefaultValues();
 
+        if (compressionFactories == null) {
+            compressionFactories = NamedFactory.Utils.setUpBuiltinFactories(false, DEFAULT_COMPRESSION_FACTORIES);
+        }
+
         if (keyExchangeFactories == null) {
             keyExchangeFactories = setUpDefaultKeyExchanges(false);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/75d1bd64/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
index 1c1703c..2f2ebd0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
@@ -27,7 +27,6 @@ import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.cipher.BuiltinCiphers;
 import org.apache.sshd.common.cipher.Cipher;
-import org.apache.sshd.common.compression.BuiltinCompressions;
 import org.apache.sshd.common.compression.Compression;
 import org.apache.sshd.common.file.FileSystemFactory;
 import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory;
@@ -56,11 +55,6 @@ import org.apache.sshd.server.forward.RejectAllForwardingFilter;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder<T,
S>> implements ObjectBuilder<T> {
-
-    // Compression is not enabled by default
-    public static final List<NamedFactory<Compression>> DEFAULT_COMPRESSION_FACTORIES
=
-            Collections.unmodifiableList(Arrays.<NamedFactory<Compression>>asList(BuiltinCompressions.none));
-
     public static final FileSystemFactory DEFAULT_FILE_SYSTEM_FACTORY = NativeFileSystemFactory.INSTANCE;
 
     public static final ForwardingFilter DEFAULT_FORWARDING_FILTER = RejectAllForwardingFilter.INSTANCE;
@@ -164,10 +158,6 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends
BaseBuilder
             cipherFactories = setUpDefaultCiphers(false);
         }
 
-        if (compressionFactories == null) {
-            compressionFactories = DEFAULT_COMPRESSION_FACTORIES;
-        }
-
         if (macFactories == null) {
             macFactories = setUpDefaultMacs(false);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/75d1bd64/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
index d65716e..08b3f2e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
@@ -27,6 +27,8 @@ import org.apache.sshd.common.BaseBuilder;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.compression.BuiltinCompressions;
+import org.apache.sshd.common.compression.CompressionFactory;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KeyExchange;
 import org.apache.sshd.common.session.ConnectionService;
@@ -81,6 +83,9 @@ public class ServerBuilder extends BaseBuilder<SshServer, ServerBuilder>
{
 
     public static final PublickeyAuthenticator DEFAULT_PUBLIC_KEY_AUTHENTICATOR = DefaultAuthorizedKeysAuthenticator.INSTANCE;
     public static final KeyboardInteractiveAuthenticator DEFAULT_INTERACTIVE_AUTHENTICATOR
= DefaultKeyboardInteractiveAuthenticator.INSTANCE;
+    public static final List<CompressionFactory> DEFAULT_COMPRESSION_FACTORIES =
+            Collections.unmodifiableList(Arrays.<CompressionFactory>asList(
+                    BuiltinCompressions.none, BuiltinCompressions.zlib, BuiltinCompressions.delayedZlib));
 
     protected PublickeyAuthenticator pubkeyAuthenticator;
     protected KeyboardInteractiveAuthenticator interactiveAuthenticator;
@@ -103,6 +108,10 @@ public class ServerBuilder extends BaseBuilder<SshServer, ServerBuilder>
{
     protected ServerBuilder fillWithDefaultValues() {
         super.fillWithDefaultValues();
 
+        if (compressionFactories == null) {
+            compressionFactories = NamedFactory.Utils.setUpBuiltinFactories(false, DEFAULT_COMPRESSION_FACTORIES);
+        }
+
         if (keyExchangeFactories == null) {
             keyExchangeFactories = setUpDefaultKeyExchanges(false);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/75d1bd64/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index 1f2ea0d..8ad4f68 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -40,8 +40,6 @@ import org.apache.sshd.common.Factory;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.PropertyResolverUtils;
 import org.apache.sshd.common.ServiceFactory;
-import org.apache.sshd.common.compression.BuiltinCompressions;
-import org.apache.sshd.common.compression.Compression;
 import org.apache.sshd.common.helpers.AbstractFactoryManager;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoServiceFactory;
@@ -483,11 +481,6 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa
         System.err.println("Starting SSHD on port " + port);
 
         SshServer sshd = SshServer.setUpDefaultServer();
-        // setup our server with all possible compressions
-        sshd.setCompressionFactories(
-                Arrays.<NamedFactory<Compression>>asList(
-                        BuiltinCompressions.none, BuiltinCompressions.zlib, BuiltinCompressions.delayedZlib));
-
         Map<String, Object> props = sshd.getProperties();
         PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.WELCOME_BANNER, "Welcome
to SSHD\n");
         props.putAll(options);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/75d1bd64/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
index 0d7a655..2319c31 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
@@ -22,12 +22,18 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
 import java.util.List;
 
 import com.jcraft.jsch.JSch;
 
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.kex.KexProposalOption;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionListener;
 import org.apache.sshd.server.SshServer;
 import org.apache.sshd.util.test.BaseTestSupport;
 import org.apache.sshd.util.test.JSchLogger;
@@ -51,6 +57,9 @@ import org.junit.runners.Parameterized.Parameters;
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 @RunWith(Parameterized.class)   // see https://github.com/junit-team/junit/wiki/Parameterized-tests
 public class CompressionTest extends BaseTestSupport {
+    private static final Collection<KexProposalOption> COMPRESSION_OPTIONS =
+            Collections.unmodifiableSet(EnumSet.of(KexProposalOption.C2SCOMP, KexProposalOption.S2CCOMP));
+
     private final CompressionFactory factory;
     private SshServer sshd;
 
@@ -72,6 +81,34 @@ public class CompressionTest extends BaseTestSupport {
     public void setUp() throws Exception {
         sshd = setupTestServer();
         sshd.setCompressionFactories(Arrays.<NamedFactory<org.apache.sshd.common.compression.Compression>>asList(factory));
+        sshd.addSessionListener(new SessionListener() {
+            @Override
+            public void sessionException(Session session, Throwable t) {
+                // ignored
+            }
+
+            @Override
+            @SuppressWarnings("synthetic-access")
+            public void sessionEvent(Session session, Event event) {
+                if (Event.KeyEstablished.equals(event)) {
+                    String expected = factory.getName();
+                    for (KexProposalOption option : COMPRESSION_OPTIONS) {
+                        String actual = session.getNegotiatedKexParameter(KexProposalOption.C2SCOMP);
+                        assertEquals("Mismatched value for " + option, expected, actual);
+                    }
+                }
+            }
+
+            @Override
+            public void sessionCreated(Session session) {
+                // ignored
+            }
+
+            @Override
+            public void sessionClosed(Session session) {
+                // ignored
+            }
+        });
         sshd.start();
 
         String name = factory.getName();


Mime
View raw message