You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2014/01/30 15:50:58 UTC

[1/6] git commit: Simplify DefaultSshFuture to always notify lock

Updated Branches:
  refs/heads/master d749a675b -> d5b96d9fe


Simplify DefaultSshFuture to always notify lock

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

Branch: refs/heads/master
Commit: 7ea210bb5b4d5cc424e65e733bcee864a579d7d3
Parents: d749a67
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 10:56:17 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 10:56:17 2014 +0100

----------------------------------------------------------------------
 .../sshd/common/future/DefaultSshFuture.java    | 123 ++++---------------
 1 file changed, 23 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/7ea210bb/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
index 0f88223..479813f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
@@ -37,16 +37,12 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
     /** A default value to indicate the future has been canceled */
     private static final Object CANCELED = new Object();
 
-    /** A number of seconds to wait between two deadlock controls ( 5 seconds ) */
-    private static final long DEAD_LOCK_CHECK_INTERVAL = 5000L;
-
     /** A lock used by the wait() method */
     private final Object lock;
     private SshFutureListener<T> firstListener;
     private List<SshFutureListener<T>> otherListeners;
     private Object result;
     private boolean ready;
-    private int waiters;
 
     /**
      * Creates a new instance.
@@ -61,21 +57,10 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
     public T await() throws InterruptedException {
         synchronized (lock) {
             while (!ready) {
-                waiters++;
-                try {
-                    // Wait for a notify, or if no notify is called,
-                    // assume that we have a deadlock and exit the
-                    // loop to check for a potential deadlock.
-                    lock.wait(DEAD_LOCK_CHECK_INTERVAL);
-                } finally {
-                    waiters--;
-                    if (!ready) {
-                        checkDeadLock();
-                    }
-                }
+                lock.wait();
             }
         }
-        return (T) this;
+        return asT();
     }
 
     /**
@@ -102,7 +87,7 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
             // Do nothing : this catch is just mandatory by contract
         }
 
-        return (T) this;
+        return asT();
     }
 
     /**
@@ -141,36 +126,22 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
         long endTime = Long.MAX_VALUE - timeoutMillis < curTime ? Long.MAX_VALUE : curTime + timeoutMillis;
 
         synchronized (lock) {
-            if (ready) {
-                return ready;
-            } else if (timeoutMillis <= 0) {
+            if (ready || timeoutMillis <= 0) {
                 return ready;
             }
 
-            waiters++;
-            try {
-                for (;;) {
-                    try {
-                        long timeOut = Math.min(timeoutMillis, DEAD_LOCK_CHECK_INTERVAL);
-                        lock.wait(timeOut);
-                    } catch (InterruptedException e) {
-                        if (interruptable) {
-                            throw e;
-                        }
-                    }
-
-                    if (ready) {
-                        return true;
-                    } else {
-                        if (endTime < System.currentTimeMillis()) {
-                            return ready;
-                        }
+            for (;;) {
+                try {
+                    lock.wait(endTime - curTime);
+                } catch (InterruptedException e) {
+                    if (interruptable) {
+                        throw e;
                     }
                 }
-            } finally {
-                waiters--;
-                if (!ready) {
-                    checkDeadLock();
+
+                curTime = System.currentTimeMillis();
+                if (ready || curTime > endTime) {
+                    return ready;
                 }
             }
         }
@@ -178,56 +149,6 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
 
 
     /**
-     *
-     * TODO checkDeadLock.
-     *
-     */
-    private void checkDeadLock() {
-//        // Only read / write / connect / write future can cause dead lock.
-//        if (!(this instanceof CloseFuture || this instanceof WriteFuture ||
-//              this instanceof ReadFuture || this instanceof ConnectFuture)) {
-//            return;
-//        }
-//
-//        // Get the current thread stackTrace.
-//        // Using Thread.currentThread().getStackTrace() is the best solution,
-//        // even if slightly less efficient than doing a new Exception().getStackTrace(),
-//        // as internally, it does exactly the same thing. The advantage of using
-//        // this solution is that we may benefit some improvement with some
-//        // future versions of Java.
-//        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
-//
-//        // Simple and quick check.
-//        for (StackTraceElement s: stackTrace) {
-//            if (AbstractPollingIoProcessor.class.getName().equals(s.getClassName())) {
-//                IllegalStateException e = new IllegalStateException( "t" );
-//                e.getStackTrace();
-//                throw new IllegalStateException(
-//                    "DEAD LOCK: " + IoFuture.class.getSimpleName() +
-//                    ".await() was invoked from an I/O processor thread.  " +
-//                    "Please use " + IoFutureListener.class.getSimpleName() +
-//                    " or configure a proper thread model alternatively.");
-//            }
-//        }
-//
-//        // And then more precisely.
-//        for (StackTraceElement s: stackTrace) {
-//            try {
-//                Class<?> cls = DefaultSshFuture.class.getClassLoader().loadClass(s.getClassName());
-//                if (IoProcessor.class.isAssignableFrom(cls)) {
-//                    throw new IllegalStateException(
-//                        "DEAD LOCK: " + IoFuture.class.getSimpleName() +
-//                        ".await() was invoked from an I/O processor thread.  " +
-//                        "Please use " + IoFutureListener.class.getSimpleName() +
-//                        " or configure a proper thread model alternatively.");
-//                }
-//            } catch (Exception cnfe) {
-//                // Ignore
-//            }
-//        }
-    }
-
-    /**
      * {@inheritDoc}
      */
     public boolean isDone() {
@@ -248,9 +169,7 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
 
             result = newValue;
             ready = true;
-            if (waiters > 0) {
-                lock.notifyAll();
-            }
+            lock.notifyAll();
         }
 
         notifyListeners();
@@ -292,7 +211,7 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
         if (notifyNow) {
             notifyListener(listener);
         }
