You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/06/30 12:26:44 UTC

[1/2] mina-sshd git commit: [SSHD-509] Use targeted derived NamedFactory(ies) for the various generic parameters

Repository: mina-sshd
Updated Branches:
  refs/heads/master e06cfdcb1 -> 84d41b582


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
index 1c468b3..48b8c97 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
@@ -29,7 +29,6 @@ import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.apache.sshd.server.PublickeyAuthenticator;
 import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
 
 /**
  * TODO Add javadoc
@@ -38,7 +37,7 @@ import org.apache.sshd.server.UserAuth;
  */
 public class UserAuthPublicKey extends AbstractUserAuth {
 
-    public static class UserAuthPublicKeyFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthPublicKeyFactory implements UserAuthFactory {
         public static final String NAME = "publickey";
 
         public static final UserAuthPublicKeyFactory INSTANCE = new UserAuthPublicKeyFactory();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
index 7ed9ec8..d5786c2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sshd.server.auth.gss;
 
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.util.GenericUtils;
@@ -26,8 +25,9 @@ import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
 import org.apache.sshd.server.auth.AbstractUserAuth;
+import org.apache.sshd.server.auth.UserAuth;
+import org.apache.sshd.server.auth.UserAuthFactory;
 import org.apache.sshd.server.session.ServerSession;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
@@ -107,10 +107,10 @@ public class UserAuthGSS extends AbstractUserAuth {
         else
         {
             byte msg = buffer.getByte();
-            if (!(msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE ||
-                    msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC && context.isEstablished())) {
+            if (!((msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE)
+               || (msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC) && context.isEstablished())) {
                 throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
-                        "Packet not supported by user authentication method");
+                        "Packet not supported by user authentication method: " + msg);
             }
 
             log.debug("In krb5.next: msg = " + msg);
@@ -236,7 +236,7 @@ public class UserAuthGSS extends AbstractUserAuth {
     /**
      * Factory class.
      */
-    public static class UserAuthGSSFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthGSSFactory implements UserAuthFactory {
         public static final UserAuthGSSFactory INSTANCE = new UserAuthGSSFactory();
         
         public UserAuthGSSFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index d68be79..e106c84 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -41,9 +41,10 @@ import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.ChannelAsyncOutputStream;
+import org.apache.sshd.common.channel.ChannelFactory;
 import org.apache.sshd.common.channel.ChannelOutputStream;
+import org.apache.sshd.common.channel.ChannelRequestHandler;
 import org.apache.sshd.common.channel.PtyMode;
-import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.file.FileSystemAware;
 import org.apache.sshd.common.file.FileSystemFactory;
 import org.apache.sshd.common.future.CloseFuture;
@@ -79,7 +80,7 @@ public class ChannelSession extends AbstractServerChannel {
 
     public static final long DEFAULT_COMMAND_EXIT_TIMEOUT = 5000;
 
-    public static class ChannelSessionFactory implements NamedFactory<Channel> {
+    public static class ChannelSessionFactory implements ChannelFactory {
         public static final ChannelSessionFactory   INSTANCE = new ChannelSessionFactory();
 
         public ChannelSessionFactory() {
@@ -315,6 +316,14 @@ public class ChannelSession extends AbstractServerChannel {
         throw new UnsupportedOperationException("Server channel does not support extended data");
     }
 
+    /**
+     * @param type The request type
+     * @param buffer The {@link Buffer} containing extra request-specific content
+     * @return A {@link Boolean} representing the success/failure of handling
+     * the request - {@code null} if unknown request received
+     * @throws IOException If request requires some extra response and failed
+     * to generate it
+     */
     public Boolean handleRequest(String type, Buffer buffer) throws IOException {
         if ("env".equals(type)) {
             return Boolean.valueOf(handleEnv(buffer));
@@ -332,7 +341,7 @@ public class ChannelSession extends AbstractServerChannel {
             return Boolean.valueOf(handleBreak(buffer));
         }
         if ("shell".equals(type)) {
-            if (this.type == null && handleShell(buffer)) {
+            if ((this.type == null) && handleShell(buffer)) {
                 this.type = type;
                 return Boolean.TRUE;
             } else {
@@ -340,7 +349,7 @@ public class ChannelSession extends AbstractServerChannel {
             }
         }
         if ("exec".equals(type)) {
-            if (this.type == null && handleExec(buffer)) {
+            if ((this.type == null) && handleExec(buffer)) {
                 this.type = type;
                 return Boolean.TRUE;
             } else {
@@ -348,7 +357,7 @@ public class ChannelSession extends AbstractServerChannel {
             }
         }
         if ("subsystem".equals(type)) {
-            if (this.type == null && handleSubsystem(buffer)) {
+            if ((this.type == null) && handleSubsystem(buffer)) {
                 this.type = type;
                 return Boolean.TRUE;
             } else {
@@ -369,7 +378,7 @@ public class ChannelSession extends AbstractServerChannel {
         String value = buffer.getString();
         addEnvVariable(name, value);
         if (log.isDebugEnabled()) {
-            log.debug("env for channel {}: {} = {}", new Object[] { Integer.valueOf(id), name, value });
+            log.debug("env for channel {}: {} = {}", Integer.valueOf(id), name, value);
         }
         return true;
     }
@@ -402,11 +411,12 @@ public class ChannelSession extends AbstractServerChannel {
         }
         if (log.isDebugEnabled()) {
             log.debug("pty for channel {}: term={}, size=({} - {}), pixels=({}, {}), modes=[{}]",
-                      new Object[] { Integer.valueOf(id), term, 
-                                     Integer.valueOf(tColumns), Integer.valueOf(tRows),
-                                     Integer.valueOf(tWidth), Integer.valueOf(tHeight),
-                                     ptyModes });
+                      Integer.valueOf(id), term, 
+                      Integer.valueOf(tColumns), Integer.valueOf(tRows),
+                      Integer.valueOf(tWidth), Integer.valueOf(tHeight),
+                      ptyModes);
         }
+
         addEnvVariable(Environment.ENV_TERM, term);
         addEnvVariable(Environment.ENV_COLUMNS, Integer.toString(tColumns));
         addEnvVariable(Environment.ENV_LINES, Integer.toString(tRows));
@@ -420,9 +430,9 @@ public class ChannelSession extends AbstractServerChannel {
         int tHeight = buffer.getInt();
         if (log.isDebugEnabled()) {
             log.debug("window-change for channel {}: ({} - {}), ({}, {})",
-                      new Object[] { Integer.valueOf(id),
-                                     Integer.valueOf(tColumns), Integer.valueOf(tRows),
-                                     Integer.valueOf(tWidth), Integer.valueOf(tHeight) });
+                      Integer.valueOf(id),
+                      Integer.valueOf(tColumns), Integer.valueOf(tRows),
+                      Integer.valueOf(tWidth), Integer.valueOf(tHeight));
         }
 
         final StandardEnvironment e = getEnvironment();
@@ -486,6 +496,7 @@ public class ChannelSession extends AbstractServerChannel {
         if (isClosing()) {
             return false;
         }
+
         String commandLine = buffer.getString();
         ServerFactoryManager manager = ((ServerSession) session).getFactoryManager();
         CommandFactory factory = manager.getCommandFactory();
@@ -493,15 +504,18 @@ public class ChannelSession extends AbstractServerChannel {
             log.warn("No command factory for command: {}", commandLine);
             return false;
         }
+
         if (log.isDebugEnabled()) {
             log.debug("Executing command: {}", commandLine);
         }
+
         try {
             command = factory.createCommand(commandLine);
         } catch (RuntimeException iae) {
             log.warn("Failed (" + iae.getClass().getSimpleName() + ") to create command for " + commandLine + ": " + iae.getMessage());
             return false;
         }
+
         prepareCommand();
         // Launch command
         command.start(getEnvironment());
@@ -521,6 +535,7 @@ public class ChannelSession extends AbstractServerChannel {
             log.warn("Unsupported subsystem: {}", subsystem);
             return false;
         }
+
         prepareCommand();
         // Launch command
         command.start(getEnvironment());
@@ -674,7 +689,7 @@ public class ChannelSession extends AbstractServerChannel {
         }
     }
 
-    private class ChannelSessionRequestHandler implements RequestHandler<Channel> {
+    private class ChannelSessionRequestHandler implements ChannelRequestHandler {
         public ChannelSessionRequestHandler() {
             super();
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
index ea2d2d6..20b8255 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
@@ -19,7 +19,8 @@
 package org.apache.sshd.server.channel;
 
 import org.apache.sshd.common.channel.Channel;
-import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.channel.ChannelRequestHandler;
+import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
 
@@ -27,7 +28,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  * Handles Putty specific channel requests as indicated by
  * <A HREF="http://tartarus.org/~simon/putty-snapshots/htmldoc/AppendixF.html">Appendix F: SSH-2 names specified for PuTTY</A>
  */
-public class PuttyRequestHandler extends AbstractLoggingBean implements RequestHandler<Channel> {
+public class PuttyRequestHandler extends AbstractLoggingBean implements ChannelRequestHandler {
     public static final String REQUEST_SUFFIX = "@putty.projects.tartarus.org";
 
     public PuttyRequestHandler() {
@@ -37,8 +38,7 @@ public class PuttyRequestHandler extends AbstractLoggingBean implements RequestH
     @Override
     public Result process(Channel channel, String request, boolean wantReply, Buffer buffer) throws Exception {
         // make sure proper suffix
-        if ((request == null)
-         || (request.length() <= REQUEST_SUFFIX.length())
+        if ((GenericUtils.length(request) <= REQUEST_SUFFIX.length())
          || (!request.endsWith(REQUEST_SUFFIX))) {
             return Result.Unsupported;
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 4741136..de8e36b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -27,10 +27,10 @@ import java.util.concurrent.ExecutorService;
 import org.apache.sshd.client.future.DefaultOpenFuture;
 import org.apache.sshd.client.future.OpenFuture;
 import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshdSocketAddress;
 import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
 import org.apache.sshd.common.channel.ChannelOutputStream;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.SshFutureListener;
@@ -54,7 +54,7 @@ import org.apache.sshd.server.channel.OpenChannelException;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class TcpipServerChannel extends AbstractServerChannel {
-    public abstract static class TcpipFactory implements NamedFactory<Channel>, ExecutorServiceCarrier {
+    public abstract static class TcpipFactory implements ChannelFactory, ExecutorServiceCarrier {
         private final ForwardingFilter.Type type;
 
         protected TcpipFactory(ForwardingFilter.Type type) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
index a139517..ebc6914 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
@@ -20,9 +20,9 @@ package org.apache.sshd.server.global;
 
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshdSocketAddress;
-import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.forward.TcpipForwarder;
 import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.ConnectionServiceRequestHandler;
 import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -32,8 +32,9 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class CancelTcpipForwardHandler extends AbstractLoggingBean implements RequestHandler<ConnectionService> {
+public class CancelTcpipForwardHandler extends AbstractLoggingBean implements ConnectionServiceRequestHandler {
     public static final String REQUEST = "cancel-tcpip-forward";
+    public static final CancelTcpipForwardHandler INSTANCE = new CancelTcpipForwardHandler();
 
     public CancelTcpipForwardHandler() {
         super();
@@ -58,8 +59,10 @@ public class CancelTcpipForwardHandler extends AbstractLoggingBean implements Re
                 buffer.putInt(port);
                 session.writePacket(buffer);
             }
+
             return Result.Replied;
         }
+
         return Result.Unsupported;
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java
index ebee834..7f94776 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java
@@ -18,8 +18,8 @@
  */
 package org.apache.sshd.server.global;
 
-import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.ConnectionServiceRequestHandler;
 import org.apache.sshd.common.util.buffer.Buffer;
 
 /**
@@ -27,7 +27,9 @@ import org.apache.sshd.common.util.buffer.Buffer;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class KeepAliveHandler implements RequestHandler<ConnectionService> {
+public class KeepAliveHandler implements ConnectionServiceRequestHandler {
+    public static final KeepAliveHandler INSTANCE = new KeepAliveHandler();
+
     public KeepAliveHandler() {
         super();
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/global/NoMoreSessionsHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/NoMoreSessionsHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/NoMoreSessionsHandler.java
index 33b5c62..594124c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/NoMoreSessionsHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/NoMoreSessionsHandler.java
@@ -18,8 +18,8 @@
  */
 package org.apache.sshd.server.global;
 
-import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.ConnectionServiceRequestHandler;
 import org.apache.sshd.common.util.buffer.Buffer;
 
 /**
@@ -27,7 +27,9 @@ import org.apache.sshd.common.util.buffer.Buffer;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class NoMoreSessionsHandler implements RequestHandler<ConnectionService> {
+public class NoMoreSessionsHandler implements ConnectionServiceRequestHandler {
+    public static final NoMoreSessionsHandler INSTANCE = new NoMoreSessionsHandler();
+
     public NoMoreSessionsHandler() {
         super();
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
index 6208ff2..33d64b0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
@@ -20,9 +20,9 @@ package org.apache.sshd.server.global;
 
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshdSocketAddress;
-import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.forward.TcpipForwarder;
 import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.ConnectionServiceRequestHandler;
 import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -32,8 +32,9 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class TcpipForwardHandler extends AbstractLoggingBean implements RequestHandler<ConnectionService> {
+public class TcpipForwardHandler extends AbstractLoggingBean implements ConnectionServiceRequestHandler {
     public static final String REQUEST = "tcpip-forward";
+    public static final TcpipForwardHandler INSTANCE = new TcpipForwardHandler();
 
     public TcpipForwardHandler() {
         super();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
index 3a8a194..c3800cc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
@@ -37,6 +37,7 @@ import org.apache.sshd.common.kex.DHG;
 import org.apache.sshd.common.kex.DHGroupData;
 import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
 import org.apache.sshd.common.random.Random;
 import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.signature.Signature;
@@ -61,8 +62,8 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
     protected byte expected;
     protected boolean oldRequest;
 
-    public static NamedFactory<KeyExchange> newFactory(final DHFactory factory) {
-        return new NamedFactory<KeyExchange>() {
+    public static KeyExchangeFactory newFactory(final DHFactory factory) {
+        return new KeyExchangeFactory() {
             @Override
             public KeyExchange create() {
                 return new DHGEXServer(factory);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
index b204615..75efab9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
@@ -28,6 +28,7 @@ import org.apache.sshd.common.kex.AbstractDH;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
 import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.signature.Signature;
 import org.apache.sshd.common.util.GenericUtils;
@@ -44,8 +45,8 @@ public class DHGServer extends AbstractDHServerKeyExchange {
     protected final DHFactory factory;
     protected AbstractDH dh;
 
-    public static NamedFactory<KeyExchange> newFactory(final DHFactory factory) {
-        return new NamedFactory<KeyExchange>() {
+    public static KeyExchangeFactory newFactory(final DHFactory factory) {
+        return new KeyExchangeFactory() {
             @Override
             public KeyExchange create() {
                 return new DHGServer(factory);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index 6a7a95d..521caaa 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -38,7 +38,7 @@ import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
+import org.apache.sshd.server.auth.UserAuth;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
index e02e436..dc733e8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
@@ -100,7 +100,7 @@ public class AuthenticationTest extends BaseTestSupport {
         try(SshClient client = SshClient.setUpDefaultClient()) {
             client.setServiceFactories(Arrays.asList(
                     new ClientUserAuthServiceOld.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
             ));
 
             client.start();
@@ -125,7 +125,7 @@ public class AuthenticationTest extends BaseTestSupport {
         try(SshClient client = SshClient.setUpDefaultClient()) {
             client.setServiceFactories(Arrays.asList(
                     new ClientUserAuthServiceOld.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
             ));
             client.start();
             
@@ -146,7 +146,7 @@ public class AuthenticationTest extends BaseTestSupport {
         try(SshClient client = SshClient.setUpDefaultClient()) {
             client.setServiceFactories(Arrays.asList(
                     new ClientUserAuthServiceOld.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
             ));
             client.start();
             
@@ -168,7 +168,7 @@ public class AuthenticationTest extends BaseTestSupport {
         try(SshClient client = SshClient.setUpDefaultClient()) {
             client.setServiceFactories(Arrays.asList(
                     new ClientUserAuthServiceOld.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
             ));
             client.start();
             

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
index 624be01..de1192a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.FactoryManagerUtils;
 import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
index b214aff..f3df1c3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
@@ -38,9 +38,11 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.sshd.client.auth.UserAuth;
 import org.apache.sshd.client.auth.UserAuthKeyboardInteractive;
 import org.apache.sshd.client.auth.UserAuthPassword;
 import org.apache.sshd.client.auth.UserAuthPublicKey;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.channel.ChannelExec;
 import org.apache.sshd.client.channel.ChannelShell;
 import org.apache.sshd.client.channel.ClientChannel;
@@ -799,12 +801,12 @@ public class ClientTest extends BaseTestSupport {
                                     }
                                 }
                         ));
-        sshd.setUserAuthFactories(Arrays.<NamedFactory<org.apache.sshd.server.UserAuth>>asList(
+        sshd.setUserAuthFactories(Arrays.<NamedFactory<org.apache.sshd.server.auth.UserAuth>>asList(
                 new org.apache.sshd.server.auth.UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory() {
                     private int xformerIndex;
 
                     @Override
-                    public org.apache.sshd.server.UserAuth create() {
+                    public org.apache.sshd.server.auth.UserAuth create() {
                         return new org.apache.sshd.server.auth.UserAuthKeyboardInteractive() {
     
                             @SuppressWarnings("synthetic-access")

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/client/session/ClientSessionImplTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/session/ClientSessionImplTest.java b/sshd-core/src/test/java/org/apache/sshd/client/session/ClientSessionImplTest.java
index e4783f1..8199921 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/session/ClientSessionImplTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/session/ClientSessionImplTest.java
@@ -59,8 +59,8 @@ public class ClientSessionImplTest extends BaseTestSupport {
         Mockito.when(client.getRandomFactory()).thenReturn(randomFactory);
         
         List<ServiceFactory> serviceFactories = Arrays.asList(
-                    new ClientUserAuthService.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientUserAuthService.ClientUserAuthServiceFactory.INSTANCE,
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
                 );
         Mockito.when(client.getServiceFactories()).thenReturn(serviceFactories);
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
index 3cacfbc..2c69afb 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
@@ -20,10 +20,17 @@ package org.apache.sshd.common.cipher;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.NamedResource;
 import org.apache.sshd.common.random.Random;
+import org.apache.sshd.common.util.buffer.BufferUtils;
 import org.apache.sshd.server.SshServer;
 import org.apache.sshd.util.BaseTestSupport;
 import org.apache.sshd.util.BogusPasswordAuthenticator;
@@ -31,10 +38,13 @@ import org.apache.sshd.util.EchoShellFactory;
 import org.apache.sshd.util.JSchLogger;
 import org.apache.sshd.util.SimpleUserInfo;
 import org.apache.sshd.util.Utils;
-import org.junit.After;
+import org.junit.Assume;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.junit.runners.MethodSorters;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import com.jcraft.jsch.JSch;
 
@@ -44,65 +54,114 @@ import com.jcraft.jsch.JSch;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(Parameterized.class)   // see https://github.com/junit-team/junit/wiki/Parameterized-tests
 public class CipherTest extends BaseTestSupport {
-
-    private SshServer sshd;
-    private int port;
-
-    @Test
-    public void testAES128CBC() throws Exception {
-        if (BuiltinCiphers.aes128cbc.isSupported()
-                && checkCipher(com.jcraft.jsch.jce.AES128CBC.class.getName())) {
-            setUp(BuiltinCiphers.aes128cbc);
-            runTest();
-        }
+    private static final Integer NUM_LOADTEST_ROUNDS = Integer.valueOf(100000);
+
+    /*
+     * NOTE !!! order is important since we build from it the C2S/S2C ciphers proposal
+     */
+    private static final List<Object[]> PARAMETERS =
+            Collections.unmodifiableList(Arrays.asList(
+                new Object[] { BuiltinCiphers.aes128cbc, com.jcraft.jsch.jce.AES128CBC.class, NUM_LOADTEST_ROUNDS },
+                new Object[] { BuiltinCiphers.tripledescbc, com.jcraft.jsch.jce.TripleDESCBC.class, NUM_LOADTEST_ROUNDS },
+                new Object[] { BuiltinCiphers.blowfishcbc, com.jcraft.jsch.jce.BlowfishCBC.class, NUM_LOADTEST_ROUNDS },
+                new Object[] { BuiltinCiphers.aes192cbc, com.jcraft.jsch.jce.AES192CBC.class, NUM_LOADTEST_ROUNDS  },
+                new Object[] { BuiltinCiphers.aes256cbc, com.jcraft.jsch.jce.AES256CBC.class, NUM_LOADTEST_ROUNDS  }
+                    ));
+
+    @SuppressWarnings("synthetic-access")
+    private static final List<NamedResource> TEST_CIPHERS = 
+            Collections.unmodifiableList(new ArrayList<NamedResource>(PARAMETERS.size()) {
+                private static final long serialVersionUID = 1L;    // we're not serializing it
+                
+                {
+                    for (Object[] params : PARAMETERS) {
+                        add((NamedResource) params[0]);
+                    }
+                    
+                    add(BuiltinCiphers.none);
+                }
+            });
+
+    private static final String CRYPT_NAMES = NamedResource.Utils.getNames(TEST_CIPHERS);
+
+    @Parameters(name = "cipher={0}, load={2}")
+    public static Collection<Object[]> parameters() {
+        return PARAMETERS;
     }
 
-    @Test
-    public void testAES192CBC() throws Exception {
-        if (BuiltinCiphers.aes192cbc.isSupported()
-                && checkCipher(com.jcraft.jsch.jce.AES192CBC.class.getName())) {
-            setUp(BuiltinCiphers.aes192cbc);
-            runTest();
-        }
-    }
+    private final Random random = Utils.getRandomizerInstance();
+    private final BuiltinCiphers builtInCipher;
+    private final Class<? extends com.jcraft.jsch.Cipher> jschCipher;
+    private final int loadTestRounds;
 
-    @Test
-    public void testAES256CBC() throws Exception {
-        if (BuiltinCiphers.aes256cbc.isSupported()
-                && checkCipher(com.jcraft.jsch.jce.AES256CBC.class.getName())) {
-            setUp(BuiltinCiphers.aes256cbc);
-            runTest();
-        }
+    public CipherTest(BuiltinCiphers builtInCipher, Class<? extends com.jcraft.jsch.Cipher> jschCipher, int loadTestRounds) {
+        this.builtInCipher = builtInCipher;
+        this.jschCipher = jschCipher;
+        this.loadTestRounds = loadTestRounds;
     }
 
     @Test
-    public void testBlowfishCBC() throws Exception {
-        if (BuiltinCiphers.blowfishcbc.isSupported()
-                && checkCipher(com.jcraft.jsch.jce.BlowfishCBC.class.getName())) {
-            setUp(BuiltinCiphers.blowfishcbc);
-            runTest();
+    public void testBuiltinCipherSession() throws Exception {
+        Assume.assumeTrue("No internal support for " + builtInCipher.getName(), builtInCipher.isSupported() && checkCipher(jschCipher.getName()));
+        
+        try(SshServer sshd = SshServer.setUpDefaultServer()) {
+            sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
+            sshd.setCipherFactories(Arrays.<NamedFactory<org.apache.sshd.common.cipher.Cipher>>asList(builtInCipher));
+            sshd.setShellFactory(new EchoShellFactory());
+            sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
+            sshd.start();
+         
+            try {
+                runJschTest(sshd.getPort());
+            } finally {
+                sshd.stop(true);
+            }
         }
     }
 
-    @Test
-    public void testTripleDESCBC() throws Exception {
-        if (BuiltinCiphers.tripledescbc.isSupported()
-                && checkCipher(com.jcraft.jsch.jce.TripleDESCBC.class.getName())) {
-            setUp(BuiltinCiphers.tripledescbc);
-            runTest();
+    private void runJschTest(int port) throws Exception {
+        JSchLogger.init();
+        JSch sch = new JSch();
+        JSch.setConfig("cipher.s2c", CRYPT_NAMES);
+        JSch.setConfig("cipher.c2s", CRYPT_NAMES);
+        com.jcraft.jsch.Session s = sch.getSession(getCurrentTestName(), "localhost", port);
+        s.setUserInfo(new SimpleUserInfo(getCurrentTestName()));
+        s.connect();
+        
+        try {
+            com.jcraft.jsch.Channel c = s.openChannel("shell");
+            c.connect();
+            
+            try(OutputStream os = c.getOutputStream();
+                InputStream is = c.getInputStream()) {
+                String expected = "this is my command\n"; 
+                byte[] expData = expected.getBytes(StandardCharsets.UTF_8);
+                byte[] actData = new byte[expData.length + Long.SIZE /* just in case */];
+                for (int i = 0; i < 10; i++) {
+                    os.write(expData);
+                    os.flush();
+
+                    int len = is.read(actData);
+                    String actual = new String(actData, 0, len);
+                    assertEquals("Mismatched command at iteration " + i, expected, actual);
+                }
+            } finally {
+                c.disconnect();
+            }
+        } finally {
+            s.disconnect();
         }
     }
 
     @Test
-    public void loadTest() throws Exception {
-        Random random = Utils.getRandomizerInstance();
-        loadTest(BuiltinCiphers.aes128cbc, random);
-        loadTest(BuiltinCiphers.blowfishcbc, random);
-        loadTest(BuiltinCiphers.tripledescbc, random);
+    public void testCipherLoad() throws Exception {
+        Assume.assumeTrue("No internal support for " + builtInCipher.getName(), builtInCipher.isSupported());
+        loadTest(builtInCipher, random, loadTestRounds);
     }
 
-    protected void loadTest(NamedFactory<Cipher> factory, Random random) throws Exception {
+    private static void loadTest(NamedFactory<Cipher> factory, Random random, int numRounds) throws Exception {
         Cipher cipher = factory.create();
         byte[] key = new byte[cipher.getBlockSize()];
         byte[] iv = new byte[cipher.getIVSize()];
@@ -110,56 +169,14 @@ public class CipherTest extends BaseTestSupport {
         random.fill(iv, 0, iv.length);
         cipher.init(Cipher.Mode.Encrypt, key, iv);
 
-        byte[] input = new byte[cipher.getBlockSize()];
+        byte[] input = new byte[BufferUtils.getNextPowerOf2(key.length)];
         random.fill(input, 0, input.length);
         long t0 = System.currentTimeMillis();
-        for (int i = 0; i < 100000; i++) {
+        for (int i = 0; i < numRounds; i++) {
             cipher.update(input, 0, input.length);
         }
         long t1 = System.currentTimeMillis();
-        System.err.println(factory.getName() + ": " + (t1 - t0) + " ms");
-    }
-
-
-    protected void setUp(NamedFactory<org.apache.sshd.common.cipher.Cipher> cipher) throws Exception {
-        sshd = SshServer.setUpDefaultServer();
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setCipherFactories(Arrays.<NamedFactory<org.apache.sshd.common.cipher.Cipher>>asList(cipher));
-        sshd.setShellFactory(new EchoShellFactory());
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-        sshd.start();
-        port = sshd.getPort();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        if (sshd != null) {
-            sshd.stop(true);
-        }
-    }
-
-    protected void runTest() throws Exception {
-        JSchLogger.init();
-        JSch sch = new JSch();
-        JSch.setConfig("cipher.s2c", "aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,none");
-        JSch.setConfig("cipher.c2s", "aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,none");
-        com.jcraft.jsch.Session s = sch.getSession(getCurrentTestName(), "localhost", port);
-        s.setUserInfo(new SimpleUserInfo(getCurrentTestName()));
-        s.connect();
-        com.jcraft.jsch.Channel c = s.openChannel("shell");
-        c.connect();
-        OutputStream os = c.getOutputStream();
-        InputStream is = c.getInputStream();
-        for (int i = 0; i < 10; i++) {
-            os.write("this is my command\n".getBytes());
-            os.flush();
-            byte[] data = new byte[512];
-            int len = is.read(data);
-            String str = new String(data, 0, len);
-            assertEquals("this is my command\n", str);
-        }
-        c.disconnect();
-        s.disconnect();
+        System.err.println(factory.getName() + "[" + numRounds + "]: " + (t1 - t0) + " ms");
     }
 
     static boolean checkCipher(String cipher){
@@ -172,6 +189,7 @@ public class CipherTest extends BaseTestSupport {
             return true;
         }
         catch(Exception e){
+            System.err.println("checkCipher(" + cipher + ") " + e.getClass().getSimpleName() + ": " + e.getMessage());
             return false;
         }
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
index 05e62c2..2f51a61 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
@@ -31,6 +31,7 @@ import org.apache.sshd.common.cipher.ECCurves;
 import org.apache.sshd.common.digest.BaseDigest;
 import org.apache.sshd.common.digest.BuiltinDigests;
 import org.apache.sshd.common.digest.Digest;
+import org.apache.sshd.common.digest.DigestFactory;
 import org.apache.sshd.common.digest.DigestInformation;
 import org.apache.sshd.common.keyprovider.KeyPairProvider;
 import org.apache.sshd.common.util.GenericUtils;
@@ -117,7 +118,12 @@ public class KeyUtilsTest extends BaseTestSupport {
                         throw thrown;
                     }
                 };
-            String actual = KeyUtils.getFingerPrint(new Factory<Digest>() {
+            String actual = KeyUtils.getFingerPrint(new DigestFactory() {
+                    @Override
+                    public String getName() {
+                        return getCurrentTestName();
+                    }
+
                     @Override
                     public Digest create() {
                         return digest;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
index bd9e5bb..42c4a5a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
@@ -20,7 +20,7 @@ package org.apache.sshd.deprecated;
 
 import java.io.IOException;
 
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.DefaultAuthFuture;
 import org.apache.sshd.client.session.ClientSessionImpl;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
index d0f4c78..3386428 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
@@ -26,7 +26,7 @@ import static org.apache.sshd.common.SshConstants.SSH_MSG_USERAUTH_SUCCESS;
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.util.buffer.Buffer;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index 2c43d77..115f700 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -113,7 +113,7 @@ public class ServerTest extends BaseTestSupport {
         client = SshClient.setUpDefaultClient();
         client.setServiceFactories(Arrays.asList(
                 new ClientUserAuthServiceOld.Factory(),
-                new ClientConnectionService.Factory()
+                ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
         ));
         client.start();
         
@@ -144,7 +144,7 @@ public class ServerTest extends BaseTestSupport {
         client = SshClient.setUpDefaultClient();
         client.setServiceFactories(Arrays.asList(
                 new ClientUserAuthServiceOld.Factory(),
-                new ClientConnectionService.Factory()
+                ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
         ));
         client.start();
         try(ClientSession s = client.connect(getCurrentTestName(), "localhost", port).verify(7L, TimeUnit.SECONDS).getSession()) {


[2/2] mina-sshd git commit: [SSHD-509] Use targeted derived NamedFactory(ies) for the various generic parameters

Posted by lg...@apache.org.
[SSHD-509] Use targeted derived NamedFactory(ies) for the various generic parameters


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

Branch: refs/heads/master
Commit: 84d41b5822b26d3d5307dfa83da854ed30c93235
Parents: e06cfdc
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Jun 30 13:26:25 2015 +0300
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Jun 30 13:26:25 2015 +0300

----------------------------------------------------------------------
 .../org/apache/sshd/agent/SshAgentFactory.java  |   3 +-
 .../agent/local/ChannelAgentForwarding.java     |   4 +-
 .../sshd/agent/local/ProxyAgentFactory.java     |   6 +-
 .../sshd/agent/unix/ChannelAgentForwarding.java |   4 +-
 .../sshd/agent/unix/UnixAgentFactory.java       |  22 +--
 .../sshd/client/ClientFactoryManager.java       |   2 +
 .../java/org/apache/sshd/client/SshClient.java  |  15 +-
 .../java/org/apache/sshd/client/UserAuth.java   |  39 ----
 .../org/apache/sshd/client/UserInteraction.java |  41 ----
 .../org/apache/sshd/client/auth/UserAuth.java   |  39 ++++
 .../sshd/client/auth/UserAuthFactory.java       |  36 ++++
 .../auth/UserAuthKeyboardInteractive.java       |   5 +-
 .../sshd/client/auth/UserAuthPassword.java      |   4 +-
 .../sshd/client/auth/UserAuthPublicKey.java     |  27 +--
 .../sshd/client/auth/UserInteraction.java       |  52 +++++
 .../client/channel/AbstractClientChannel.java   |   6 +-
 .../org/apache/sshd/client/kex/DHGClient.java   |   5 +-
 .../org/apache/sshd/client/kex/DHGEXClient.java |   5 +-
 .../client/session/ClientConnectionService.java |   7 +-
 .../sshd/client/session/ClientSession.java      |   2 +-
 .../sshd/client/session/ClientSessionImpl.java  |   2 +-
 .../client/session/ClientUserAuthService.java   |  11 +-
 .../org/apache/sshd/common/NamedFactory.java    |  24 +--
 .../org/apache/sshd/common/NamedResource.java   |  14 +-
 .../org/apache/sshd/common/ServiceFactory.java  |  20 +-
 .../sshd/common/channel/ChannelFactory.java     |  36 ++++
 .../common/channel/ChannelRequestHandler.java   |  36 ++++
 .../org/apache/sshd/common/cipher/Cipher.java   |  33 ++--
 .../sshd/common/digest/BuiltinDigests.java      |   2 +-
 .../sshd/common/digest/DigestFactory.java       |  37 ++++
 .../common/forward/DefaultTcpipForwarder.java   |   5 +-
 .../apache/sshd/common/io/IoHandlerFactory.java |  37 ++++
 .../sshd/common/kex/KeyExchangeFactory.java     |  37 ++++
 .../ConnectionServiceRequestHandler.java        |  38 ++++
 .../apache/sshd/common/util/GenericUtils.java   |  20 +-
 .../org/apache/sshd/server/ServerBuilder.java   |  15 +-
 .../sshd/server/ServerFactoryManager.java       |   1 +
 .../java/org/apache/sshd/server/SshServer.java  |   1 +
 .../java/org/apache/sshd/server/UserAuth.java   |  70 -------
 .../sshd/server/auth/AbstractUserAuth.java      |   1 -
 .../org/apache/sshd/server/auth/UserAuth.java   |  70 +++++++
 .../sshd/server/auth/UserAuthFactory.java       |  37 ++++
 .../auth/UserAuthKeyboardInteractive.java       |   4 +-
 .../apache/sshd/server/auth/UserAuthNone.java   |   4 +-
 .../sshd/server/auth/UserAuthPassword.java      |   4 +-
 .../sshd/server/auth/UserAuthPublicKey.java     |   3 +-
 .../sshd/server/auth/gss/UserAuthGSS.java       |  12 +-
 .../sshd/server/channel/ChannelSession.java     |  43 ++--
 .../server/channel/PuttyRequestHandler.java     |   8 +-
 .../sshd/server/forward/TcpipServerChannel.java |   4 +-
 .../global/CancelTcpipForwardHandler.java       |   7 +-
 .../sshd/server/global/KeepAliveHandler.java    |   6 +-
 .../server/global/NoMoreSessionsHandler.java    |   6 +-
 .../sshd/server/global/TcpipForwardHandler.java |   5 +-
 .../org/apache/sshd/server/kex/DHGEXServer.java |   5 +-
 .../org/apache/sshd/server/kex/DHGServer.java   |   5 +-
 .../server/session/ServerUserAuthService.java   |   2 +-
 .../org/apache/sshd/AuthenticationTest.java     |   8 +-
 .../java/org/apache/sshd/WelcomeBannerTest.java |   2 +-
 .../java/org/apache/sshd/client/ClientTest.java |   6 +-
 .../client/session/ClientSessionImplTest.java   |   4 +-
 .../apache/sshd/common/cipher/CipherTest.java   | 196 ++++++++++---------
 .../sshd/common/config/keys/KeyUtilsTest.java   |   8 +-
 .../deprecated/ClientUserAuthServiceOld.java    |   2 +-
 .../deprecated/UserAuthKeyboardInteractive.java |   2 +-
 .../java/org/apache/sshd/server/ServerTest.java |   4 +-
 66 files changed, 797 insertions(+), 424 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
index ba12eaf..33ff448 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java
@@ -31,11 +31,10 @@ import org.apache.sshd.common.session.ConnectionService;
 public interface SshAgentFactory {
 
     /**
-     * Retrieve the channel factory used to create channels on the client side.
      * The channels are requested by the ssh server when forwarding a client request.
      * The channel will receive agent requests and need to forward them to the agent,
      * either local or through another proxy.
-     * @return
+     * @return The channel factory used to create channels on the client side
      */
     NamedFactory<Channel> getChannelForwardingFactory();
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
index 6aef192..a59d7d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
@@ -25,9 +25,9 @@ import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.common.AbstractAgentClient;
 import org.apache.sshd.client.future.DefaultOpenFuture;
 import org.apache.sshd.client.future.OpenFuture;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
 import org.apache.sshd.common.channel.ChannelOutputStream;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.SshFutureListener;
@@ -40,7 +40,7 @@ import org.apache.sshd.server.channel.AbstractServerChannel;
  */
 public class ChannelAgentForwarding extends AbstractServerChannel {
 
-    public static class ChannelAgentForwardingFactory implements NamedFactory<Channel> {
+    public static class ChannelAgentForwardingFactory implements ChannelFactory {
         public static final ChannelAgentForwardingFactory INSTANCE = new ChannelAgentForwardingFactory();
 
         public ChannelAgentForwardingFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
index 4b3e02a..11d30ef 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
@@ -39,9 +39,13 @@ public class ProxyAgentFactory implements SshAgentFactory {
 
     private final Map<String, AgentServerProxy> proxies = new ConcurrentHashMap<String, AgentServerProxy>();
 
+    public ProxyAgentFactory() {
+        super();
+    }
+
     @Override
     public NamedFactory<Channel> getChannelForwardingFactory() {
-        return new ChannelAgentForwarding.ChannelAgentForwardingFactory();
+        return ChannelAgentForwarding.ChannelAgentForwardingFactory.INSTANCE;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index 7a38bdd..6cfc81a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -28,9 +28,9 @@ import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.client.future.DefaultOpenFuture;
 import org.apache.sshd.client.future.OpenFuture;
 import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelFactory;
 import org.apache.sshd.common.channel.ChannelOutputStream;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.SshFutureListener;
@@ -49,7 +49,7 @@ import org.apache.tomcat.jni.Status;
  */
 public class ChannelAgentForwarding extends AbstractServerChannel {
 
-    public static class ChannelAgentForwardingFactory implements NamedFactory<Channel>, ExecutorServiceCarrier {
+    public static class ChannelAgentForwardingFactory implements ChannelFactory, ExecutorServiceCarrier {
         public static final ChannelAgentForwardingFactory INSTANCE = new ChannelAgentForwardingFactory();
         
         public ChannelAgentForwardingFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
index c101842..e2c9ea5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
@@ -40,17 +40,17 @@ public class UnixAgentFactory implements SshAgentFactory, ExecutorServiceConfigu
     private ExecutorService executor;
     private boolean shutdownExecutor;
     private final NamedFactory<Channel> factory = new ChannelAgentForwarding.ChannelAgentForwardingFactory() {
-        @Override
-        public ExecutorService getExecutorService() {
-            return UnixAgentFactory.this.getExecutorService();
-        }
-
-        @Override
-        public boolean isShutdownOnExit() {
-            return UnixAgentFactory.this.isShutdownOnExit();
-        }
-        
-    };
+            @Override
+            public ExecutorService getExecutorService() {
+                return UnixAgentFactory.this.getExecutorService();
+            }
+    
+            @Override
+            public boolean isShutdownOnExit() {
+                return UnixAgentFactory.this.isShutdownOnExit();
+            }
+            
+        };
 
     public UnixAgentFactory() {
         super();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
index 0af6014..cf105d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
@@ -20,6 +20,8 @@ package org.apache.sshd.client;
 
 import java.util.List;
 
+import org.apache.sshd.client.auth.UserAuth;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 9b814d7..659e718 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -38,9 +38,12 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
+import org.apache.sshd.agent.SshAgentFactory;
+import org.apache.sshd.client.auth.UserAuth;
 import org.apache.sshd.client.auth.UserAuthKeyboardInteractive;
 import org.apache.sshd.client.auth.UserAuthPassword;
 import org.apache.sshd.client.auth.UserAuthPublicKey;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.channel.ChannelShell;
 import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.config.keys.ClientIdentity;
@@ -166,26 +169,28 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
         ValidateUtils.checkNotNull(getServerKeyVerifier(), "ServerKeyVerifier not set", GenericUtils.EMPTY_OBJECT_ARRAY);
 
         // Register the additional agent forwarding channel if needed
-        if (getAgentFactory() != null) {
+        SshAgentFactory agentFactory = getAgentFactory();
+        if (agentFactory != null) {
             List<NamedFactory<Channel>> factories = getChannelFactories();
             if (GenericUtils.isEmpty(factories)) {
                 factories = new ArrayList<NamedFactory<Channel>>();
             } else {
                 factories = new ArrayList<NamedFactory<Channel>>(factories);
             }
-            factories.add(getAgentFactory().getChannelForwardingFactory());
+            factories.add(ValidateUtils.checkNotNull(agentFactory.getChannelForwardingFactory(), "No agent channel forwarding factory for %s", agentFactory));
+
             setChannelFactories(factories);
         }
 
         if (GenericUtils.isEmpty(getServiceFactories())) {
             setServiceFactories(Arrays.asList(
-                    new ClientUserAuthService.Factory(),
-                    new ClientConnectionService.Factory()
+                    ClientUserAuthService.ClientUserAuthServiceFactory.INSTANCE,
+                    ClientConnectionService.ClientConnectionServiceFactory.INSTANCE
             ));
         }
 
         if (GenericUtils.isEmpty(getUserAuthFactories())) {
-            setUserAuthFactories(Arrays.asList(
+            setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(
                     UserAuthPublicKey.UserAuthPublicKeyFactory.INSTANCE,
                     UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory.INSTANCE,
                     UserAuthPassword.UserAuthPasswordFactory.INSTANCE

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
deleted file mode 100644
index 7e8d337..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/UserAuth.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 org.apache.sshd.client;
-
-import java.util.Collection;
-
-import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public interface UserAuth {
-
-    void init(ClientSession session, String service, Collection<?> identities) throws Exception;
-
-    boolean process(Buffer buffer) throws Exception;
-
-    void destroy();
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java b/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
deleted file mode 100644
index d828a6b..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/UserInteraction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 org.apache.sshd.client;
-
-/**
- * Interface used by the ssh client to communicate with the end user.
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <a href="https://www.ietf.org/rfc/rfc4256.txt">RFC 4256</A>
- */
-public interface UserInteraction {
-
-    /**
-     * Displays the welcome banner to the user.
-     *
-     * @param banner the welcome banner
-     */
-    void welcome(String banner);
-
-    String[] interactive(String destination,
-                         String name,
-                         String instruction,
-                         String lang,
-                         String[] prompt,
-                         boolean[] echo);
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
new file mode 100644
index 0000000..808ef14
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.client.auth;
+
+import java.util.Collection;
+
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * TODO Add javadoc
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuth {
+
+    void init(ClientSession session, String service, Collection<?> identities) throws Exception;
+
+    boolean process(Buffer buffer) throws Exception;
+
+    void destroy();
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
new file mode 100644
index 0000000..e72f409
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.client.auth;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuthFactory extends NamedFactory<UserAuth> {
+    // required because of generics issues
+    Transformer<UserAuthFactory,NamedFactory<UserAuth>> FAC2NAMED=new Transformer<UserAuthFactory,NamedFactory<UserAuth>>() {
+        @Override
+        public NamedFactory<UserAuth> transform(UserAuthFactory input) {
+            return input;
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
index 4cbdc8f..57ade35 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
@@ -28,10 +28,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.sshd.client.ClientFactoryManager;
-import org.apache.sshd.client.UserAuth;
-import org.apache.sshd.client.UserInteraction;
 import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
@@ -44,7 +41,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  */
 public class UserAuthKeyboardInteractive extends AbstractLoggingBean implements UserAuth {
 
-    public static class UserAuthKeyboardInteractiveFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthKeyboardInteractiveFactory implements UserAuthFactory {
         public static final UserAuthKeyboardInteractiveFactory INSTANCE = new UserAuthKeyboardInteractiveFactory();
 
         public UserAuthKeyboardInteractiveFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
index b9e885b..d0482f9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
@@ -23,9 +23,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.sshd.client.UserAuth;
 import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -37,7 +35,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  */
 public class UserAuthPassword extends AbstractLoggingBean implements UserAuth {
 
-    public static class UserAuthPasswordFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthPasswordFactory implements UserAuthFactory {
         public static final UserAuthPasswordFactory INSTANCE = new UserAuthPasswordFactory();
 
         public UserAuthPasswordFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
index e691825..e737d57 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
@@ -18,8 +18,6 @@
  */
 package org.apache.sshd.client.auth;
 
-import static org.apache.sshd.common.config.keys.KeyUtils.getKeyType;
-
 import java.io.IOException;
 import java.security.KeyPair;
 import java.security.PublicKey;
@@ -30,13 +28,12 @@ import java.util.List;
 
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.SshAgentFactory;
-import org.apache.sshd.client.UserAuth;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
+import org.apache.sshd.common.config.keys.KeyUtils;
 import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.signature.Signature;
 import org.apache.sshd.common.util.Pair;
 import org.apache.sshd.common.util.ValidateUtils;
@@ -51,7 +48,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
  */
 public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
 
-    public static class UserAuthPublicKeyFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthPublicKeyFactory implements UserAuthFactory {
         public static final String NAME = "publickey";
         public static final UserAuthPublicKeyFactory INSTANCE = new UserAuthPublicKeyFactory();
 
@@ -117,8 +114,9 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
             if (keys.hasNext()) {
                 current = keys.next();
                 PublicKey key = current.getPublicKey();
-                String algo = getKeyType(key);
-                log.debug("Send SSH_MSG_USERAUTH_REQUEST for publickey");
+                String algo = KeyUtils.getKeyType(key);
+                log.debug("Send SSH_MSG_USERAUTH_REQUEST request publickey algo={}", algo);
+
                 buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST);
                 buffer.putString(session.getUsername());
                 buffer.putString(service);
@@ -129,13 +127,16 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
                 session.writePacket(buffer);
                 return true;
             }
+            
+            log.debug("No more keys to send");
             return false;
         }
+
         byte cmd = buffer.getByte();
         if (cmd == SshConstants.SSH_MSG_USERAUTH_PK_OK) {
             PublicKey key = current.getPublicKey();
-            String algo = getKeyType(key);
-            log.debug("Send SSH_MSG_USERAUTH_REQUEST for publickey");
+            String algo = KeyUtils.getKeyType(key);
+            log.debug("Send SSH_MSG_USERAUTH_REQUEST reply publickey algo={}", algo);
             buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST);
             buffer.putString(session.getUsername());
             buffer.putString(service);
@@ -145,7 +146,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
             buffer.putPublicKey(key);
 
             Buffer bs = new ByteArrayBuffer();
-            bs.putBytes(((AbstractSession) session).getKex().getH());
+            bs.putBytes(session.getKex().getH());
             bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
             bs.putString(session.getUsername());
             bs.putString(service);
@@ -153,8 +154,8 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
             bs.putByte((byte) 1);
             bs.putString(algo);
             bs.putPublicKey(key);
-            byte[] sig = current.sign(bs.getCompactData());
 
+            byte[] sig = current.sign(bs.getCompactData());
             bs = new ByteArrayBuffer();
             bs.putString(algo);
             bs.putBytes(sig);
@@ -164,7 +165,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
             return true;
         }
 
-        throw new IllegalStateException("Received unknown packet");
+        throw new IllegalStateException("Received unknown packet: cmd=" + cmd);
     }
 
     @Override
@@ -219,7 +220,7 @@ public class UserAuthPublicKey extends AbstractLoggingBean implements UserAuth {
 
         @Override
         public byte[] sign(byte[] data) throws Exception {
-            String keyType = getKeyType(pair);
+            String keyType = KeyUtils.getKeyType(pair);
             Signature verif = ValidateUtils.checkNotNull(
                     NamedFactory.Utils.create(manager.getSignatureFactories(), keyType),
                     "No signer could be located for key type=%s",

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
new file mode 100644
index 0000000..fad4694
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserInteraction.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.client.auth;
+
+/**
+ * Interface used by the ssh client to communicate with the end user.
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @see <a href="https://www.ietf.org/rfc/rfc4256.txt">RFC 4256</A>
+ */
+public interface UserInteraction {
+
+    /**
+     * Displays the welcome banner to the user.
+     * @param banner The welcome banner
+     */
+    void welcome(String banner);
+
+    /**
+     * @param destination The session identifier
+     * @param name The interaction name (may be empty)
+     * @param instruction The instruction (may be empty)
+     * @param lang The language for the data (may be empty)
+     * @param prompt The prompts to be displayed (may be empty)
+     * @param echo For each prompt whether to echo the user's response
+     * @return The replies - <B>Note:</B> the protocol states that the number
+     * of replies should be <U>exactly</U> the same as the number of prompts,
+     * however we do not enforce it since it is defined as the <U>server's</U>
+     * job to check and manage this violation
+     */
+    String[] interactive(String destination,
+                         String name,
+                         String instruction,
+                         String lang,
+                         String[] prompt,
+                         boolean[] echo);
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index b444c16..dd2de79 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.channel.AbstractChannel;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.ChannelAsyncInputStream;
 import org.apache.sshd.common.channel.ChannelAsyncOutputStream;
-import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.channel.ChannelRequestHandler;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.util.buffer.Buffer;
@@ -328,7 +328,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
         return exitStatus;
     }
 
-    private class ExitStatusChannelRequestHandler implements RequestHandler<Channel> {
+    private class ExitStatusChannelRequestHandler implements ChannelRequestHandler {
         public ExitStatusChannelRequestHandler() {
             super();
         }
@@ -345,7 +345,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
         }
     }
 
-    private class ExitSignalChannelRequestHandler implements RequestHandler<Channel> {
+    private class ExitSignalChannelRequestHandler implements ChannelRequestHandler {
         public ExitSignalChannelRequestHandler() {
             super();
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
index 4667987..cdbf6a4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
@@ -26,6 +26,7 @@ import org.apache.sshd.common.config.keys.KeyUtils;
 import org.apache.sshd.common.kex.AbstractDH;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
 import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.signature.Signature;
@@ -46,8 +47,8 @@ public class DHGClient extends AbstractDHClientKeyExchange {
     protected final DHFactory factory;
     protected AbstractDH dh;
 
-    public static final NamedFactory<KeyExchange> newFactory(final DHFactory delegate) {
-        return new NamedFactory<KeyExchange>() {
+    public static final KeyExchangeFactory newFactory(final DHFactory delegate) {
+        return new KeyExchangeFactory() {
             @Override
             public String getName() {
                 return delegate.getName();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
index 00319b8..79c1a4a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
@@ -29,6 +29,7 @@ import org.apache.sshd.common.config.keys.KeyUtils;
 import org.apache.sshd.common.kex.AbstractDH;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.kex.KeyExchangeFactory;
 import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.signature.Signature;
@@ -52,8 +53,8 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
     protected byte[] p;
     protected byte[] g;
 
-    public static final NamedFactory<KeyExchange> newFactory(final DHFactory delegate) {
-        return new NamedFactory<KeyExchange>() {
+    public static final KeyExchangeFactory newFactory(final DHFactory delegate) {
+        return new KeyExchangeFactory() {
             @Override
             public String getName() {
                 return delegate.getName();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
index 9be89e3..38bd7be 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
@@ -41,7 +41,12 @@ import org.apache.sshd.common.util.buffer.Buffer;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class ClientConnectionService extends AbstractConnectionService {
-    public static class Factory implements ServiceFactory {
+    public static class ClientConnectionServiceFactory implements ServiceFactory {
+        public static final ClientConnectionServiceFactory INSTANCE = new ClientConnectionServiceFactory();
+
+        public ClientConnectionServiceFactory() {
+            super();
+        }
 
         @Override
         public String getName() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index d694b75..442c5d2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 import org.apache.sshd.client.ClientFactoryManager;
 import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.channel.ChannelDirectTcpip;
 import org.apache.sshd.client.channel.ChannelExec;
 import org.apache.sshd.client.channel.ChannelShell;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index 50c0d5a..305c53b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -31,7 +31,7 @@ import java.util.Map;
 
 import org.apache.sshd.client.ClientFactoryManager;
 import org.apache.sshd.client.ServerKeyVerifier;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.channel.ChannelDirectTcpip;
 import org.apache.sshd.client.channel.ChannelExec;
 import org.apache.sshd.client.channel.ChannelShell;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 1658e48..42a728a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -24,8 +24,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.sshd.client.ClientFactoryManager;
-import org.apache.sshd.client.UserAuth;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.auth.UserAuth;
+import org.apache.sshd.client.auth.UserInteraction;
 import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.future.DefaultAuthFuture;
 import org.apache.sshd.common.FactoryManagerUtils;
@@ -46,7 +46,12 @@ import org.apache.sshd.common.util.buffer.Buffer;
  */
 public class ClientUserAuthService extends CloseableUtils.AbstractCloseable implements Service {
 
-    public static class Factory implements ServiceFactory {
+    public static class ClientUserAuthServiceFactory implements ServiceFactory {
+        public static final ClientUserAuthServiceFactory INSTANCE = new ClientUserAuthServiceFactory();
+
+        public ClientUserAuthServiceFactory() {
+            super();
+        }
 
         @Override
         public String getName() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
index 76c1e0c..16e797b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.Transformer;
 
 /**
@@ -50,7 +49,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
         /**
          * Create an instance of the specified name by looking up the needed factory
          * in the list.
-         * 
          * @param factories list of available factories
          * @param name the factory name to use
          * @param <T> type of object to create
@@ -67,7 +65,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
 
         /**
          * Get a comma separated list of the factory names from the given list.
-         *
          * @param factories list of available factories
          * @return a comma separated list of factory names
          * @deprecated Use {@link NamedResource.Utils#getNames(Collection)}
@@ -79,7 +76,6 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
 
         /**
          * Remove the factory identified by the name from the list.
-         *
          * @param factories list of factories
          * @param name the name of the factory to remove
          * @param <T> type of object to create
@@ -95,23 +91,15 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
 
         /**
          * Retrieve the factory identified by its name from the list.
-         *
          * @param factories list of available factories
-         * @param name the name of the factory to retrieve
-         * @param <T> type of object create by the factories
-         * @return a factory or <code>null</code> if not found in the list
+         * @param name the name of the factory to retrieve - ignored if {@code null}/empty
+         * @param <T> type of object create by the factories - ignored if {@code null}/empty
+         * @return A (case <U>insensitive</U>) matching factory or {@code null} if not found in the list
+         * @deprecated Use {@link NamedResource.Utils#findByName(String, java.util.Comparator, Collection)
          */
+        @Deprecated
         public static <T> NamedFactory<T> get(Collection<? extends NamedFactory<T>> factories, String name) {
-            if (GenericUtils.isEmpty(factories)) {
-                return null;
-            }
-
-            for (NamedFactory<T> f : factories) {
-                if (f.getName().equals(name)) {
-                    return f;
-                }
-            }
-            return null;
+            return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
         }
 
         public static final <S extends OptionalFeature,T,E extends NamedFactory<T>> List<NamedFactory<T>> setUpTransformedFactories(

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
index e1c2287..c5032d8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
@@ -95,11 +95,21 @@ public interface NamedResource {
         
         /**
          * @param name Name of the resource - ignored if {@code null}/empty
+         * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
+         * @return The <U>first</U> resource whose name matches case <U>sensitive</U>
+         * the given name - {@code null} if no match found
+         */
+        public static <R extends NamedResource> R findByName(String name, Collection<? extends R> resources) {
+            return findByName(name, GenericUtils.CASE_SENSITIVE_ORDER, resources);
+        }
+
+        /**
+         * @param name Name of the resource - ignored if {@code null}/empty
          * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
          * matches the <tt>name</tt> parameter
          * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
-         * @return The <U>first</U> resource whose name matches the parameter - {@code null}
-         * if no match found
+         * @return The <U>first</U> resource whose name matches the parameter (by invoking
+         * {@link Comparator#compare(Object, Object)} - {@code null} if no match found
          */
         public static <R extends NamedResource> R findByName(String name, Comparator<? super String> c, Collection<? extends R> resources) {
             if (GenericUtils.isEmpty(name) || GenericUtils.isEmpty(resources)) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
index 340f827..b6fd3df 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.Collection;
 
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.GenericUtils;
 
 public interface ServiceFactory extends NamedResource {
     Service create(Session session) throws IOException;
@@ -31,27 +30,22 @@ public interface ServiceFactory extends NamedResource {
      * Utility class to help using NamedFactories
      */
     public static class Utils {
-
         /**
          * Create an instance of the specified name by looking up the needed factory
-         * in the list.
-         *
+         * in the list (case <U>insensitive</U>.
          * @param factories list of available factories
          * @param name the factory name to use
          * @return a newly created object or <code>null</code> if the factory is not in the list
+         * @throws IOException if session creation failed
+         * @see ServiceFactory#create(Session)
          */
         public static Service create(Collection<? extends ServiceFactory> factories, String name, Session session) throws IOException {
-            if (GenericUtils.isEmpty(factories)) {
+            ServiceFactory factory = NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
+            if (factory == null) {
                 return null;
+            } else {
+                return factory.create(session);
             }
-
-            for (ServiceFactory f : factories) {
-                if (f.getName().equals(name)) {
-                    return f.create(session);
-                }
-            }
-
-            return null;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
new file mode 100644
index 0000000..bbfd1ad
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.channel;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ChannelFactory extends NamedFactory<Channel> {
+    // required because of generics issues
+    Transformer<ChannelFactory,NamedFactory<Channel>> FAC2NAMED=new Transformer<ChannelFactory,NamedFactory<Channel>>() {
+        @Override
+        public NamedFactory<Channel> transform(ChannelFactory input) {
+            return input;
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
new file mode 100644
index 0000000..1871068
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.channel;
+
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ChannelRequestHandler extends RequestHandler<Channel> {
+    // required because of generics issues
+    Transformer<ChannelRequestHandler,RequestHandler<Channel>> CHANN2HNDLR =
+            new Transformer<ChannelRequestHandler, RequestHandler<Channel>>() {
+                @Override
+                public RequestHandler<Channel> transform(ChannelRequestHandler input) {
+                    return input;
+                }
+            };
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java b/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
index e50ce14..b614fa3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/cipher/Cipher.java
@@ -31,44 +31,39 @@ public interface Cipher  {
     }
 
     /**
-     * Retrieves the size of the initialization vector
-     *
-     * @return
+     * @return Size of the initialization vector (in bytes)
      */
     int getIVSize();
 
     /**
-     * Retrieves the block size for this cipher
-     *
-     * @return
+     * @return The block size (in bytes) for this cipher
      */
     int getBlockSize();
 
     /**
      * Initialize the cipher for encryption or decryption with
-     * the given private key and initialization vector
-     *
-     * @param mode
-     * @param key
-     * @param iv
-     * @throws Exception
+     * the given key and initialization vector
+     * @param mode Encrypt/Decrypt initialization
+     * @param key Key bytes
+     * @param iv Initialization vector bytes
+     * @throws Exception If failed to initialize
      */
     void init(Mode mode, byte[] key, byte[] iv) throws Exception;
 
     /**
      * Performs in-place encryption or decryption on the given data.
      * @param input The input/output bytes
-     * @throws Exception
+     * @throws Exception If failed to execute
+     * @see #update(byte[], int, int)
      */
-    void update(byte[] input) throws Exception;
+    void update(byte[] input) throws Exception; // TODO make this a default method in JDK-8
 
     /**
      * Performs in-place encryption or decryption on the given data.
-     * 
-     * @param input
-     * @param inputOffset
-     * @param inputLen
-     * @throws Exception
+     * @param input The input/output bytes
+     * @param inputOffset The offset of the data in the data buffer
+     * @param inputLen The number of bytes to update - starting at the given offset
+     * @throws Exception If failed to execute
      */
     void update(byte[] input, int inputOffset, int inputLen) throws Exception;
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
index 679aa95..bce8b3a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.util.GenericUtils;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public enum BuiltinDigests implements DigestInformation, NamedFactory<Digest> {
+public enum BuiltinDigests implements DigestInformation, DigestFactory {
     md5(Constants.MD5, "MD5", 16),
     sha1(Constants.SHA1, "SHA-1", 20),
     sha256(Constants.SHA256, "SHA-256", 32),

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
new file mode 100644
index 0000000..0dd7d85
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.digest;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface DigestFactory extends NamedFactory<Digest> {
+    // required because of generics issues
+    Transformer<DigestFactory,NamedFactory<Digest>> FAC2NAMED=new Transformer<DigestFactory,NamedFactory<Digest>>() {
+        @Override
+        public NamedFactory<Digest> transform(DigestFactory input) {
+            return input;
+        }
+    };
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index 184c029..890297a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -37,6 +37,7 @@ import org.apache.sshd.common.SshdSocketAddress;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoHandler;
+import org.apache.sshd.common.io.IoHandlerFactory;
 import org.apache.sshd.common.io.IoServiceFactory;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.session.ConnectionService;
@@ -57,7 +58,7 @@ import org.apache.sshd.server.forward.ForwardingFilter;
 public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable implements TcpipForwarder {
 
     private final ConnectionService service;
-    private final Factory<IoHandler> socksProxyIoHandlerFactory = new Factory<IoHandler>() {
+    private final IoHandlerFactory socksProxyIoHandlerFactory = new IoHandlerFactory() {
             @Override
             public IoHandler create() {
                 return new SocksProxy(getConnectionService());
@@ -68,7 +69,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
     private final Map<Integer, SshdSocketAddress> remoteToLocal = new HashMap<Integer, SshdSocketAddress>();
     private final Map<Integer, SocksProxy> dynamicLocal = new HashMap<Integer, SocksProxy>();
     private final Set<LocalForwardingEntry> localForwards = new HashSet<LocalForwardingEntry>();
-    private final Factory<IoHandler> staticIoHandlerFactory = new Factory<IoHandler>() {
+    private final IoHandlerFactory staticIoHandlerFactory = new IoHandlerFactory() {
             @Override
             public IoHandler create() {
                 return new StaticIoHandler();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
new file mode 100644
index 0000000..168df15
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.io;
+
+import org.apache.sshd.common.Factory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface IoHandlerFactory extends Factory<IoHandler> {
+    // may be required due to generics reasons
+    Transformer<IoHandlerFactory,Factory<IoHandler>> FAC2FAC =
+            new Transformer<IoHandlerFactory, Factory<IoHandler>>() {
+                @Override
+                public Factory<IoHandler> transform(IoHandlerFactory input) {
+                    return input;
+                }
+            };
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
new file mode 100644
index 0000000..460ec60
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchangeFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.kex;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface KeyExchangeFactory extends NamedFactory<KeyExchange> {
+    // required because of generics issues
+    Transformer<KeyExchangeFactory,NamedFactory<KeyExchange>> FAC2NAMED=new Transformer<KeyExchangeFactory,NamedFactory<KeyExchange>>() {
+        @Override
+        public NamedFactory<KeyExchange> transform(KeyExchangeFactory input) {
+            return input;
+        }
+    };
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
new file mode 100644
index 0000000..fb09479
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionServiceRequestHandler.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.common.session;
+
+import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ConnectionServiceRequestHandler extends RequestHandler<ConnectionService> {
+    // required because of generics issues
+    Transformer<ConnectionServiceRequestHandler,RequestHandler<ConnectionService>> SVC2HNDLR =
+            new Transformer<ConnectionServiceRequestHandler, RequestHandler<ConnectionService>>() {
+                @Override
+                public RequestHandler<ConnectionService> transform(ConnectionServiceRequestHandler input) {
+                    return input;
+                }
+            };
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
index 2ca27d0..fd3cefb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
@@ -36,9 +36,23 @@ import java.util.TreeSet;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public final class GenericUtils {
-    public static final byte[]      EMPTY_BYTE_ARRAY={ };
-    public static final String[]    EMPTY_STRING_ARRAY={ };
-    public static final Object[]    EMPTY_OBJECT_ARRAY={ };
+    public static final byte[]   EMPTY_BYTE_ARRAY = { };
+    public static final String[] EMPTY_STRING_ARRAY = { };
+    public static final Object[] EMPTY_OBJECT_ARRAY = { };
+    
+    /**
+     * The complement of {@link String#CASE_INSENSITIVE_ORDER}
+     */
+    public static final Comparator<String> CASE_SENSITIVE_ORDER = new Comparator<String>() {
+            @Override
+            public int compare(String s1, String s2) {
+                if (s1 == s2) {
+                    return 0;
+                } else {
+                    return s1.compareTo(s2);
+                }
+            }
+        };
 
     private GenericUtils() {
         throw new UnsupportedOperationException("No instance");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/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 d8ea7b0..1bc8d1b 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
@@ -24,9 +24,12 @@ import java.util.List;
 
 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.kex.BuiltinDHFactories;
 import org.apache.sshd.common.kex.DHFactory;
 import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.util.Transformer;
 import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.config.keys.DefaultAuthorizedKeysAuthenticator;
@@ -74,16 +77,16 @@ public class ServerBuilder extends BaseBuilder<SshServer, ServerBuilder> {
             keyExchangeFactories = setUpDefaultKeyExchanges(false);
         }
         if (channelFactories == null) {
-            channelFactories = Arrays.asList(
+            channelFactories = Arrays.<NamedFactory<Channel>>asList(
                     ChannelSession.ChannelSessionFactory.INSTANCE,
                     TcpipServerChannel.DirectTcpipFactory.INSTANCE);
         }
         if (globalRequestHandlers == null) {
-            globalRequestHandlers = Arrays.asList(
-                    new KeepAliveHandler(),
-                    new NoMoreSessionsHandler(),
-                    new TcpipForwardHandler(),
-                    new CancelTcpipForwardHandler());
+            globalRequestHandlers = Arrays.<RequestHandler<ConnectionService>>asList(
+                    KeepAliveHandler.INSTANCE,
+                    NoMoreSessionsHandler.INSTANCE,
+                    TcpipForwardHandler.INSTANCE,
+                    CancelTcpipForwardHandler.INSTANCE);
         }
         if (factory == null) {
             factory = SshServer.DEFAULT_SSH_SERVER_FACTORY;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
index a86dce8..eef39e2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.sshd.common.Factory;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.server.auth.UserAuth;
 import org.apache.sshd.server.auth.gss.GSSAuthenticator;
 
 /**

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/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 3cd5b04..340770d 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
@@ -44,6 +44,7 @@ import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.OsUtils;
 import org.apache.sshd.common.util.SecurityUtils;
 import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.server.auth.UserAuth;
 import org.apache.sshd.server.auth.UserAuthKeyboardInteractive;
 import org.apache.sshd.server.auth.UserAuthPassword;
 import org.apache.sshd.server.auth.UserAuthPublicKey;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
deleted file mode 100644
index bb80288..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/server/UserAuth.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 org.apache.sshd.server;
-
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.server.session.ServerSession;
-
-/**
- * Server side authentication mechanism.
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public interface UserAuth {
-
-    /**
-     * Try to authenticate the user.
-     * This methods should return a non null object which is the user identity if
-     * the authentication succeeded.  If the authentication failed, this method should
-     * throw an exception.  If the authentication is still ongoing, a null value should
-     * be returned.
-     *
-     * @param session the current ssh session
-     * @param username the user trying to log in
-     * @param buffer the request buffer containing parameters specific to this request
-     * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
-     *          failed and <code>null</code> if not finished yet
-     * @throws Exception if the authentication fails
-     */
-    Boolean auth(ServerSession session, String username, String service, Buffer buffer) throws Exception;
-
-    /**
-     * Handle another step in the authentication process.
-     *
-     * @param buffer  the request buffer containing parameters specific to this request
-     * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
-     *          failed and <code>null</code> if not finished yet
-     * @throws Exception if the authentication fails
-     */
-    Boolean next(Buffer buffer) throws Exception;
-
-    /**
-     * Get a user name which has been derived from the handshaking process, or the initial name if
-     * nothing has been found.
-     *
-     * @return The user name
-     * @throws Exception if the request fails
-     */
-    String getUserName() throws Exception;
-
-    /**
-     * Free any system resources used by the module.
-     */
-    void destroy();
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
index c766310..83569d6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/AbstractUserAuth.java
@@ -20,7 +20,6 @@ package org.apache.sshd.server.auth;
 
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-import org.apache.sshd.server.UserAuth;
 import org.apache.sshd.server.session.ServerSession;
 
 /**

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
new file mode 100644
index 0000000..1eeec16
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuth.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.server.auth;
+
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.server.session.ServerSession;
+
+/**
+ * Server side authentication mechanism.
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuth {
+
+    /**
+     * Try to authenticate the user.
+     * This methods should return a non null object which is the user identity if
+     * the authentication succeeded.  If the authentication failed, this method should
+     * throw an exception.  If the authentication is still ongoing, a null value should
+     * be returned.
+     *
+     * @param session the current ssh session
+     * @param username the user trying to log in
+     * @param buffer the request buffer containing parameters specific to this request
+     * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
+     *          failed and <code>null</code> if not finished yet
+     * @throws Exception if the authentication fails
+     */
+    Boolean auth(ServerSession session, String username, String service, Buffer buffer) throws Exception;
+
+    /**
+     * Handle another step in the authentication process.
+     *
+     * @param buffer  the request buffer containing parameters specific to this request
+     * @return <code>true</code> if the authentication succeeded, <code>false</code> if the authentication
+     *          failed and <code>null</code> if not finished yet
+     * @throws Exception if the authentication fails
+     */
+    Boolean next(Buffer buffer) throws Exception;
+
+    /**
+     * Get a user name which has been derived from the handshaking process, or the initial name if
+     * nothing has been found.
+     *
+     * @return The user name
+     * @throws Exception if the request fails
+     */
+    String getUserName() throws Exception;
+
+    /**
+     * Free any system resources used by the module.
+     */
+    void destroy();
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
new file mode 100644
index 0000000..642c107
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.sshd.server.auth;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface UserAuthFactory extends NamedFactory<UserAuth> {
+    // required because of generics issues
+    Transformer<UserAuthFactory,NamedFactory<UserAuth>> FAC2NAMED=new Transformer<UserAuthFactory,NamedFactory<UserAuth>>() {
+        @Override
+        public NamedFactory<UserAuth> transform(UserAuthFactory input) {
+            return input;
+        }
+    };
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
index 867dda0..9740771 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
@@ -19,7 +19,6 @@
 package org.apache.sshd.server.auth;
 
 import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.util.GenericUtils;
@@ -27,7 +26,6 @@ import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.server.PasswordAuthenticator;
 import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
 import org.apache.sshd.server.session.ServerSession;
 
 /**
@@ -35,7 +33,7 @@ import org.apache.sshd.server.session.ServerSession;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class UserAuthKeyboardInteractive extends AbstractUserAuth {
-    public static class UserAuthKeyboardInteractiveFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthKeyboardInteractiveFactory implements UserAuthFactory {
         public static final UserAuthKeyboardInteractiveFactory INSTANCE = new UserAuthKeyboardInteractiveFactory();
 
         public UserAuthKeyboardInteractiveFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
index f25fd52..254f5fd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthNone.java
@@ -18,9 +18,7 @@
  */
 package org.apache.sshd.server.auth;
 
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.server.UserAuth;
 
 /**
  * TODO Add javadoc
@@ -29,7 +27,7 @@ import org.apache.sshd.server.UserAuth;
  */
 public class UserAuthNone extends AbstractUserAuth {
 
-    public static class UserAuthNoneFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthNoneFactory implements UserAuthFactory {
         public static final UserAuthNoneFactory INSTANCE = new UserAuthNoneFactory();
 
         public UserAuthNoneFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/84d41b58/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
index 9168b99..d0fa54e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPassword.java
@@ -18,13 +18,11 @@
  */
 package org.apache.sshd.server.auth;
 
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.server.PasswordAuthenticator;
 import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.UserAuth;
 import org.apache.sshd.server.session.ServerSession;
 
 /**
@@ -34,7 +32,7 @@ import org.apache.sshd.server.session.ServerSession;
  */
 public class UserAuthPassword extends AbstractUserAuth {
 
-    public static class UserAuthPasswordFactory implements NamedFactory<UserAuth> {
+    public static class UserAuthPasswordFactory implements UserAuthFactory {
         public static final UserAuthPasswordFactory INSTANCE = new UserAuthPasswordFactory();
         
         public UserAuthPasswordFactory() {