-        return (T) this;
+        return asT();
     }
 
     /**
@@ -317,7 +236,7 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
             }
         }
 
-        return (T) this;
+        return asT();
     }
 
     private void notifyListeners() {
@@ -337,10 +256,9 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
         }
     }
 
-    @SuppressWarnings("unchecked")
     private void notifyListener(SshFutureListener<T> l) {
         try {
-            l.operationComplete((T) this);
+            l.operationComplete(asT());
         } catch (Throwable t) {
             logger.warn("Listener threw an exception", t);
         }
@@ -353,4 +271,9 @@ public class DefaultSshFuture<T extends SshFuture> implements SshFuture<T> {
     public void cancel() {
         setValue(CANCELED);
     }
+
+    @SuppressWarnings("unchecked")
+    private T asT() {
+        return (T) this;
+    }
 }


[5/6] git commit: Improve SftpTest to work when run from the project root and not from sshd-core/ (usually the default case in IDE)

Posted by gn...@apache.org.
Improve SftpTest to work when run from the project root and not from sshd-core/ (usually the default case in IDE)

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

Branch: refs/heads/master
Commit: df2133c56c7d0ac12320538548f271bd9897bd99
Parents: 8ea1e86
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 15:49:43 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 15:49:43 2014 +0100

----------------------------------------------------------------------
 sshd-core/src/test/java/org/apache/sshd/SftpTest.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/df2133c5/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SftpTest.java b/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
index d166cc6..0d15d4e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
@@ -23,6 +23,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.URI;
+import java.net.URL;
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.Vector;
@@ -210,7 +212,12 @@ public class SftpTest {
     public void testReadDir() throws Exception {
         ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
         c.connect();
-        Vector res = c.ls("target/classes/org/apache/sshd/");
+
+        URI url = getClass().getClassLoader().getResource(SshClient.class.getName().replace('.', '/') + ".class").toURI();
+        URI base = new File(System.getProperty("user.dir")).getAbsoluteFile().toURI();
+        String path = new File(base.relativize(url).getPath()).getParent() + "/";
+//        String path = "target/classes/org/apache/sshd/";
+        Vector res = c.ls(path);
         for (Object f : res) {
             System.out.println(f.toString());
         }


[3/6] git commit: Fix typo s/negociate/negotiate Fix a few other minors stuff

Posted by gn...@apache.org.
Fix typo s/negociate/negotiate
Fix a few other minors stuff

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

Branch: refs/heads/master
Commit: f83185bfaced4ba2b4848d969ef2643b1839a394
Parents: c1a6b58
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 11:43:06 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 11:43:06 2014 +0100

----------------------------------------------------------------------
 .../org/apache/sshd/common/NamedFactory.java    |  2 +-
 .../org/apache/sshd/common/SshConstants.java    |  2 +-
 .../sshd/common/session/AbstractSession.java    | 64 ++++++++++----------
 .../sshd/server/auth/UserAuthPublicKey.java     |  1 -
 .../sshd/server/channel/ChannelSession.java     | 19 +++---
 .../sshd/server/kex/AbstractDHGServer.java      |  2 +-
 .../java/org/apache/sshd/server/kex/DHGEX.java  |  2 +-
 .../sshd/server/session/ServerSession.java      |  8 +--
 .../server/session/ServerUserAuthService.java   |  1 -
 9 files changed, 47 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/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 df7f77e..74ed284 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,7 @@ import java.util.List;
 
 /**
  * A named factory is a factory identified by a name.
- * Such names are used mainly in the algorithm negociation at the beginning of the SSH connection.
+ * Such names are used mainly in the algorithm negotiation at the beginning of the SSH connection.
  *
  * @param <T>
  *

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
index 1eda338..bb0cf45 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
@@ -75,7 +75,7 @@ public interface SshConstants {
     static final byte SSH_MSG_CHANNEL_FAILURE=               100;
 
     //
-    // Values for the algorithms negociation 
+    // Values for the algorithms negotiation
     //
 
     static final int PROPOSAL_KEX_ALGS = 0;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index 700b18e..efd5570 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -117,7 +117,7 @@ public abstract class AbstractSession implements Session {
     protected String clientVersion;
     protected String[] serverProposal;
     protected String[] clientProposal;
-    protected String[] negociated;
+    protected String[] negotiated;
     protected byte[] I_C; // the payload of the client's SSH_MSG_KEXINIT
     protected byte[] I_S; // the payload of the factoryManager's SSH_MSG_KEXINIT
     protected KeyExchange kex;
@@ -161,7 +161,6 @@ public abstract class AbstractSession implements Session {
         this.factoryManager = factoryManager;
         this.ioSession = ioSession;
         this.random = factoryManager.getRandomFactory().create();
-//        this.tcpipForwarder = factoryManager.getTcpipForwarderFactory().create(this);
     }
 
     /**
@@ -172,7 +171,7 @@ public abstract class AbstractSession implements Session {
      * @param ioSession the MINA session
      * @return the session attached to the MINA session
      */
-    public static final AbstractSession getSession(IoSession ioSession) {
+    public static AbstractSession getSession(IoSession ioSession) {
         return getSession(ioSession, false);
     }
 
@@ -187,7 +186,7 @@ public abstract class AbstractSession implements Session {
      *        returned if no session is attached
      * @return the session attached to the MINA session or <code>null</code>
      */
-    public static final AbstractSession getSession(IoSession ioSession, boolean allowNull) {
+    public static AbstractSession getSession(IoSession ioSession, boolean allowNull) {
         AbstractSession session = (AbstractSession) ioSession.getAttribute(SESSION);
         if (!allowNull && session == null) {
             throw new IllegalStateException("No session available");
@@ -201,7 +200,7 @@ public abstract class AbstractSession implements Session {
      * @param ioSession the MINA session
      * @param session the session to attach
      */
-    public static final void attachSession(IoSession ioSession, AbstractSession session) {
+    public static void attachSession(IoSession ioSession, AbstractSession session) {
         ioSession.setAttribute(SESSION, session);
     }
 
@@ -347,8 +346,8 @@ public abstract class AbstractSession implements Session {
                     throw new IllegalStateException("Received SSH_MSG_KEXINIT while key exchange is running");
                 }
                 kexState = KEX_STATE_RUN;
-                negociate();
-                kex = NamedFactory.Utils.create(factoryManager.getKeyExchangeFactories(), negociated[SshConstants.PROPOSAL_KEX_ALGS]);
+                negotiate();
+                kex = NamedFactory.Utils.create(factoryManager.getKeyExchangeFactories(), negotiated[SshConstants.PROPOSAL_KEX_ALGS]);
                 kex.init(this, serverVersion.getBytes(), clientVersion.getBytes(), I_S, I_C);
                 break;
             case SSH_MSG_NEWKEYS:
@@ -523,7 +522,6 @@ public abstract class AbstractSession implements Session {
             // they actually send exactly this amount.
             //
             int bsize = outCipherSize;
-            int oldLen = len;
             len += 5;
             int pad = (-len) & (bsize - 1);
             if (pad < bsize) {
@@ -777,7 +775,7 @@ public abstract class AbstractSession implements Session {
     }
 
     /**
-     * Create our proposal for SSH negociation
+     * Create our proposal for SSH negotiation
      *
      * @param hostKeyTypes the list of supported host key types
      * @return an array of 10 strings holding this proposal
@@ -801,9 +799,9 @@ public abstract class AbstractSession implements Session {
      * Send the key exchange initialization packet.
      * This packet contains random data along with our proposal.
      *
-     * @param proposal our proposal for key exchange negociation
+     * @param proposal our proposal for key exchange negotiation
      * @return the sent packet which must be kept for later use
-     * @throws IOException if an error occured sending the packet
+     * @throws IOException if an error occurred sending the packet
      */
     protected byte[] sendKexInit(String[] proposal) throws IOException {
         Buffer buffer = createBuffer(SshConstants.SSH_MSG_KEXINIT, 0);
@@ -865,8 +863,8 @@ public abstract class AbstractSession implements Session {
 
     /**
      * Put new keys into use.
-     * This method will intialize the ciphers, digests, macs and compression
-     * according to the negociated server and client proposals.
+     * This method will initialize the ciphers, digests, macs and compression
+     * according to the negotiated server and client proposals.
      *
      * @throws Exception if an error occurs
      */
@@ -924,24 +922,24 @@ public abstract class AbstractSession implements Session {
         hash.update(buf, 0, pos);
         MACs2c = hash.digest();
 
-        s2ccipher = NamedFactory.Utils.create(factoryManager.getCipherFactories(), negociated[SshConstants.PROPOSAL_ENC_ALGS_STOC]);
+        s2ccipher = NamedFactory.Utils.create(factoryManager.getCipherFactories(), negotiated[SshConstants.PROPOSAL_ENC_ALGS_STOC]);
         Es2c = resizeKey(Es2c, s2ccipher.getBlockSize(), hash, K, H);
         s2ccipher.init(isServer ? Cipher.Mode.Encrypt : Cipher.Mode.Decrypt, Es2c, IVs2c);
 
-        s2cmac = NamedFactory.Utils.create(factoryManager.getMacFactories(), negociated[SshConstants.PROPOSAL_MAC_ALGS_STOC]);
+        s2cmac = NamedFactory.Utils.create(factoryManager.getMacFactories(), negotiated[SshConstants.PROPOSAL_MAC_ALGS_STOC]);
         MACs2c = resizeKey(MACs2c, s2cmac.getBlockSize(), hash, K, H);
         s2cmac.init(MACs2c);
 
-        c2scipher = NamedFactory.Utils.create(factoryManager.getCipherFactories(), negociated[SshConstants.PROPOSAL_ENC_ALGS_CTOS]);
+        c2scipher = NamedFactory.Utils.create(factoryManager.getCipherFactories(), negotiated[SshConstants.PROPOSAL_ENC_ALGS_CTOS]);
         Ec2s = resizeKey(Ec2s, c2scipher.getBlockSize(), hash, K, H);
         c2scipher.init(isServer ? Cipher.Mode.Decrypt : Cipher.Mode.Encrypt, Ec2s, IVc2s);
 
-        c2smac = NamedFactory.Utils.create(factoryManager.getMacFactories(), negociated[SshConstants.PROPOSAL_MAC_ALGS_CTOS]);
+        c2smac = NamedFactory.Utils.create(factoryManager.getMacFactories(), negotiated[SshConstants.PROPOSAL_MAC_ALGS_CTOS]);
         MACc2s = resizeKey(MACc2s, c2smac.getBlockSize(), hash, K, H);
         c2smac.init(MACc2s);
 
-        s2ccomp = NamedFactory.Utils.create(factoryManager.getCompressionFactories(), negociated[SshConstants.PROPOSAL_COMP_ALGS_STOC]);
-        c2scomp = NamedFactory.Utils.create(factoryManager.getCompressionFactories(), negociated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]);
+        s2ccomp = NamedFactory.Utils.create(factoryManager.getCompressionFactories(), negotiated[SshConstants.PROPOSAL_COMP_ALGS_STOC]);
+        c2scomp = NamedFactory.Utils.create(factoryManager.getCompressionFactories(), negotiated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]);
 
         if (isServer) {
             outCipher = s2ccipher;
@@ -1020,10 +1018,10 @@ public abstract class AbstractSession implements Session {
 
     /**
      * Send an unimplemented packet.  This packet should contain the
-     * sequence id of the usupported packet: this number is assumed to
+     * sequence id of the unsupported packet: this number is assumed to
      * be the last packet received.
      *
-     * @throws IOException if an error occured sending the packet
+     * @throws IOException if an error occurred sending the packet
      */
     protected void notImplemented() throws IOException {
         Buffer buffer = createBuffer(SshConstants.SSH_MSG_UNIMPLEMENTED, 0);
@@ -1032,11 +1030,11 @@ public abstract class AbstractSession implements Session {
     }
 
     /**
-     * Compute the negociated proposals by merging the client and
-     * server proposal.  The negocatiated proposal will be stored in
-     * the {@link #negociated} property.
+     * Compute the negotiated proposals by merging the client and
+     * server proposal.  The negotiated proposal will be stored in
+     * the {@link #negotiated} property.
      */
-    protected void negociate() {
+    protected void negotiate() {
         String[] guess = new String[SshConstants.PROPOSAL_MAX];
         for (int i = 0; i < SshConstants.PROPOSAL_MAX; i++) {
             String[] c = clientProposal[i].split(",");
@@ -1063,19 +1061,19 @@ public abstract class AbstractSession implements Session {
                     "compression algorithms (client to server)",
                     "compression algorithms (server to client)"
                 };
-                throw new IllegalStateException("Unable to negociate key exchange for " + items[i] +
+                throw new IllegalStateException("Unable to negotiate key exchange for " + items[i] +
                         " (client: " + clientProposal[i] + " / server: " + serverProposal[i] + ")");
             }
         }
-        negociated = guess;
+        negotiated = guess;
         log.info("Kex: server->client {} {} {}",
-                new Object[] { negociated[SshConstants.PROPOSAL_ENC_ALGS_STOC],
-                               negociated[SshConstants.PROPOSAL_MAC_ALGS_STOC],
-                               negociated[SshConstants.PROPOSAL_COMP_ALGS_STOC]});
+                new Object[] { negotiated[SshConstants.PROPOSAL_ENC_ALGS_STOC],
+                               negotiated[SshConstants.PROPOSAL_MAC_ALGS_STOC],
+                               negotiated[SshConstants.PROPOSAL_COMP_ALGS_STOC]});
         log.info("Kex: client->server {} {} {}",
-                new Object[] { negociated[SshConstants.PROPOSAL_ENC_ALGS_CTOS],
-                               negociated[SshConstants.PROPOSAL_MAC_ALGS_CTOS],
-                               negociated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]});
+                new Object[] { negotiated[SshConstants.PROPOSAL_ENC_ALGS_CTOS],
+                               negotiated[SshConstants.PROPOSAL_MAC_ALGS_CTOS],
+                               negotiated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]});
     }
 
     protected void requestSuccess(Buffer buffer) throws Exception{

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/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 e6fd677..0e4de86 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.SshException;
 import org.apache.sshd.common.util.Buffer;
 import org.apache.sshd.server.PublickeyAuthenticator;
 import org.apache.sshd.server.UserAuth;
-import org.apache.sshd.server.session.ServerSession;
 
 /**
  * TODO Add javadoc

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/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 a3e9144..2f5d68b 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,7 +41,6 @@ import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.channel.ChannelOutputStream;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.DefaultCloseFuture;
-import org.apache.sshd.common.future.SshFuture;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.util.Buffer;
 import org.apache.sshd.common.util.IoUtils;
@@ -372,10 +371,10 @@ public class ChannelSession extends AbstractServerChannel {
     }
 
     protected boolean handleShell(Buffer buffer) throws IOException {
-        if (((ServerSession) session).getServerFactoryManager().getShellFactory() == null) {
+        if (((ServerSession) session).getFactoryManager().getShellFactory() == null) {
             return false;
         }
-        command = ((ServerSession) session).getServerFactoryManager().getShellFactory().create();
+        command = ((ServerSession) session).getFactoryManager().getShellFactory().create();
         prepareCommand();
         command.start(getEnvironment());
         return true;
@@ -383,7 +382,7 @@ public class ChannelSession extends AbstractServerChannel {
 
     protected boolean handleExec(Buffer buffer) throws IOException {
         String commandLine = buffer.getString();
-        if (((ServerSession) session).getServerFactoryManager().getCommandFactory() == null) {
+        if (((ServerSession) session).getFactoryManager().getCommandFactory() == null) {
             log.warn("Unsupported command: {}", commandLine);
             return false;
         }
@@ -391,7 +390,7 @@ public class ChannelSession extends AbstractServerChannel {
             log.info("Executing command: {}", commandLine);
         }
         try {
-            command = ((ServerSession) session).getServerFactoryManager().getCommandFactory().createCommand(commandLine);
+            command = ((ServerSession) session).getFactoryManager().getCommandFactory().createCommand(commandLine);
         } catch (IllegalArgumentException iae) {
             // TODO: Shouldn't we log errors on the server side?
             return false;
@@ -404,7 +403,7 @@ public class ChannelSession extends AbstractServerChannel {
 
     protected boolean handleSubsystem(Buffer buffer) throws IOException {
         String subsystem = buffer.getString();
-        List<NamedFactory<Command>> factories = ((ServerSession) session).getServerFactoryManager().getSubsystemFactories();
+        List<NamedFactory<Command>> factories = ((ServerSession) session).getFactoryManager().getSubsystemFactories();
         if (factories == null) {
             log.warn("Unsupported subsystem: {}", subsystem);
             return false;
@@ -443,7 +442,7 @@ public class ChannelSession extends AbstractServerChannel {
         }
         // If the shell wants to be aware of the file system, let's do that too
         if (command instanceof FileSystemAware) {
-            FileSystemFactory factory = ((ServerSession) session).getServerFactoryManager().getFileSystemFactory();
+            FileSystemFactory factory = ((ServerSession) session).getFactoryManager().getFileSystemFactory();
             ((FileSystemAware) command).setFileSystemView(factory.createFileSystemView(session));
         }
         out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
@@ -488,8 +487,8 @@ public class ChannelSession extends AbstractServerChannel {
 
     protected boolean handleAgentForwarding(Buffer buffer) throws IOException {
         final ServerSession server = (ServerSession) session;
-        final ForwardingFilter filter = server.getServerFactoryManager().getTcpipForwardingFilter();
-        final SshAgentFactory factory = server.getServerFactoryManager().getAgentFactory();
+        final ForwardingFilter filter = server.getFactoryManager().getTcpipForwardingFilter();
+        final SshAgentFactory factory = server.getFactoryManager().getAgentFactory();
         if (factory == null || (filter != null && !filter.canForwardAgent(server))) {
             return false;
         }
@@ -501,7 +500,7 @@ public class ChannelSession extends AbstractServerChannel {
 
     protected boolean handleX11Forwarding(Buffer buffer) throws IOException {
         final ServerSession server = (ServerSession) session;
-        final ForwardingFilter filter = server.getServerFactoryManager().getTcpipForwardingFilter();
+        final ForwardingFilter filter = server.getFactoryManager().getTcpipForwardingFilter();
         if (filter == null || !filter.canForwardX11(server)) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
index dd42317..e6a4023 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
@@ -86,7 +86,7 @@ public abstract class AbstractDHGServer implements KeyExchange {
 
         byte[] K_S;
         KeyPair kp = session.getHostKey();
-        String algo = session.getNegociated(SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS);
+        String algo = session.getNegotiated(SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS);
         Signature sig = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), algo);
         sig.init(kp.getPublic(), kp.getPrivate());
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
index 592ce75..3231655 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
@@ -133,7 +133,7 @@ public class DHGEX implements KeyExchange {
 
             byte[] K_S;
             KeyPair kp = session.getHostKey();
-            String algo = session.getNegociated(SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS);
+            String algo = session.getNegotiated(SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS);
             Signature sig = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), algo);
             sig.init(kp.getPublic(), kp.getPrivate());
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 0969335..4f10cdd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -21,12 +21,10 @@ package org.apache.sshd.server.session;
 import java.io.IOException;
 import java.security.KeyPair;
 
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.ServiceFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.session.AbstractSession;
 import org.apache.sshd.common.util.Buffer;
 import org.apache.sshd.server.ServerFactoryManager;
@@ -61,8 +59,8 @@ public class ServerSession extends AbstractSession {
         sendKexInit();
     }
 
-    public String getNegociated(int index) {
-        return negociated[index];
+    public String getNegotiated(int index) {
+        return negotiated[index];
     }
 
     public ServerFactoryManager getFactoryManager() {
@@ -137,7 +135,7 @@ public class ServerSession extends AbstractSession {
     }
 
     public KeyPair getHostKey() {
-        return factoryManager.getKeyPairProvider().loadKey(negociated[SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS]);
+        return factoryManager.getKeyPairProvider().loadKey(negotiated[SshConstants.PROPOSAL_SERVER_HOST_KEY_ALGS]);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f83185bf/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 cc173f8..49612e2 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
@@ -25,7 +25,6 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.sshd.SshServer;
-import org.apache.sshd.client.session.ClientSessionImpl;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.Service;
 import org.apache.sshd.common.ServiceFactory;


[2/6] git commit: [SSHD-286] Rename getClientFactoryManager/getServerFactoryManager to getFactoryManager with return type override.

Posted by gn...@apache.org.
[SSHD-286] Rename getClientFactoryManager/getServerFactoryManager to getFactoryManager with return type override.


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

Branch: refs/heads/master
Commit: c1a6b588ea29e6a208c8c3d8991ebf777a5fe9ad
Parents: 7ea210b
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 11:41:28 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 11:41:28 2014 +0100

----------------------------------------------------------------------
 sshd-core/src/main/java/org/apache/sshd/ClientSession.java       | 2 +-
 .../org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java | 2 +-
 .../java/org/apache/sshd/client/session/ClientSessionImpl.java   | 4 ++--
 .../org/apache/sshd/client/session/ClientUserAuthService.java    | 2 +-
 .../org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java | 2 +-
 .../main/java/org/apache/sshd/server/auth/UserAuthPassword.java  | 2 +-
 .../main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java | 2 +-
 .../main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java   | 2 +-
 .../main/java/org/apache/sshd/server/session/ServerSession.java  | 2 +-
 .../org/apache/sshd/server/session/ServerUserAuthService.java    | 2 +-
 10 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/sshd-core/src/main/java/org/apache/sshd/ClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/ClientSession.java
index 26fd46b..96068cb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/ClientSession.java
@@ -175,6 +175,6 @@ public interface ClientSession extends Session {
     /**
      * Return ClientFactoryManager for this session.
      */
-    ClientFactoryManager getClientFactoryManager();
+    ClientFactoryManager getFactoryManager();
 
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 36cd4bb..374ac36 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
@@ -78,7 +78,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
                     } else if (num == 1 && password != null && !echo[0] && prompt[0].toLowerCase().startsWith("password:")) {
                         rep = new String[] { password };
                     } else {
-                        UserInteraction ui = session.getClientFactoryManager().getUserInteraction();
+                        UserInteraction ui = session.getFactoryManager().getUserInteraction();
                         if (ui != null) {
                             String dest = username + "@" + session.getIoSession().getRemoteAddress().toString();
                             rep = ui.interactive(dest, name, instruction, prompt, echo);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 6da6c0c..720ce4b 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
@@ -101,7 +101,7 @@ public class ClientSessionImpl extends AbstractSession implements ClientSession
         sendKexInit();
     }
 
-    public ClientFactoryManager getClientFactoryManager() {
+    public ClientFactoryManager getFactoryManager() {
         return (ClientFactoryManager) factoryManager;
     }
 
@@ -301,7 +301,7 @@ public class ClientSessionImpl extends AbstractSession implements ClientSession
 
     @Override
     protected void checkKeys() throws SshException {
-        ServerKeyVerifier serverKeyVerifier = getClientFactoryManager().getServerKeyVerifier();
+        ServerKeyVerifier serverKeyVerifier = getFactoryManager().getServerKeyVerifier();
         SocketAddress remoteAddress = ioSession.getRemoteAddress();
 
         if (!serverKeyVerifier.verifyServerKey(this, remoteAddress, kex.getServerKey())) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 d98c510..9612b9b 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
@@ -102,7 +102,7 @@ public class ClientUserAuthService implements Service {
             String welcome = buffer.getString();
             String lang = buffer.getString();
             log.debug("Welcome banner: {}", welcome);
-            UserInteraction ui = session.getClientFactoryManager().getUserInteraction();
+            UserInteraction ui = session.getFactoryManager().getUserInteraction();
             if (ui != null) {
                 ui.welcome(welcome);
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 989d4a6..94cfdba 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
@@ -73,7 +73,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
     }
 
     private boolean checkPassword(ServerSession session, String username, String password) throws Exception {
-        PasswordAuthenticator auth = session.getServerFactoryManager().getPasswordAuthenticator();
+        PasswordAuthenticator auth = session.getFactoryManager().getPasswordAuthenticator();
         if (auth != null) {
             return auth.authenticate(username, password, session);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 8db22b8..50754ac 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
@@ -58,7 +58,7 @@ public class UserAuthPassword extends AbstractUserAuth {
     }
 
     private boolean checkPassword(ServerSession session, String username, String password) throws Exception {
-        PasswordAuthenticator auth = session.getServerFactoryManager().getPasswordAuthenticator();
+        PasswordAuthenticator auth = session.getFactoryManager().getPasswordAuthenticator();
         if (auth != null) {
             return auth.authenticate(username, password, session);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 e71957c..e6fd677 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
@@ -70,7 +70,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
 
         byte[] sig = hasSig ? buffer.getBytes() : null;
 
-        PublickeyAuthenticator authenticator = session.getServerFactoryManager().getPublickeyAuthenticator();
+        PublickeyAuthenticator authenticator = session.getFactoryManager().getPublickeyAuthenticator();
         if (authenticator == null) {
             throw new Exception("No PublickeyAuthenticator configured");
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 ca6bb41..abb73d1 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
@@ -207,7 +207,7 @@ public class UserAuthGSS extends AbstractUserAuth {
      * @throws Exception If no GSS authenticator is defined
      */
     private GSSAuthenticator getAuthenticator(ServerSession session) throws Exception {
-        GSSAuthenticator ga = session.getServerFactoryManager().getGSSAuthenticator();
+        GSSAuthenticator ga = session.getFactoryManager().getGSSAuthenticator();
 
         if (ga == null) {
             throw new Exception("No GSSAuthenticator configured");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 30c8311..0969335 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -65,7 +65,7 @@ public class ServerSession extends AbstractSession {
         return negociated[index];
     }
 
-    public ServerFactoryManager getServerFactoryManager() {
+    public ServerFactoryManager getFactoryManager() {
         return (ServerFactoryManager) factoryManager;
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c1a6b588/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 5ad87ad..cc173f8 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
@@ -255,7 +255,7 @@ public class ServerUserAuthService implements Service {
     }
 
     private ServerFactoryManager getFactoryManager() {
-        return session.getServerFactoryManager();
+        return session.getFactoryManager();
     }
 
 }


[6/6] git commit: [SSHD-285] Automatic key re-rexchange from server

Posted by gn...@apache.org.
[SSHD-285] Automatic key re-rexchange from server

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

Branch: refs/heads/master
Commit: d5b96d9fe6703ba43eedaf288eac6f5bf8c7e63c
Parents: df2133c
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 15:50:46 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 15:50:46 2014 +0100

----------------------------------------------------------------------
 .../sshd/common/session/AbstractSession.java    | 156 ++++++++++++++++---
 .../sshd/server/ServerFactoryManager.java       |  14 ++
 .../sshd/server/session/ServerSession.java      |  21 ++-
 .../java/org/apache/sshd/KeyReExchangeTest.java |  98 +++++++++---
 4 files changed, 248 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d5b96d9f/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index efd5570..cc050e2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -21,8 +21,10 @@ package org.apache.sshd.common.session;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
@@ -148,6 +150,16 @@ public abstract class AbstractSession implements Session {
     protected final AtomicReference<Buffer> requestResult = new AtomicReference<Buffer>();
     protected final Map<AttributeKey<?>, Object> attributes = new ConcurrentHashMap<AttributeKey<?>, Object>();
 
+    //
+    // Rekeying
+    //
+    protected long inPackets;
+    protected long outPackets;
+    protected long inBytes;
+    protected long outBytes;
+    protected long lastKeyTime;
+    protected final Queue<PendingWriteFuture> pendingPackets = new LinkedList<PendingWriteFuture>();
+
     protected Service currentService;
 
     /**
@@ -288,6 +300,12 @@ public abstract class AbstractSession implements Session {
      * @throws Exception if an exeption occurs while handling this packet.
      */
     protected void handleMessage(Buffer buffer) throws Exception {
+        synchronized (lock) {
+            doHandleMessage(buffer);
+        }
+    }
+
+    protected void doHandleMessage(Buffer buffer) throws Exception {
         byte cmd = buffer.getByte();
         switch (cmd) {
             case SSH_MSG_DISCONNECT: {
@@ -361,6 +379,12 @@ public abstract class AbstractSession implements Session {
                     reexchangeFuture.setValue(true);
                 }
                 sendEvent(SessionListener.Event.KeyEstablished);
+                synchronized (pendingPackets) {
+                    PendingWriteFuture future;
+                    while ((future = pendingPackets.poll()) != null) {
+                        doWritePacket(future.getBuffer()).addListener(future);
+                    }
+                }
                 break;
             default:
                 if (cmd >= SshConstants.SSH_MSG_KEX_FIRST && cmd <= SshConstants.SSH_MSG_KEX_LAST) {
@@ -381,6 +405,7 @@ public abstract class AbstractSession implements Session {
                 }
                 break;
         }
+        checkRekey();
     }
 
     /**
@@ -468,16 +493,35 @@ public abstract class AbstractSession implements Session {
      * @throws java.io.IOException if an error occured when encoding sending the packet
      */
     public IoWriteFuture writePacket(Buffer buffer) throws IOException {
-        try {
-            // Synchronize all write requests as needed by the encoding algorithm
-            // and also queue the write request in this synchronized block to ensure
-            // packets are sent in the correct order
-            synchronized (encodeLock) {
-                encode(buffer);
-                return ioSession.write(buffer);
+        // While exchanging key, queue high level packets
+        if (kexState != KEX_STATE_DONE) {
+            byte cmd = buffer.array()[buffer.rpos()];
+            if (cmd > SshConstants.SSH_MSG_KEX_LAST) {
+                synchronized (pendingPackets) {
+                    if (kexState != KEX_STATE_DONE) {
+                        log.info("Flag packet {} as pending until key exchange is done", cmd);
+                        PendingWriteFuture future = new PendingWriteFuture(buffer);
+                        pendingPackets.add(future);
+                        return future;
+                    }
+                }
             }
+        }
+        try {
+            return doWritePacket(buffer);
         } finally {
             resetIdleTimeout();
+            checkRekey();
+        }
+    }
+
+    protected IoWriteFuture doWritePacket(Buffer buffer) throws IOException {
+        // Synchronize all write requests as needed by the encoding algorithm
+        // and also queue the write request in this synchronized block to ensure
+        // packets are sent in the correct order
+        synchronized (encodeLock) {
+            encode(buffer);
+            return ioSession.write(buffer);
         }
     }
 
@@ -600,6 +644,9 @@ public abstract class AbstractSession implements Session {
             }
             // Increment packet id
             seqo = (seqo + 1) & 0xffffffffL;
+            // Update stats
+            outPackets ++;
+            outBytes += len;
             // Make buffer ready to be read
             buffer.rpos(off);
         } catch (SshException e) {
@@ -689,6 +736,9 @@ public abstract class AbstractSession implements Session {
                     if (log.isTraceEnabled()) {
                         log.trace("Received packet #{}: {}", seqi, buf.printHex());
                     }
+                    // Update stats
+                    inPackets ++;
+                    inBytes += buf.available();
                     // Process decoded packet
                     handleMessage(buf);
                     // Set ready to handle next packet
@@ -965,6 +1015,11 @@ public abstract class AbstractSession implements Session {
         if (inCompression != null) {
             inCompression.init(Compression.Type.Inflater, -1);
         }
+        inBytes = 0;
+        outBytes = 0;
+        inPackets = 0;
+        outPackets = 0;
+        lastKeyTime = System.currentTimeMillis();
     }
 
     /**
@@ -1067,13 +1122,13 @@ public abstract class AbstractSession implements Session {
         }
         negotiated = guess;
         log.info("Kex: server->client {} {} {}",
-                new Object[] { negotiated[SshConstants.PROPOSAL_ENC_ALGS_STOC],
-                               negotiated[SshConstants.PROPOSAL_MAC_ALGS_STOC],
-                               negotiated[SshConstants.PROPOSAL_COMP_ALGS_STOC]});
+                new Object[]{negotiated[SshConstants.PROPOSAL_ENC_ALGS_STOC],
+                        negotiated[SshConstants.PROPOSAL_MAC_ALGS_STOC],
+                        negotiated[SshConstants.PROPOSAL_COMP_ALGS_STOC]});
         log.info("Kex: client->server {} {} {}",
-                new Object[] { negotiated[SshConstants.PROPOSAL_ENC_ALGS_CTOS],
-                               negotiated[SshConstants.PROPOSAL_MAC_ALGS_CTOS],
-                               negotiated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]});
+                new Object[]{negotiated[SshConstants.PROPOSAL_ENC_ALGS_CTOS],
+                        negotiated[SshConstants.PROPOSAL_MAC_ALGS_CTOS],
+                        negotiated[SshConstants.PROPOSAL_COMP_ALGS_CTOS]});
     }
 
     protected void requestSuccess(Buffer buffer) throws Exception{
@@ -1109,6 +1164,18 @@ public abstract class AbstractSession implements Session {
         return defaultValue;
     }
 
+    public long getLongProperty(String name, long defaultValue) {
+        try {
+            String v = factoryManager.getProperties().get(name);
+            if (v != null) {
+                return Long.parseLong(v);
+            }
+        } catch (Exception e) {
+            // Ignore
+        }
+        return defaultValue;
+    }
+
     /**
      * Returns the value of the user-defined attribute of this session.
      *
@@ -1168,13 +1235,18 @@ public abstract class AbstractSession implements Session {
      * {@inheritDoc}
      */
     public SshFuture reExchangeKeys() throws IOException {
-        if (kexState != KEX_STATE_DONE) {
-            throw new IllegalStateException("Can not perform key re-exchange while key exchange is already running");
+        synchronized (lock) {
+            if (kexState == KEX_STATE_DONE) {
+                log.info("Initiating key re-exchange");
+                kexState = KEX_STATE_INIT;
+                sendKexInit();
+                reexchangeFuture = new DefaultSshFuture(null);
+            }
+            return reexchangeFuture;
         }
-        kexState = KEX_STATE_INIT;
-        sendKexInit();
-        reexchangeFuture = new DefaultSshFuture(null);
-        return reexchangeFuture;
+    }
+
+    protected void checkRekey() throws IOException {
     }
 
     protected abstract void sendKexInit() throws IOException;
@@ -1190,4 +1262,50 @@ public abstract class AbstractSession implements Session {
 
     public abstract void resetIdleTimeout();
 
+    /**
+     * Future holding a packet pending key exchange termination.
+     */
+    protected static class PendingWriteFuture extends DefaultSshFuture<IoWriteFuture>
+            implements IoWriteFuture, SshFutureListener<IoWriteFuture> {
+
+        private final Buffer buffer;
+
+        protected PendingWriteFuture(Buffer buffer) {
+            super(null);
+            this.buffer = buffer;
+        }
+
+        public Buffer getBuffer() {
+            return buffer;
+        }
+
+        public boolean isWritten() {
+            return getValue() instanceof Boolean;
+        }
+
+        public Throwable getException() {
+            Object v = getValue();
+            return v instanceof Throwable ? (Throwable) v : null;
+        }
+
+        public void setWritten() {
+            setValue(Boolean.TRUE);
+        }
+
+        public void setException(Throwable cause) {
+            if (cause == null) {
+                throw new IllegalArgumentException();
+            }
+            setValue(cause);
+        }
+
+        public void operationComplete(IoWriteFuture future) {
+            if (future.isWritten()) {
+                setWritten();
+            } else {
+                future.setException(future.getException());
+            }
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d5b96d9f/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 49bac66..2f6a1e3 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
@@ -88,6 +88,20 @@ public interface ServerFactoryManager extends FactoryManager {
     public static final String COMMAND_EXIT_TIMEOUT = "command-exit-timeout";
 
     /**
+     * Key re-exchange will be automatically performed after the session
+     * has sent or received the given amount of bytes.
+     * The default value is 1 gigabyte.
+     */
+    public static final String REKEY_BYTES_LIMIT = "rekey-bytes-limit";
+
+    /**
+     * Key re-exchange will be automatically performed after the specified
+     * amount of time has elapsed since the last key exchange. In milliseconds.
+     * The default value is 1 hour.
+     */
+    public static final String REKEY_TIME_LIMIT = "rekey-time-limit";
+
+    /**
      * Retrieve the list of named factories for <code>UserAuth<code> objects.
      *
      * @return a list of named <code>UserAuth</code> factories, never <code>null</code>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d5b96d9f/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 4f10cdd..b92eea0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -43,16 +43,23 @@ import org.apache.sshd.server.ServerFactoryManager;
  */
 public class ServerSession extends AbstractSession {
 
+    protected static final long MAX_PACKETS = (1l << 31);
+
     private long authTimeoutTimestamp;
     private long idleTimeoutTimestamp = 0L;
-    private int authTimeoutMs = 2 * 60 * 1000; // 2 minutes in milliseconds
-    private int idleTimeoutMs = 10 * 60 * 1000; // 10 minutes in milliseconds
+    private int authTimeoutMs = 2 * 60 * 1000;    // 2 minutes in milliseconds
+    private int idleTimeoutMs = 10 * 60 * 1000;   // 10 minutes in milliseconds
+    private long maxBytes = 1024 * 1024;          // 1 GB
+    private long maxKeyInterval = 60 * 60 * 1000; // 1 hour
+
 
     public ServerSession(ServerFactoryManager server, IoSession ioSession) throws Exception {
         super(true, server, ioSession);
         authTimeoutMs = getIntProperty(ServerFactoryManager.AUTH_TIMEOUT, authTimeoutMs);
         authTimeoutTimestamp = System.currentTimeMillis() + authTimeoutMs;
         idleTimeoutMs = getIntProperty(ServerFactoryManager.IDLE_TIMEOUT, idleTimeoutMs);
+        maxBytes = Math.max(32, getLongProperty(ServerFactoryManager.REKEY_BYTES_LIMIT, maxBytes));
+        maxKeyInterval = getLongProperty(ServerFactoryManager.REKEY_TIME_LIMIT, maxKeyInterval);
         log.info("Session created from {}", ioSession.getRemoteAddress());
         sendServerIdentification();
         kexState = KEX_STATE_INIT;
@@ -98,6 +105,16 @@ public class ServerSession extends AbstractSession {
         }
     }
 
+    protected void checkRekey() throws IOException {
+        if (kexState == KEX_STATE_DONE) {
+            if (   inPackets > MAX_PACKETS || outPackets > MAX_PACKETS
+                || inBytes > maxBytes || outBytes > maxBytes
+                || maxKeyInterval > 0 && System.currentTimeMillis() - lastKeyTime > maxKeyInterval)
+            {
+                reExchangeKeys();
+            }
+        }
+    }
     public void resetIdleTimeout() {
         this.idleTimeoutTimestamp = System.currentTimeMillis() + idleTimeoutMs;
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d5b96d9f/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
index e6b1c54..b4170fa 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
@@ -23,20 +23,13 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
-import java.util.Collections;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import com.jcraft.jsch.JSch;
 import org.apache.sshd.client.channel.ChannelShell;
-import org.apache.sshd.client.kex.DHG1;
-import org.apache.sshd.client.kex.DHG14;
-import org.apache.sshd.client.kex.DHGEX;
-import org.apache.sshd.client.kex.DHGEX256;
-import org.apache.sshd.client.kex.ECDHP256;
-import org.apache.sshd.client.kex.ECDHP384;
-import org.apache.sshd.client.kex.ECDHP521;
-import org.apache.sshd.common.KeyExchange;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.Session;
+import org.apache.sshd.common.SessionListener;
+import org.apache.sshd.server.ServerFactoryManager;
 import org.apache.sshd.util.BogusPasswordAuthenticator;
 import org.apache.sshd.util.EchoShellFactory;
 import org.apache.sshd.util.JSchLogger;
@@ -44,7 +37,6 @@ import org.apache.sshd.util.SimpleUserInfo;
 import org.apache.sshd.util.TeeOutputStream;
 import org.apache.sshd.util.Utils;
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertArrayEquals;
@@ -61,11 +53,21 @@ public class KeyReExchangeTest {
     private SshServer sshd;
     private int port;
 
-    @Before
-    public void setUp() throws Exception {
+    @After
+    public void tearDown() throws Exception {
+        sshd.stop();
+    }
+
+    protected void setUp(long bytesLimit, long timeLimit) throws Exception {
         port = Utils.getFreePort();
 
         sshd = SshServer.setUpDefaultServer();
+        if (bytesLimit > 0) {
+            sshd.getProperties().put(ServerFactoryManager.REKEY_BYTES_LIMIT, Long.toString(bytesLimit));
+        }
+        if (timeLimit > 0) {
+            sshd.getProperties().put(ServerFactoryManager.REKEY_TIME_LIMIT, Long.toString(timeLimit));
+        }
         sshd.setPort(port);
         sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
         sshd.setShellFactory(new EchoShellFactory());
@@ -73,13 +75,10 @@ public class KeyReExchangeTest {
         sshd.start();
     }
 
-    @After
-    public void tearDown() throws Exception {
-        sshd.stop();
-    }
-
     @Test
     public void testReExchangeFromClient() throws Exception {
+        setUp(0, 0);
+
         JSchLogger.init();
         JSch.setConfig("kex", "diffie-hellman-group-exchange-sha1");
         JSch sch = new JSch();
@@ -105,6 +104,8 @@ public class KeyReExchangeTest {
 
     @Test
     public void testReExchangeFromNativeClient() throws Exception {
+        setUp(0, 0);
+
         SshClient client = SshClient.setUpDefaultClient();
         client.start();
         ClientSession session = client.connect("localhost", port).await().getSession();
@@ -133,7 +134,63 @@ public class KeyReExchangeTest {
         for (int i = 0; i < 10; i++) {
             teeOut.write(sb.toString().getBytes());
             teeOut.flush();
-            session.reExchangeKeys().await();
+            session.reExchangeKeys();
+        }
+        teeOut.write("exit\n".getBytes());
+        teeOut.flush();
+
+        channel.waitFor(ClientChannel.CLOSED, 0);
+
+        channel.close(false);
+        client.stop();
+
+        assertArrayEquals(sent.toByteArray(), out.toByteArray());
+    }
+
+    @Test
+    public void testReExchangeFromServer() throws Exception {
+        setUp(8192, 0);
+
+        SshClient client = SshClient.setUpDefaultClient();
+        client.start();
+        ClientSession session = client.connect("localhost", port).await().getSession();
+        session.authPassword("smx", "smx").await();
+        ChannelShell channel = session.createShellChannel();
+
+        ByteArrayOutputStream sent = new ByteArrayOutputStream();
+        PipedOutputStream pipedIn = new PipedOutputStream();
+        channel.setIn(new PipedInputStream(pipedIn));
+        OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ByteArrayOutputStream err = new ByteArrayOutputStream();
+        channel.setOut(out);
+        channel.setErr(err);
+        channel.open();
+
+        teeOut.write("this is my command\n".getBytes());
+        teeOut.flush();
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < 100; i++) {
+            sb.append("0123456789");
+        }
+        sb.append("\n");
+
+        final AtomicInteger exchanges = new AtomicInteger();
+        session.addListener(new SessionListener() {
+            public void sessionCreated(Session session) {
+            }
+            public void sessionEvent(Session sesssion, Event event) {
+                if (event == Event.KeyEstablished) {
+                    exchanges.incrementAndGet();
+                }
+            }
+            public void sessionClosed(Session session) {
+            }
+        });
+        for (int i = 0; i < 100; i++) {
+            teeOut.write(sb.toString().getBytes());
+            teeOut.flush();
         }
         teeOut.write("exit\n".getBytes());
         teeOut.flush();
@@ -143,6 +200,7 @@ public class KeyReExchangeTest {
         channel.close(false);
         client.stop();
 
+        assertTrue("Expected rekeying", exchanges.get() > 0);
         assertArrayEquals(sent.toByteArray(), out.toByteArray());
     }
 }


[4/6] git commit: Tone down logging for received packets to debug

Posted by gn...@apache.org.
Tone down logging for received packets to debug

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

Branch: refs/heads/master
Commit: 8ea1e86a4ddb3934ef832297e5641d6f069bd97e
Parents: f83185b
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 15:48:59 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 15:48:59 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/sshd/client/kex/AbstractDHGClient.java   | 4 ++--
 .../src/main/java/org/apache/sshd/client/kex/DHGEX.java      | 8 ++++----
 .../src/main/java/org/apache/sshd/server/kex/DHGEX.java      | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/8ea1e86a/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
index f93bd83..872821b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
@@ -77,7 +77,7 @@ public abstract class AbstractDHGClient implements KeyExchange {
         hash.init();
         e = dh.getE();
 
-        log.info("Send SSH_MSG_KEXDH_INIT");
+        log.debug("Send SSH_MSG_KEXDH_INIT");
         Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEXDH_INIT, 0);
         buffer.putMPInt(e);
         session.writePacket(buffer);
@@ -92,7 +92,7 @@ public abstract class AbstractDHGClient implements KeyExchange {
                                    "Protocol error: expected packet SSH_MSG_KEXDH_REPLY, got " + cmd);
         }
 
-        log.info("Received SSH_MSG_KEXDH_REPLY");
+        log.debug("Received SSH_MSG_KEXDH_REPLY");
         
         byte[] K_S = buffer.getBytes();
         f = buffer.getMPIntAsBytes();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/8ea1e86a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
index 4eb033a..71e56c2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
@@ -94,7 +94,7 @@ public class DHGEX implements KeyExchange {
         this.I_S = I_S;
         this.I_C = I_C;
 
-        log.info("Send SSH_MSG_KEX_DH_GEX_REQUEST");
+        log.debug("Send SSH_MSG_KEX_DH_GEX_REQUEST");
         Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST, 0);
         buffer.putInt(min);
         buffer.putInt(prf);
@@ -112,7 +112,7 @@ public class DHGEX implements KeyExchange {
         }
 
         if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_GROUP) {
-            log.info("Received SSH_MSG_KEX_DH_GEX_GROUP");
+            log.debug("Received SSH_MSG_KEX_DH_GEX_GROUP");
             p = buffer.getMPIntAsBytes();
             g = buffer.getMPIntAsBytes();
 
@@ -121,7 +121,7 @@ public class DHGEX implements KeyExchange {
             hash.init();
             e = dh.getE();
 
-            log.info("Send SSH_MSG_KEX_DH_GEX_INIT");
+            log.debug("Send SSH_MSG_KEX_DH_GEX_INIT");
             buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_INIT, 0);
             buffer.putMPInt(e);
             session.writePacket(buffer);
@@ -130,7 +130,7 @@ public class DHGEX implements KeyExchange {
         }
 
         if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_REPLY) {
-            log.info("Received SSH_MSG_KEX_DH_GEX_REPLY");
+            log.debug("Received SSH_MSG_KEX_DH_GEX_REPLY");
             byte[] K_S = buffer.getBytes();
             f = buffer.getMPIntAsBytes();
             byte[] sig = buffer.getBytes();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/8ea1e86a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
index 3231655..900366b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
@@ -101,7 +101,7 @@ public class DHGEX implements KeyExchange {
         }
 
         if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST) {
-            log.info("Received SSH_MSG_KEX_DH_GEX_REQUEST");
+            log.debug("Received SSH_MSG_KEX_DH_GEX_REQUEST");
             min = buffer.getInt();
             prf = buffer.getInt();
             max = buffer.getInt();
@@ -114,7 +114,7 @@ public class DHGEX implements KeyExchange {
             hash = dh.getHash();
             hash.init();
 
-            log.info("Send SSH_MSG_KEX_DH_GEX_GROUP");
+            log.debug("Send SSH_MSG_KEX_DH_GEX_GROUP");
             buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_GROUP, 0);
             buffer.putMPInt(dh.getP());
             buffer.putMPInt(dh.getG());
@@ -125,7 +125,7 @@ public class DHGEX implements KeyExchange {
         }
 
         if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_INIT) {
-            log.info("Received SSH_MSG_KEX_DH_GEX_INIT");
+            log.debug("Received SSH_MSG_KEX_DH_GEX_INIT");
             e = buffer.getMPIntAsBytes();
             dh.setF(e);
             K = dh.getK();