http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/random/JceRandomFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/random/JceRandomFactory.java 
b/sshd-core/src/main/java/org/apache/sshd/common/random/JceRandomFactory.java
index 1350814..855ef80 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/random/JceRandomFactory.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/random/JceRandomFactory.java
@@ -25,7 +25,7 @@ package org.apache.sshd.common.random;
 public class JceRandomFactory implements RandomFactory {
     public static final JceRandomFactory INSTANCE = new JceRandomFactory();
 
-    public JceRandomFactory () {
+    public JceRandomFactory() {
         super();
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/random/Random.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/random/Random.java 
b/sshd-core/src/main/java/org/apache/sshd/common/random/Random.java
index 1729001..b4b4d7f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/random/Random.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/random/Random.java
@@ -26,6 +26,7 @@ package org.apache.sshd.common.random;
 public interface Random {
     /**
      * Fill the buffer with random values
+     *
      * @param bytes The bytes to fill
      * @see #fill(byte[], int, int)
      */
@@ -33,9 +34,10 @@ public interface Random {
 
     /**
      * Fill part of bytes with random values.
+     *
      * @param bytes byte array to be filled.
      * @param start index to start filling at.
-     * @param len length of segment to fill.
+     * @param len   length of segment to fill.
      */
     void fill(byte[] bytes, int start, int len);
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/random/RandomFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/random/RandomFactory.java 
b/sshd-core/src/main/java/org/apache/sshd/common/random/RandomFactory.java
index 78d348c..309fe2d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/random/RandomFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/random/RandomFactory.java
@@ -19,19 +19,12 @@
 
 package org.apache.sshd.common.random;
 
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.OptionalFeature;
-import org.apache.sshd.common.util.Transformer;
+import org.apache.sshd.common.BuiltinFactory;
 
 /**
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
-public interface RandomFactory extends NamedFactory<Random>, OptionalFeature {
-    // required because of generics issues
-    Transformer<RandomFactory,NamedFactory<Random>> FAC2NAMED=new 
Transformer<RandomFactory,NamedFactory<Random>>() {
-        @Override
-        public NamedFactory<Random> transform(RandomFactory input) {
-            return input;
-        }
-    };
+// CHECKSTYLE:OFF
+public interface RandomFactory extends BuiltinFactory<Random> {
+
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpSourceStreamResolver.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpSourceStreamResolver.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpSourceStreamResolver.java
index 7e1f21f..3e68747 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpSourceStreamResolver.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpSourceStreamResolver.java
@@ -29,7 +29,6 @@ import java.nio.file.attribute.PosixFilePermission;
 import java.util.Collection;
 import java.util.Set;
 
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.io.IoUtils;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -38,7 +37,8 @@ import 
org.apache.sshd.common.util.logging.AbstractLoggingBean;
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
 public class LocalFileScpSourceStreamResolver extends AbstractLoggingBean 
implements ScpSourceStreamResolver {
-    private final Path path, name;
+    private final Path path;
+    private final Path name;
     private final Set<PosixFilePermission> perms;
     private final long size;
     private final ScpTimestamp time;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
index 3accdb4..2ca6aab 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
@@ -68,7 +68,7 @@ public class LocalFileScpTargetStreamResolver extends 
AbstractLoggingBean implem
             file = path;
         } else if (!status) {
             Path parent = path.getParent();
-            
+
             Boolean parentStatus = IoUtils.checkFileExists(parent, options);
             if (parentStatus == null) {
                 throw new AccessDeniedException("Receive file parent (" + 
parent + ") existence status cannot be determined for " + path);
@@ -78,11 +78,11 @@ public class LocalFileScpTargetStreamResolver extends 
AbstractLoggingBean implem
                 file = path;
             }
         }
-        
+
         if (file == null) {
             throw new IOException("Can not write to " + path);
         }
-        
+
         Boolean fileStatus = IoUtils.checkFileExists(file, options);
         if (fileStatus == null) {
             throw new AccessDeniedException("Receive file existence status 
cannot be determined: " + file);
@@ -133,8 +133,8 @@ public class LocalFileScpTargetStreamResolver extends 
AbstractLoggingBean implem
 
         if (time != null) {
             BasicFileAttributeView view = Files.getFileAttributeView(path, 
BasicFileAttributeView.class);
-            FileTime lastModified = FileTime.from(time.lastModifiedTime, 
TimeUnit.MILLISECONDS);
-            FileTime lastAccess = FileTime.from(time.lastAccessTime, 
TimeUnit.MILLISECONDS);
+            FileTime lastModified = FileTime.from(time.getLastModifiedTime(), 
TimeUnit.MILLISECONDS);
+            FileTime lastAccess = FileTime.from(time.getLastAccessTime(), 
TimeUnit.MILLISECONDS);
             if (log.isTraceEnabled()) {
                 log.trace("updateFileProperties(" + name + ")[" + path + "] 
last-modified=" + lastModified + ", last-access=" + lastAccess);
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
index c685d23..d61dbb8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
@@ -78,15 +78,15 @@ public class ScpHelper extends AbstractLoggingBean {
     public static final int MIN_RECEIVE_BUFFER_SIZE = MIN_COPY_BUFFER_SIZE;
     public static final int MIN_SEND_BUFFER_SIZE = MIN_COPY_BUFFER_SIZE;
 
-    public static final int S_IRUSR =  0000400;
-    public static final int S_IWUSR =  0000200;
-    public static final int S_IXUSR =  0000100;
-    public static final int S_IRGRP =  0000040;
-    public static final int S_IWGRP =  0000020;
-    public static final int S_IXGRP =  0000010;
-    public static final int S_IROTH =  0000004;
-    public static final int S_IWOTH =  0000002;
-    public static final int S_IXOTH =  0000001;
+    public static final int S_IRUSR = 0000400;
+    public static final int S_IWUSR = 0000200;
+    public static final int S_IXUSR = 0000100;
+    public static final int S_IRGRP = 0000040;
+    public static final int S_IWGRP = 0000020;
+    public static final int S_IXGRP = 0000010;
+    public static final int S_IROTH = 0000004;
+    public static final int S_IWOTH = 0000002;
+    public static final int S_IXOTH = 0000001;
 
     protected final FileSystem fileSystem;
     protected final InputStream in;
@@ -144,7 +144,7 @@ public class ScpHelper extends AbstractLoggingBean {
     public void receive(final Path path, final boolean recursive, boolean 
shouldBeDir, final boolean preserve, final int bufferSize) throws IOException {
         if (shouldBeDir) {
             LinkOption[] options = IoUtils.getLinkOptions(false);
-            Boolean      status = IoUtils.checkFileExists(path, options);
+            Boolean status = IoUtils.checkFileExists(path, options);
             if (status == null) {
                 throw new SshException("Target directory " + path + " is most 
like inaccessible");
             }
@@ -180,6 +180,9 @@ public class ScpHelper extends AbstractLoggingBean {
                     return;
                 case 'D':
                     isDir = true;
+                    line = String.valueOf((char) c) + readLine();
+                    log.debug("Received header: " + line);
+                    break;
                 case 'C':
                     line = String.valueOf((char) c) + readLine();
                     log.debug("Received header: " + line);
@@ -207,6 +210,7 @@ public class ScpHelper extends AbstractLoggingBean {
             }
         }
     }
+
     public void receiveDir(String header, Path path, ScpTimestamp time, 
boolean preserve, int bufferSize) throws IOException {
         if (log.isDebugEnabled()) {
             log.debug("Receiving directory {}", path);
@@ -229,7 +233,7 @@ public class ScpHelper extends AbstractLoggingBean {
             throw new AccessDeniedException("Receive directory existence 
status cannot be determined: " + path);
         }
 
-        Path file=null;
+        Path file = null;
         if (status && Files.isDirectory(path, options)) {
             String localName = name.replace('/', File.separatorChar);
             file = path.resolve(localName);
@@ -240,7 +244,7 @@ public class ScpHelper extends AbstractLoggingBean {
             if (status == null) {
                 throw new AccessDeniedException("Receive directory parent (" + 
parent + ") existence status cannot be determined for " + path);
             }
-                
+
             if (status && Files.isDirectory(parent, options)) {
                 file = path;
             }
@@ -268,7 +272,7 @@ public class ScpHelper extends AbstractLoggingBean {
         time = null;
         try {
             listener.startFolderEvent(FileOperation.RECEIVE, path, perms);
-            for (; ; ) {
+            for (;;) {
                 header = readLine();
                 if (log.isDebugEnabled()) {
                     log.debug("Received header: " + header);
@@ -367,8 +371,8 @@ public class ScpHelper extends AbstractLoggingBean {
 
         if (time != null) {
             BasicFileAttributeView view = Files.getFileAttributeView(file, 
BasicFileAttributeView.class);
-            FileTime lastModified = FileTime.from(time.lastModifiedTime, 
TimeUnit.MILLISECONDS);
-            FileTime lastAccess = FileTime.from(time.lastAccessTime, 
TimeUnit.MILLISECONDS);
+            FileTime lastModified = FileTime.from(time.getLastModifiedTime(), 
TimeUnit.MILLISECONDS);
+            FileTime lastAccess = FileTime.from(time.getLastAccessTime(), 
TimeUnit.MILLISECONDS);
             if (log.isTraceEnabled()) {
                 log.trace("updateFileProperties(" + file + ") last-modified=" 
+ lastModified + ", last-access=" + lastAccess);
             }
@@ -382,7 +386,7 @@ public class ScpHelper extends AbstractLoggingBean {
 
     public String readLine(boolean canEof) throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        for (; ; ) {
+        for (;;) {
             int c = in.read();
             if (c == '\n') {
                 return baos.toString();
@@ -399,8 +403,8 @@ public class ScpHelper extends AbstractLoggingBean {
 
     public void send(Collection<String> paths, boolean recursive, boolean 
preserve, int bufferSize) throws IOException {
         readAck(false);
-        
-        LinkOption[]    options=IoUtils.getLinkOptions(false);
+
+        LinkOption[] options = IoUtils.getLinkOptions(false);
         for (String pattern : paths) {
             pattern = pattern.replace('/', File.separatorChar);
 
@@ -445,14 +449,14 @@ public class ScpHelper extends AbstractLoggingBean {
 
     public void sendPaths(Collection<? extends Path> paths, boolean recursive, 
boolean preserve, int bufferSize) throws IOException {
         readAck(false);
-        
-        LinkOption[]    options=IoUtils.getLinkOptions(false);
+
+        LinkOption[] options = IoUtils.getLinkOptions(false);
         for (Path file : paths) {
             send(file, recursive, preserve, bufferSize, options);
         }
     }
 
-    protected void send(Path file, boolean recursive, boolean preserve, int 
bufferSize, LinkOption ... options) throws IOException {
+    protected void send(Path file, boolean recursive, boolean preserve, int 
bufferSize, LinkOption... options) throws IOException {
         Boolean status = IoUtils.checkFileExists(file, options);
         if (status == null) {
             throw new AccessDeniedException("Send file existence status cannot 
be determined: " + file);
@@ -522,8 +526,8 @@ public class ScpHelper extends AbstractLoggingBean {
 
         ScpTimestamp time = resolver.getTimestamp();
         if (preserve && (time != null)) {
-            String cmd = "T" + 
TimeUnit.MILLISECONDS.toSeconds(time.lastModifiedTime)
-                    + ' ' + '0' + ' ' + 
TimeUnit.MILLISECONDS.toSeconds(time.lastAccessTime)
+            String cmd = "T" + 
TimeUnit.MILLISECONDS.toSeconds(time.getLastModifiedTime())
+                    + ' ' + '0' + ' ' + 
TimeUnit.MILLISECONDS.toSeconds(time.getLastAccessTime())
                     + ' ' + '0' + '\n';
             out.write(cmd.getBytes(StandardCharsets.UTF_8));
             out.flush();
@@ -598,7 +602,7 @@ public class ScpHelper extends AbstractLoggingBean {
         readAck(false);
     }
 
-    public static String getOctalPermissions(Path path, LinkOption ... 
options) throws IOException {
+    public static String getOctalPermissions(Path path, LinkOption... options) 
throws IOException {
         return getOctalPermissions(IoUtils.getPermissions(path, options));
     }
 
@@ -689,20 +693,20 @@ public class ScpHelper extends AbstractLoggingBean {
     public int readAck(boolean canEof) throws IOException {
         int c = in.read();
         switch (c) {
-        case -1:
-            if (!canEof) {
-                throw new EOFException("readAck - EOF before ACK");
-            }
-            break;
-        case OK:
-            break;
-        case WARNING:
-            log.warn("Received warning: " + readLine());
-            break;
-        case ERROR:
-            throw new IOException("Received nack: " + readLine());
-        default:
-            break;
+            case -1:
+                if (!canEof) {
+                    throw new EOFException("readAck - EOF before ACK");
+                }
+                break;
+            case OK:
+                break;
+            case WARNING:
+                log.warn("Received warning: " + readLine());
+                break;
+            case ERROR:
+                throw new IOException("Received nack: " + readLine());
+            default:
+                break;
         }
         return c;
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpReceiveLineHandler.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpReceiveLineHandler.java 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpReceiveLineHandler.java
index 3f38e01..55094ef 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpReceiveLineHandler.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpReceiveLineHandler.java
@@ -26,9 +26,9 @@ import java.io.IOException;
  */
 public interface ScpReceiveLineHandler {
     /**
-     * @param line Received SCP input line
+     * @param line  Received SCP input line
      * @param isDir Does the input line refer to a directory
-     * @param time The received {@link ScpTimestamp} - may be {@code null}
+     * @param time  The received {@link ScpTimestamp} - may be {@code null}
      * @throws IOException If failed to process the line
      */
     void process(String line, boolean isDir, ScpTimestamp time) throws 
IOException;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpSourceStreamResolver.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpSourceStreamResolver.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpSourceStreamResolver.java
index 6749a66..e104942 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpSourceStreamResolver.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpSourceStreamResolver.java
@@ -52,14 +52,14 @@ public interface ScpSourceStreamResolver {
      * @throws IOException If failed to generate the required data
      */
     ScpTimestamp getTimestamp() throws IOException;
-    
+
     /**
      * @return An estimated size of the expected number of bytes to be 
uploaded.
      * If non-positive then assumed to be unknown.
      * @throws IOException If failed to generate an estimate
      */
     long getSize() throws IOException;
-    
+
     /**
      * @return The {@link InputStream} containing the data to be uploaded
      * @throws IOException If failed to create the stream

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTargetStreamResolver.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTargetStreamResolver.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTargetStreamResolver.java
index f3db61f..a599c07 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTargetStreamResolver.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTargetStreamResolver.java
@@ -32,9 +32,10 @@ public interface ScpTargetStreamResolver {
     /**
      * Called when receiving a file in order to obtain an output stream
      * for the incoming data
-     * @param name File name as received from remote site
+     *
+     * @param name   File name as received from remote site
      * @param length Number of bytes expected to receive
-     * @param perms The {@link Set} of {@link PosixFilePermission} expected
+     * @param perms  The {@link Set} of {@link PosixFilePermission} expected
      * @return The {@link OutputStream} to write the incoming data
      * @throws IOException If failed to create the stream
      */
@@ -47,12 +48,13 @@ public interface ScpTargetStreamResolver {
 
     /**
      * Called after successful reception of the data (and after closing the 
stream)
-     * @param name File name as received from remote site
+     *
+     * @param name     File name as received from remote site
      * @param preserve If {@code true} then the resolver should attempt to 
preserve
-     * the specified permissions and timestamp
-     * @param perms The {@link Set} of {@link PosixFilePermission} expected
-     * @param time If not {@code null} then the required timestamp(s) on the
-     * incoming data
+     *                 the specified permissions and timestamp
+     * @param perms    The {@link Set} of {@link PosixFilePermission} expected
+     * @param time     If not {@code null} then the required timestamp(s) on 
the
+     *                 incoming data
      * @throws IOException If failed to post-process the incoming data
      */
     void postProcessReceivedData(String name, boolean preserve, 
Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTimestamp.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTimestamp.java 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTimestamp.java
index eccf71a..7be0944 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTimestamp.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTimestamp.java
@@ -28,33 +28,40 @@ import org.apache.sshd.common.util.GenericUtils;
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
 public class ScpTimestamp {
-    public final long lastModifiedTime;
-    public final long lastAccessTime;
+    private final long lastModifiedTime;
+    private final long lastAccessTime;
 
     public ScpTimestamp(long modTime, long accTime) {
         lastModifiedTime = modTime;
         lastAccessTime = accTime;
     }
-    
+
+    public long getLastModifiedTime() {
+        return lastModifiedTime;
+    }
+
+    public long getLastAccessTime() {
+        return lastAccessTime;
+    }
+
     @Override
     public String toString() {
         return "modified=" + new Date(lastModifiedTime)
-             + ";accessed=" + new Date(lastAccessTime)
-             ;
+                + ";accessed=" + new Date(lastAccessTime);
     }
 
     /**
      * @param line The time specification - format:
-     * {@code T<mtime-sec> <mtime-micros> <atime-sec> <atime-micros>}
-     * where specified times are since UTC 
+     *             {@code T<mtime-sec> <mtime-micros> <atime-sec> 
<atime-micros>}
+     *             where specified times are since UTC
      * @return The {@link ScpTimestamp} value with the timestamps converted to
      * <U>milliseconds</U>
      * @throws NumberFormatException if bad numerical values - <B>Note:</B>
-     * does not check if 1st character is 'T'.
+     *                               does not check if 1st character is 'T'.
      */
     public static ScpTimestamp parseTime(String line) throws 
NumberFormatException {
         String[] numbers = GenericUtils.split(line.substring(1), ' ');
         return new 
ScpTimestamp(TimeUnit.SECONDS.toMillis(Long.parseLong(numbers[0])),
-                                
TimeUnit.SECONDS.toMillis(Long.parseLong(numbers[2])));
+                TimeUnit.SECONDS.toMillis(Long.parseLong(numbers[2])));
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTransferEventListener.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTransferEventListener.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTransferEventListener.java
index fb82707..9bb41bc 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTransferEventListener.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpTransferEventListener.java
@@ -37,6 +37,33 @@ public interface ScpTransferEventListener extends 
EventListener {
     }
 
     /**
+     * An &quot;empty&quot; implementation to be used instead of {@code null}s
+     */
+    ScpTransferEventListener EMPTY = new ScpTransferEventListener() {
+        // TODO in JDK 8.0 implement all methods as default with empty body in 
the interface itself
+
+        @Override
+        public void startFileEvent(FileOperation op, Path file, long length, 
Set<PosixFilePermission> perms) {
+            // ignored
+        }
+
+        @Override
+        public void endFileEvent(FileOperation op, Path file, long length, 
Set<PosixFilePermission> perms, Throwable thrown) {
+            // ignored
+        }
+
+        @Override
+        public void startFolderEvent(FileOperation op, Path file, 
Set<PosixFilePermission> perms) {
+            // ignored
+        }
+
+        @Override
+        public void endFolderEvent(FileOperation op, Path file, 
Set<PosixFilePermission> perms, Throwable thrown) {
+            // ignored
+        }
+    };
+
+    /**
      * @param op     The {@link FileOperation}
      * @param file   The <U>local</U> referenced file {@link Path}
      * @param length Size (in bytes) of transfered data
@@ -74,30 +101,4 @@ public interface ScpTransferEventListener extends 
EventListener {
      */
     void endFolderEvent(FileOperation op, Path file, Set<PosixFilePermission> 
perms, Throwable thrown);
 
-    /**
-     * An &quot;empty&quot; implementation to be used instead of {@code null}s
-     */
-    ScpTransferEventListener EMPTY = new ScpTransferEventListener() {
-        // TODO in JDK 8.0 implement all methods as default with empty body in 
the interface itself
-
-        @Override
-        public void startFileEvent(FileOperation op, Path file, long length, 
Set<PosixFilePermission> perms) {
-            // ignored
-        }
-
-        @Override
-        public void endFileEvent(FileOperation op, Path file, long length, 
Set<PosixFilePermission> perms, Throwable thrown) {
-            // ignored
-        }
-
-        @Override
-        public void startFolderEvent(FileOperation op, Path file, 
Set<PosixFilePermission> perms) {
-            // ignored
-        }
-
-        @Override
-        public void endFolderEvent(FileOperation op, Path file, 
Set<PosixFilePermission> perms, Throwable thrown) {
-            // ignored
-        }
-    };
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
index 47c6cc4..48b3a0a 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
@@ -18,20 +18,6 @@
  */
 package org.apache.sshd.common.session;
 
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_CLOSE;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_DATA;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_EOF;
-import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_FAILURE;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN;
-import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN_CONFIRMATION;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_REQUEST;
-import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_WINDOW_ADJUST;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_GLOBAL_REQUEST;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_REQUEST_FAILURE;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_REQUEST_SUCCESS;
-
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
@@ -61,6 +47,20 @@ import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.server.channel.OpenChannelException;
 import org.apache.sshd.server.x11.X11ForwardSupport;
 
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_CLOSE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_DATA;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_EOF;
+import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_FAILURE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN;
+import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN_CONFIRMATION;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_REQUEST;
+import static 
org.apache.sshd.common.SshConstants.SSH_MSG_CHANNEL_WINDOW_ADJUST;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_GLOBAL_REQUEST;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_REQUEST_FAILURE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_REQUEST_SUCCESS;
+
 /**
  * Base implementation of ConnectionService.
  *
@@ -69,19 +69,26 @@ import org.apache.sshd.server.x11.X11ForwardSupport;
 public abstract class AbstractConnectionService extends 
CloseableUtils.AbstractInnerCloseable implements ConnectionService {
     /**
      * Property that can be used to configure max. allowed concurrent active 
channels
+     *
      * @see #registerChannel(Channel)
      */
     public static final String MAX_CONCURRENT_CHANNELS_PROP = 
"max-sshd-channels";
-        public static final int DEFAULT_MAX_CHANNELS = Integer.MAX_VALUE;
+    public static final int DEFAULT_MAX_CHANNELS = Integer.MAX_VALUE;
 
-    /** Map of channels keyed by the identifier */
+    /**
+     * Map of channels keyed by the identifier
+     */
     protected final Map<Integer, Channel> channels = new ConcurrentHashMap<>();
-    /** Next channel identifier */
+    /**
+     * Next channel identifier
+     */
     protected final AtomicInteger nextChannelId = new AtomicInteger(0);
 
     protected final AbstractSession session;
 
-    /** The tcpip forwarder */
+    /**
+     * The tcpip forwarder
+     */
     protected final TcpipForwarder tcpipForwarder;
     protected final AgentForwardSupport agentForward;
     protected final X11ForwardSupport x11Forward;
@@ -93,7 +100,7 @@ public abstract class AbstractConnectionService extends 
CloseableUtils.AbstractI
         FactoryManager manager = session.getFactoryManager();
         agentForward = new AgentForwardSupport(this);
         x11Forward = new X11ForwardSupport(this);
-        
+
         TcpipForwarderFactory factory = ValidateUtils.checkNotNull(
                 manager.getTcpipForwarderFactory(),
                 "No forwarder factory",
@@ -149,7 +156,7 @@ public abstract class AbstractConnectionService extends 
CloseableUtils.AbstractI
 
             channels.put(channelId, channel);
         }
-        
+
         if (log.isDebugEnabled()) {
             log.debug("registerChannel(id={}) {}", Integer.valueOf(channelId), 
channel);
         }
@@ -462,8 +469,7 @@ public abstract class AbstractConnectionService extends 
CloseableUtils.AbstractI
 
         byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
                  ? SshConstants.SSH_MSG_CHANNEL_SUCCESS
-                 : SshConstants.SSH_MSG_CHANNEL_FAILURE
-                 ;
+                 : SshConstants.SSH_MSG_CHANNEL_FAILURE;
         buffer.clear();
         // leave room for the SSH header
         buffer.ensureCapacity(5 + 1 + (Integer.SIZE / Byte.SIZE), 
Int2IntFunction.Utils.add(Byte.SIZE));

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/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 aabc4cb..acf0c2f 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
@@ -18,15 +18,6 @@
  */
 package org.apache.sshd.common.session;
 
-import static org.apache.sshd.common.SshConstants.SSH_MSG_DEBUG;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_DISCONNECT;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_IGNORE;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_KEXINIT;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_NEWKEYS;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_SERVICE_ACCEPT;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_SERVICE_REQUEST;
-import static org.apache.sshd.common.SshConstants.SSH_MSG_UNIMPLEMENTED;
-
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.nio.charset.StandardCharsets;
@@ -74,21 +65,31 @@ import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.BufferUtils;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 
+import static org.apache.sshd.common.SshConstants.SSH_MSG_DEBUG;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_DISCONNECT;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_IGNORE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_KEXINIT;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_NEWKEYS;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_SERVICE_ACCEPT;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_SERVICE_REQUEST;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_UNIMPLEMENTED;
+
 /**
  * The AbstractSession handles all the basic SSH protocol such as key 
exchange, authentication,
  * encoding and decoding. Both server side and client side sessions should 
inherit from this
  * abstract class. Some basic packet processing methods are defined but the 
actual call to these
  * methods should be done from the {@link 
#handleMessage(org.apache.sshd.common.util.buffer.Buffer)}
  * method, which is dependant on the state and side of this session.
- *
+ * <p/>
  * TODO: if there is any very big packet, decoderBuffer and uncompressBuffer 
will get quite big
- *        and they won't be resized down at any time. Though the packet size 
is really limited
- *        by the channel max packet size
+ * and they won't be resized down at any time. Though the packet size is 
really limited
+ * by the channel max packet size
  *
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
 public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerCloseable implements Session {
-    public static final String  DEFAULT_SSH_VERSION_PREFIX="SSH-2.0-";
+
+    public static final String DEFAULT_SSH_VERSION_PREFIX = "SSH-2.0-";
 
     /**
      * Name of the property where this session is stored in the attributes of 
the
@@ -97,20 +98,34 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      */
     public static final String SESSION = "org.apache.sshd.session";
 
-    /** Client or server side */
+    /**
+     * Client or server side
+     */
     protected final boolean isServer;
-    /** The factory manager used to retrieve factories of Ciphers, Macs and 
other objects */
+    /**
+     * The factory manager used to retrieve factories of Ciphers, Macs and 
other objects
+     */
     protected final FactoryManager factoryManager;
-    /** The underlying MINA session */
+    /**
+     * The underlying MINA session
+     */
     protected final IoSession ioSession;
-    /** The pseudo random generator */
+    /**
+     * The pseudo random generator
+     */
     protected final Random random;
-    /** Boolean indicating if this session has been authenticated or not */
+    /**
+     * Boolean indicating if this session has been authenticated or not
+     */
     protected boolean authed;
-    /** The name of the authenticated user */
+    /**
+     * The name of the authenticated user
+     */
     protected String username;
 
-    /** Session listeners container */
+    /**
+     * Session listeners container
+     */
     protected final List<SessionListener> listeners = new 
CopyOnWriteArrayList<SessionListener>();
     protected final SessionListener sessionListenerProxy;
     //
@@ -120,11 +135,11 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     protected String serverVersion;
     protected String clientVersion;
     // if empty then means not-initialized
-    protected final Map<KexProposalOption,String> serverProposal = new 
EnumMap<>(KexProposalOption.class);
-    protected final Map<KexProposalOption,String> clientProposal = new 
EnumMap<>(KexProposalOption.class);
-    private final Map<KexProposalOption,String> negotiationResult  = new 
EnumMap<>(KexProposalOption.class);
-    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 final Map<KexProposalOption, String> serverProposal = new 
EnumMap<>(KexProposalOption.class);
+    protected final Map<KexProposalOption, String> clientProposal = new 
EnumMap<>(KexProposalOption.class);
+    protected final Map<KexProposalOption, String> negotiationResult = new 
EnumMap<>(KexProposalOption.class);
+    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;
     protected final AtomicReference<KexState> kexState = new 
AtomicReference<KexState>(KexState.UNKNOWN);
     @SuppressWarnings("rawtypes")
@@ -155,8 +170,8 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     protected final Map<AttributeKey<?>, Object> attributes = new 
ConcurrentHashMap<>();
 
     // Session timeout
-    protected long authTimeoutTimestamp = 0L;
-    protected long idleTimeoutTimestamp = 0L;
+    protected long authTimeoutTimestamp;
+    protected long idleTimeoutTimestamp;
     protected long authTimeoutMs = TimeUnit.MINUTES.toMillis(2);          // 2 
minutes in milliseconds
     protected long idleTimeoutMs = TimeUnit.MINUTES.toMillis(10);         // 
10 minutes in milliseconds
     protected long disconnectTimeoutMs = TimeUnit.SECONDS.toMillis(10);   // 
10 seconds in milliseconds
@@ -178,7 +193,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * Create a new session.
      *
      * @param factoryManager the factory manager
-     * @param ioSession the underlying MINA session
+     * @param ioSession      the underlying MINA session
      */
     public AbstractSession(boolean isServer, FactoryManager factoryManager, 
IoSession ioSession) {
         this.isServer = isServer;
@@ -212,7 +227,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      *
      * @param ioSession the MINA session
      * @param allowNull if <code>true</code>, a {@code null} value may be
-     *        returned if no session is attached
+     *                  returned if no session is attached
      * @return the session attached to the MINA session or {@code null}
      */
     public static AbstractSession getSession(IoSession ioSession, boolean 
allowNull) {
@@ -227,7 +242,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * Attach a session to the MINA session
      *
      * @param ioSession the MINA session
-     * @param session the session to attach
+     * @param session   the session to attach
      */
     public static void attachSession(IoSession ioSession, AbstractSession 
session) {
         ioSession.setAttribute(SESSION, session);
@@ -266,13 +281,13 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     @Override
     public String getNegotiatedKexParameter(KexProposalOption paramType) {
-       if (paramType == null) {
-               return null;
-       }
+        if (paramType == null) {
+            return null;
+        }
 
-       synchronized(negotiationResult) {
-               return negotiationResult.get(paramType);
-       }
+        synchronized (negotiationResult) {
+            return negotiationResult.get(paramType);
+        }
     }
 
     @Override
@@ -288,7 +303,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     /**
      * Main input point for the MINA framework.
-     *
+     * <p/>
      * This method will be called each time new data is received on
      * the socket and will append it to the input buffer before
      * calling the {@link #decode()} method.
@@ -334,12 +349,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
         int cmd = buffer.getUByte();
         switch (cmd) {
             case SSH_MSG_DISCONNECT: {
-                int code = buffer.getInt();
-                String msg = buffer.getString();
-                if (log.isDebugEnabled()) {
-                    log.debug("Received SSH_MSG_DISCONNECT (reason={}, 
msg={})", Integer.valueOf(code), msg);
-                }
-                close(true);
+                handleDisconnect(buffer);
                 break;
             }
             case SSH_MSG_IGNORE: {
@@ -362,69 +372,16 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
                 break;
             }
             case SSH_MSG_SERVICE_REQUEST:
-                String service = buffer.getString();
-                log.debug("Received SSH_MSG_SERVICE_REQUEST '{}'", service);
-                validateKexState(cmd, KexState.DONE);
-                try {
-                    startService(service);
-                } catch (Exception e) {
-                    log.debug("Service " + service + " rejected", e);
-                    
disconnect(SshConstants.SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE, "Bad service 
request: " + service);
-                    break;
-                }
-                log.debug("Accepted service {}", service);
-                Buffer response = 
createBuffer(SshConstants.SSH_MSG_SERVICE_ACCEPT);
-                response.putString(service);
-                writePacket(response);
+                handleServiceRequest(buffer);
                 break;
             case SSH_MSG_SERVICE_ACCEPT:
-                log.debug("Received SSH_MSG_SERVICE_ACCEPT");
-                validateKexState(cmd, KexState.DONE);
-                serviceAccept();
+                handleServiceAccept();
                 break;
             case SSH_MSG_KEXINIT:
-                log.debug("Received SSH_MSG_KEXINIT");
-                receiveKexInit(buffer);
-                if (kexState.compareAndSet(KexState.DONE, KexState.RUN)) {
-                    sendKexInit();
-                } else if (!kexState.compareAndSet(KexState.INIT, 
KexState.RUN)) {
-                    throw new IllegalStateException("Received SSH_MSG_KEXINIT 
while key exchange is running");
-                }
-
-                {
-                    Map<KexProposalOption,String> result = negotiate();
-                    String kexAlgorithm = 
result.get(KexProposalOption.ALGORITHMS);
-                    kex = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getKeyExchangeFactories(),
 kexAlgorithm),
-                                                     "Unknown negotiated KEX 
algorithm: %s",
-                                                     kexAlgorithm);
-                    kex.init(this, 
serverVersion.getBytes(StandardCharsets.UTF_8), 
clientVersion.getBytes(StandardCharsets.UTF_8), I_S, I_C);
-                }
-
-                sendEvent(SessionListener.Event.KexCompleted);
+                handleKexInit(buffer);
                 break;
             case SSH_MSG_NEWKEYS:
-                log.debug("Received SSH_MSG_NEWKEYS");
-                validateKexState(cmd, KexState.KEYS);
-                receiveNewKeys();
-                if (reexchangeFuture != null) {
-                    reexchangeFuture.setValue(Boolean.TRUE);
-                }
-                sendEvent(SessionListener.Event.KeyEstablished);
-                synchronized (pendingPackets) {
-                    if (!pendingPackets.isEmpty()) {
-                        log.debug("Dequeing pending packets");
-                        synchronized (encodeLock) {
-                            PendingWriteFuture future;
-                            while ((future = pendingPackets.poll()) != null) {
-                                
doWritePacket(future.getBuffer()).addListener(future);
-                            }
-                        }
-                    }
-                    kexState.set(KexState.DONE);
-                }
-                synchronized (lock) {
-                    lock.notifyAll();
-                }
+                handleNewKeys(cmd);
                 break;
             default:
                 if ((cmd >= SshConstants.SSH_MSG_KEX_FIRST) && (cmd <= 
SshConstants.SSH_MSG_KEX_LAST)) {
@@ -446,6 +403,82 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
         checkRekey();
     }
 
+    private void handleDisconnect(Buffer buffer) {
+        int code = buffer.getInt();
+        String msg = buffer.getString();
+        if (log.isDebugEnabled()) {
+            log.debug("Received SSH_MSG_DISCONNECT (reason={}, msg={})", 
Integer.valueOf(code), msg);
+        }
+        close(true);
+    }
+
+    private void handleServiceRequest(Buffer buffer) throws IOException {
+        String service = buffer.getString();
+        log.debug("Received SSH_MSG_SERVICE_REQUEST '{}'", service);
+        validateKexState(SSH_MSG_SERVICE_REQUEST, KexState.DONE);
+        try {
+            startService(service);
+        } catch (Exception e) {
+            log.debug("Service " + service + " rejected", e);
+            disconnect(SshConstants.SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE, 
"Bad service request: " + service);
+            return;
+        }
+        log.debug("Accepted service {}", service);
+        Buffer response = createBuffer(SshConstants.SSH_MSG_SERVICE_ACCEPT);
+        response.putString(service);
+        writePacket(response);
+    }
+
+    private void handleServiceAccept() throws java.io.IOException {
+        log.debug("Received SSH_MSG_SERVICE_ACCEPT");
+        validateKexState(SSH_MSG_SERVICE_ACCEPT, 
org.apache.sshd.common.kex.KexState.DONE);
+        serviceAccept();
+    }
+
+    private void handleKexInit(org.apache.sshd.common.util.buffer.Buffer 
buffer) throws Exception {
+        log.debug("Received SSH_MSG_KEXINIT");
+        receiveKexInit(buffer);
+        if (kexState.compareAndSet(org.apache.sshd.common.kex.KexState.DONE, 
org.apache.sshd.common.kex.KexState.RUN)) {
+            sendKexInit();
+        } else if 
(!kexState.compareAndSet(org.apache.sshd.common.kex.KexState.INIT, 
org.apache.sshd.common.kex.KexState.RUN)) {
+            throw new IllegalStateException("Received SSH_MSG_KEXINIT while 
key exchange is running");
+        }
+
+        java.util.Map<org.apache.sshd.common.kex.KexProposalOption, String> 
result = negotiate();
+        String kexAlgorithm = 
result.get(org.apache.sshd.common.kex.KexProposalOption.ALGORITHMS);
+        kex = 
org.apache.sshd.common.util.ValidateUtils.checkNotNull(org.apache.sshd.common.NamedFactory.Utils.create(factoryManager.getKeyExchangeFactories(),
 kexAlgorithm),
+                "Unknown negotiated KEX algorithm: %s",
+                kexAlgorithm);
+        kex.init(this, 
serverVersion.getBytes(java.nio.charset.StandardCharsets.UTF_8), 
clientVersion.getBytes(java.nio.charset.StandardCharsets.UTF_8), i_s, i_c);
+
+        
sendEvent(org.apache.sshd.common.session.SessionListener.Event.KexCompleted);
+    }
+
+    private void handleNewKeys(int cmd) throws Exception {
+        log.debug("Received SSH_MSG_NEWKEYS");
+        validateKexState(cmd, org.apache.sshd.common.kex.KexState.KEYS);
+        receiveNewKeys();
+        if (reexchangeFuture != null) {
+            reexchangeFuture.setValue(Boolean.TRUE);
+        }
+        
sendEvent(org.apache.sshd.common.session.SessionListener.Event.KeyEstablished);
+        synchronized (pendingPackets) {
+            if (!pendingPackets.isEmpty()) {
+                log.debug("Dequeing pending packets");
+                synchronized (encodeLock) {
+                    PendingWriteFuture future;
+                    while ((future = pendingPackets.poll()) != null) {
+                        doWritePacket(future.getBuffer()).addListener(future);
+                    }
+                }
+            }
+            kexState.set(org.apache.sshd.common.kex.KexState.DONE);
+        }
+        synchronized (lock) {
+            lock.notifyAll();
+        }
+    }
+
     protected void validateKexState(int cmd, KexState expected) {
         KexState actual = kexState.get();
         if (!expected.equals(actual)) {
@@ -458,7 +491,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * The session will be closed and a disconnect packet will be
      * sent before if the given exception is an
      * {@link org.apache.sshd.common.SshException}.
-     * 
+     *
      * @param t the exception to process
      */
     @Override
@@ -503,7 +536,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     }
 
     protected Service[] getServices() {
-        return currentService != null ? new Service[] { currentService } : new 
Service[0];
+        return currentService != null ? new Service[]{currentService} : new 
Service[0];
     }
 
     @Override
@@ -662,7 +695,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
             // Check that the packet has some free space for the header
             if (buffer.rpos() < 5) {
                 log.warn("Performance cost: when sending a packet, ensure that 
"
-                           + "5 bytes are available in front of the buffer");
+                        + "5 bytes are available in front of the buffer");
                 Buffer nb = new ByteArrayBuffer();
                 nb.wpos(5);
                 nb.putBuffer(buffer);
@@ -747,7 +780,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
                     if (decoderLength < 5 || decoderLength > (256 * 1024)) {
                         log.warn("Error decoding packet (invalid length) {}", 
decoderBuffer.printHex());
                         throw new 
SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
-                                               "Invalid packet length: " + 
decoderLength);
+                                "Invalid packet length: " + decoderLength);
                     }
                     // Ok, that's good, we can go to the next step
                     decoderState = 1;
@@ -755,7 +788,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
                     // need more data
                     break;
                 }
-            // We have received the beginning of the packet
+                // We have received the beginning of the packet
             } else if (decoderState == 1) {
                 // The read position should always be 4 at this point
                 assert decoderBuffer.rpos() == 4;
@@ -764,7 +797,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
                 if (decoderBuffer.available() >= decoderLength + macSize) {
                     byte[] data = decoderBuffer.array();
                     // Decrypt the remaining of the packet
-                    if (inCipher != null){
+                    if (inCipher != null) {
                         inCipher.update(data, inCipherSize, decoderLength + 4 
- inCipherSize);
                     }
                     // Check the mac of the packet
@@ -835,12 +868,12 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     /**
      * Read the other side identification.
      * This method is specific to the client or server side, but both should 
call
-     * {@link 
#doReadIdentification(org.apache.sshd.common.util.buffer.Buffer,boolean)} and
+     * {@link #doReadIdentification(org.apache.sshd.common.util.buffer.Buffer, 
boolean)} and
      * store the result in the needed property.
      *
      * @param buffer the buffer containing the remote identification
      * @return <code>true</code> if the identification has been fully read or
-     *         <code>false</code> if more data is needed
+     * <code>false</code> if more data is needed
      * @throws IOException if an error occurs such as a bad protocol version
      */
     protected abstract boolean readIdentification(Buffer buffer) throws 
IOException;
@@ -898,29 +931,23 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * @param hostKeyTypes the list of supported host key types
      * @return The proposal {@link Map>
      */
-    protected Map<KexProposalOption,String> createProposal(String 
hostKeyTypes) {
-        Map<KexProposalOption,String> proposal = new 
EnumMap<>(KexProposalOption.class);
+    protected Map<KexProposalOption, String> createProposal(String 
hostKeyTypes) {
+        Map<KexProposalOption, String> proposal = new 
EnumMap<>(KexProposalOption.class);
         proposal.put(KexProposalOption.ALGORITHMS, 
NamedResource.Utils.getNames(factoryManager.getKeyExchangeFactories()));
         proposal.put(KexProposalOption.SERVERKEYS, hostKeyTypes);
-        
-        {
-            String value = 
NamedResource.Utils.getNames(factoryManager.getCipherFactories());
-            proposal.put(KexProposalOption.S2CENC, value);
-            proposal.put(KexProposalOption.C2SENC, value);
-        }
 
-        {
-            String value = 
NamedResource.Utils.getNames(factoryManager.getMacFactories());
-            proposal.put(KexProposalOption.S2CMAC, value);
-            proposal.put(KexProposalOption.C2SMAC, value);
-        }
-        
-        {
-            String value = 
NamedResource.Utils.getNames(factoryManager.getCompressionFactories());
-            proposal.put(KexProposalOption.S2CCOMP, value);
-            proposal.put(KexProposalOption.C2SCOMP, value);
-        }
-        
+        String ciphers = 
NamedResource.Utils.getNames(factoryManager.getCipherFactories());
+        proposal.put(KexProposalOption.S2CENC, ciphers);
+        proposal.put(KexProposalOption.C2SENC, ciphers);
+
+        String macs = 
NamedResource.Utils.getNames(factoryManager.getMacFactories());
+        proposal.put(KexProposalOption.S2CMAC, macs);
+        proposal.put(KexProposalOption.C2SMAC, macs);
+
+        String compressions = 
NamedResource.Utils.getNames(factoryManager.getCompressionFactories());
+        proposal.put(KexProposalOption.S2CCOMP, compressions);
+        proposal.put(KexProposalOption.C2SCOMP, compressions);
+
         proposal.put(KexProposalOption.S2CLANG, "");
         proposal.put(KexProposalOption.C2SLANG, "");
         return proposal;
@@ -934,7 +961,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * @return the sent packet which must be kept for later use
      * @throws IOException if an error occurred sending the packet
      */
-    protected byte[] sendKexInit(Map<KexProposalOption,String> proposal) 
throws IOException {
+    protected byte[] sendKexInit(Map<KexProposalOption, String> proposal) 
throws IOException {
         log.debug("Send SSH_MSG_KEXINIT");
         Buffer buffer = createBuffer(SshConstants.SSH_MSG_KEXINIT);
         int p = buffer.wpos();
@@ -963,17 +990,18 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * Receive the remote key exchange init message.
      * The packet data is returned for later use.
      *
-     * @param buffer the buffer containing the key exchange init packet
+     * @param buffer   the buffer containing the key exchange init packet
      * @param proposal the remote proposal to fill
      * @return the packet data
      */
-    protected byte[] receiveKexInit(Buffer buffer, 
Map<KexProposalOption,String> proposal) {
+    protected byte[] receiveKexInit(Buffer buffer, Map<KexProposalOption, 
String> proposal) {
         // Recreate the packet payload which will be needed at a later time
         byte[] d = buffer.array();
         byte[] data = new byte[buffer.available() + 1 /* the opcode */];
         data[0] = SshConstants.SSH_MSG_KEXINIT;
-        
-        int size = 6, cookieStartPos = buffer.rpos();
+
+        int size = 6;
+        int cookieStartPos = buffer.rpos();
         System.arraycopy(d, cookieStartPos, data, 1, data.length - 1);
         // Skip random cookie data
         buffer.rpos(cookieStartPos + SshConstants.MSG_KEX_COOKIE_SIZE);
@@ -989,11 +1017,12 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
             if (log.isTraceEnabled()) {
                 log.trace("receiveKexInit(" + toString() + ")[" + 
paramType.getDescription() + "] " + value);
             }
-            int curPos = buffer.rpos(), readLen = curPos - lastPos;
+            int curPos = buffer.rpos();
+            int readLen = curPos - lastPos;
             proposal.put(paramType, value);
             size += readLen;
         }
-        
+
         boolean firstKexPacketFollows = buffer.getBoolean();
         if (log.isTraceEnabled()) {
             log.trace("receiveKexInit(" + toString() + ") first kex packet 
follows: " + firstKexPacketFollows);
@@ -1031,14 +1060,14 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * @throws Exception if an error occurs
      */
     protected void receiveNewKeys() throws Exception {
-        byte[] IVc2s;
-        byte[] IVs2c;
-        byte[] Ec2s;
-        byte[] Es2c;
-        byte[] MACc2s;
-        byte[] MACs2c;
-        byte[] K = kex.getK();
-        byte[] H = kex.getH();
+        byte[] iv_c2s;
+        byte[] iv_s2c;
+        byte[] e_c2s;
+        byte[] e_s2c;
+        byte[] mac_c2s;
+        byte[] mac_s2c;
+        byte[] k = kex.getK();
+        byte[] h = kex.getH();
         Digest hash = kex.getHash();
         Cipher s2ccipher;
         Cipher c2scipher;
@@ -1048,79 +1077,69 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
         Compression c2scomp;
 
         if (sessionId == null) {
-            sessionId = new byte[H.length];
-            System.arraycopy(H, 0, sessionId, 0, H.length);
+            sessionId = new byte[h.length];
+            System.arraycopy(h, 0, sessionId, 0, h.length);
         }
 
         Buffer buffer = new ByteArrayBuffer();
-        buffer.putMPInt(K);
-        buffer.putRawBytes(H);
+        buffer.putMPInt(k);
+        buffer.putRawBytes(h);
         buffer.putByte((byte) 0x41);
         buffer.putRawBytes(sessionId);
         int pos = buffer.available();
         byte[] buf = buffer.array();
         hash.update(buf, 0, pos);
-        IVc2s = hash.digest();
+        iv_c2s = hash.digest();
 
         int j = pos - sessionId.length - 1;
 
         buf[j]++;
         hash.update(buf, 0, pos);
-        IVs2c = hash.digest();
+        iv_s2c = hash.digest();
 
         buf[j]++;
         hash.update(buf, 0, pos);
-        Ec2s = hash.digest();
+        e_c2s = hash.digest();
 
         buf[j]++;
         hash.update(buf, 0, pos);
-        Es2c = hash.digest();
+        e_s2c = hash.digest();
 
         buf[j]++;
         hash.update(buf, 0, pos);
-        MACc2s = hash.digest();
+        mac_c2s = hash.digest();
 
         buf[j]++;
         hash.update(buf, 0, pos);
-        MACs2c = hash.digest();
+        mac_s2c = hash.digest();
 
-        {
-            String value = getNegotiatedKexParameter(KexProposalOption.S2CENC);
-            s2ccipher = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getCipherFactories(),
 value), "Unknown s2c cipher: %s", value);
-            Es2c = resizeKey(Es2c, s2ccipher.getBlockSize(), hash, K, H);
-            s2ccipher.init(isServer ? Cipher.Mode.Encrypt : 
Cipher.Mode.Decrypt, Es2c, IVs2c);
-        }
+        String value;
 
-        {
-            String value = getNegotiatedKexParameter(KexProposalOption.S2CMAC);
-            s2cmac = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getMacFactories(),
 value), "Unknown s2c mac: %s", value);
-            MACs2c = resizeKey(MACs2c, s2cmac.getBlockSize(), hash, K, H);
-            s2cmac.init(MACs2c);
-        }
+        value = getNegotiatedKexParameter(KexProposalOption.S2CENC);
+        s2ccipher = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getCipherFactories(),
 value), "Unknown s2c cipher: %s", value);
+        e_s2c = resizeKey(e_s2c, s2ccipher.getBlockSize(), hash, k, h);
+        s2ccipher.init(isServer ? Cipher.Mode.Encrypt : Cipher.Mode.Decrypt, 
e_s2c, iv_s2c);
 
-        {
-            String value = 
getNegotiatedKexParameter(KexProposalOption.S2CCOMP);
-            s2ccomp = 
NamedFactory.Utils.create(factoryManager.getCompressionFactories(), value);
-        }
+        value = getNegotiatedKexParameter(KexProposalOption.S2CMAC);
+        s2cmac = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getMacFactories(),
 value), "Unknown s2c mac: %s", value);
+        mac_s2c = resizeKey(mac_s2c, s2cmac.getBlockSize(), hash, k, h);
+        s2cmac.init(mac_s2c);
 
-        {
-            String value = getNegotiatedKexParameter(KexProposalOption.C2SENC);
-            c2scipher = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getCipherFactories(),
 value), "Unknown c2s cipher: %s", value);
-            Ec2s = resizeKey(Ec2s, c2scipher.getBlockSize(), hash, K, H);
-            c2scipher.init(isServer ? Cipher.Mode.Decrypt : 
Cipher.Mode.Encrypt, Ec2s, IVc2s);
-        }
+        value = getNegotiatedKexParameter(KexProposalOption.S2CCOMP);
+        s2ccomp = 
NamedFactory.Utils.create(factoryManager.getCompressionFactories(), value);
 
-        {
-            String value = getNegotiatedKexParameter(KexProposalOption.C2SMAC);
-            c2smac = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getMacFactories(),
 value), "Unknown c2s mac: %s", value);
-            MACc2s = resizeKey(MACc2s, c2smac.getBlockSize(), hash, K, H);
-            c2smac.init(MACc2s);
-        }
+        value = getNegotiatedKexParameter(KexProposalOption.C2SENC);
+        c2scipher = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getCipherFactories(),
 value), "Unknown c2s cipher: %s", value);
+        e_c2s = resizeKey(e_c2s, c2scipher.getBlockSize(), hash, k, h);
+        c2scipher.init(isServer ? Cipher.Mode.Decrypt : Cipher.Mode.Encrypt, 
e_c2s, iv_c2s);
 
-        {
-            String value = 
getNegotiatedKexParameter(KexProposalOption.C2SCOMP);
-            c2scomp = 
NamedFactory.Utils.create(factoryManager.getCompressionFactories(), value);
-        }
+        value = getNegotiatedKexParameter(KexProposalOption.C2SMAC);
+        c2smac = 
ValidateUtils.checkNotNull(NamedFactory.Utils.create(factoryManager.getMacFactories(),
 value), "Unknown c2s mac: %s", value);
+        mac_c2s = resizeKey(mac_c2s, c2smac.getBlockSize(), hash, k, h);
+        c2smac.init(mac_c2s);
+
+        value = getNegotiatedKexParameter(KexProposalOption.C2SCOMP);
+        c2scomp = 
NamedFactory.Utils.create(factoryManager.getCompressionFactories(), value);
 
         if (isServer) {
             outCipher = s2ccipher;
@@ -1157,28 +1176,28 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * Private method used while putting new keys into use that will resize 
the key used to
      * initialize the cipher to the needed length.
      *
-     * @param E the key to resize
+     * @param e         the key to resize
      * @param blockSize the cipher block size
-     * @param hash the hash algorithm
-     * @param K the key exchange K parameter
-     * @param H the key exchange H parameter
+     * @param hash      the hash algorithm
+     * @param k         the key exchange k parameter
+     * @param h         the key exchange h parameter
      * @return the resize key
      * @throws Exception if a problem occur while resizing the key
      */
-    private byte[] resizeKey(byte[] E, int blockSize, Digest hash, byte[] K, 
byte[] H) throws Exception {
-        while (blockSize > E.length) {
+    private byte[] resizeKey(byte[] e, int blockSize, Digest hash, byte[] k, 
byte[] h) throws Exception {
+        while (blockSize > e.length) {
             Buffer buffer = new ByteArrayBuffer();
-            buffer.putMPInt(K);
-            buffer.putRawBytes(H);
-            buffer.putRawBytes(E);
+            buffer.putMPInt(k);
+            buffer.putRawBytes(h);
+            buffer.putRawBytes(e);
             hash.update(buffer.array(), 0, buffer.available());
             byte[] foo = hash.digest();
-            byte[] bar = new byte[E.length + foo.length];
-            System.arraycopy(E, 0, bar, 0, E.length);
-            System.arraycopy(foo, 0, bar, E.length, foo.length);
-            E = bar;
+            byte[] bar = new byte[e.length + foo.length];
+            System.arraycopy(e, 0, bar, 0, e.length);
+            System.arraycopy(foo, 0, bar, e.length, foo.length);
+            e = bar;
         }
-        return E;
+        return e;
     }
 
     @Override
@@ -1215,13 +1234,14 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
      * Compute the negotiated proposals by merging the client and
      * server proposal. The negotiated proposal will also be stored in
      * the {@link #negotiationResult} property.
+     *
      * @return The negotiated options {@link Map}
      */
-    protected Map<KexProposalOption,String> negotiate() {
-        Map<KexProposalOption,String> guess = new 
EnumMap<>(KexProposalOption.class);
+    protected Map<KexProposalOption, String> negotiate() {
+        Map<KexProposalOption, String> guess = new 
EnumMap<>(KexProposalOption.class);
         for (KexProposalOption paramType : KexProposalOption.VALUES) {
-               String clientParamValue = clientProposal.get(paramType);
-               String serverParamValue = serverProposal.get(paramType);
+            String clientParamValue = clientProposal.get(paramType);
+            String serverParamValue = serverProposal.get(paramType);
             String[] c = GenericUtils.split(clientParamValue, ',');
             String[] s = GenericUtils.split(serverParamValue, ',');
             for (String ci : c) {
@@ -1231,39 +1251,39 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
                         break;
                     }
                 }
-                
+
                 String value = guess.get(paramType);
                 if (value != null) {
                     break;
                 }
             }
-            
+
             // check if reached an agreement
             String value = guess.get(paramType);
             if (value == null) {
-               String  message="Unable to negotiate key exchange for " + 
paramType.getDescription()
-                                         + " (client: " + clientParamValue + " 
/ server: " + serverParamValue + ")";
+                String message = "Unable to negotiate key exchange for " + 
paramType.getDescription()
+                        + " (client: " + clientParamValue + " / server: " + 
serverParamValue + ")";
                 // OK if could not negotiate languages
-               if (KexProposalOption.S2CLANG.equals(paramType) || 
KexProposalOption.C2SLANG.equals(paramType)) {
+                if (KexProposalOption.S2CLANG.equals(paramType) || 
KexProposalOption.C2SLANG.equals(paramType)) {
                     if (log.isTraceEnabled()) {
                         log.trace(message);
                     }
-               } else {
-                       throw new IllegalStateException(message);
-               }
+                } else {
+                    throw new IllegalStateException(message);
+                }
             } else {
-               if (log.isTraceEnabled()) {
-                       log.trace("Kex: negotiate(" +  
paramType.getDescription() + ") guess=" + value
-                                       + " (client: " + clientParamValue + " / 
server: " + serverParamValue + ")");
-               }
+                if (log.isTraceEnabled()) {
+                    log.trace("Kex: negotiate(" + paramType.getDescription() + 
") guess=" + value
+                            + " (client: " + clientParamValue + " / server: " 
+ serverParamValue + ")");
+                }
             }
         }
-        
+
         return setNegotiationResult(guess);
     }
 
-    protected Map<KexProposalOption,String> 
setNegotiationResult(Map<KexProposalOption,String> guess) {
-        synchronized(negotiationResult) {
+    protected Map<KexProposalOption, String> 
setNegotiationResult(Map<KexProposalOption, String> guess) {
+        synchronized (negotiationResult) {
             if (!negotiationResult.isEmpty()) {
                 negotiationResult.clear(); // debug breakpoint
             }
@@ -1272,19 +1292,19 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
         if (log.isDebugEnabled()) {
             log.debug("Kex: server->client {} {} {}",
-                      guess.get(KexProposalOption.S2CENC),
-                      guess.get(KexProposalOption.S2CMAC),
-                      guess.get(KexProposalOption.S2CCOMP));
+                    guess.get(KexProposalOption.S2CENC),
+                    guess.get(KexProposalOption.S2CMAC),
+                    guess.get(KexProposalOption.S2CCOMP));
             log.debug("Kex: client->server {} {} {}",
-                      guess.get(KexProposalOption.C2SENC),
-                      guess.get(KexProposalOption.C2SMAC),
-                      guess.get(KexProposalOption.C2SCOMP));
+                    guess.get(KexProposalOption.C2SENC),
+                    guess.get(KexProposalOption.C2SMAC),
+                    guess.get(KexProposalOption.C2SCOMP));
         }
-        
+
         return guess;
     }
 
-    protected void requestSuccess(Buffer buffer) throws Exception{
+    protected void requestSuccess(Buffer buffer) throws Exception {
         synchronized (requestResult) {
             requestResult.set(new ByteArrayBuffer(buffer.getCompactData()));
             resetIdleTimeout();
@@ -1292,7 +1312,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
         }
     }
 
-    protected void requestFailure(Buffer buffer) throws Exception{
+    protected void requestFailure(Buffer buffer) throws Exception {
         synchronized (requestResult) {
             requestResult.set(null);
             resetIdleTimeout();
@@ -1303,7 +1323,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     /**
      * Retrieve a configuration property as an integer
      *
-     * @param name the name of the property
+     * @param name         the name of the property
      * @param defaultValue the default value
      * @return the value of the configuration property or the default value if 
not found
      */
@@ -1339,7 +1359,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     @Override
     @SuppressWarnings("unchecked")
     public <T> T getAttribute(AttributeKey<T> key) {
-        return (T)attributes.get(key);
+        return (T) attributes.get(key);
     }
 
     /**
@@ -1352,7 +1372,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     @Override
     @SuppressWarnings("unchecked")
     public <T, E extends T> T setAttribute(AttributeKey<T> key, E value) {
-        return (T)attributes.put(key, value);
+        return (T) attributes.put(key, value);
     }
 
     @Override
@@ -1381,7 +1401,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     }
 
     protected void sendEvent(SessionListener.Event event) throws IOException {
-       sessionListenerProxy.sessionEvent(this, event);
+        sessionListenerProxy.sessionEvent(this, event);
     }
 
     @Override
@@ -1403,10 +1423,10 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
         String resolvedAlgorithms = resolveAvailableSignaturesProposal();
         if (GenericUtils.isEmpty(resolvedAlgorithms)) {
             throw new 
SshException(SshConstants.SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE,
-                                   "sendKexInit() no resolved signatures 
available");
+                    "sendKexInit() no resolved signatures available");
         }
 
-        Map<KexProposalOption,String> proposal = 
createProposal(resolvedAlgorithms); 
+        Map<KexProposalOption, String> proposal = 
createProposal(resolvedAlgorithms);
         byte[] seed = sendKexInit(proposal);
         if (log.isDebugEnabled()) {
             log.debug("sendKexInit(" + proposal + ") seed: " + 
BufferUtils.printHex(':', seed));
@@ -1417,9 +1437,9 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     /**
      * @param seed The result of the KEXINIT handshake - required for correct
-     * session key establishment
+     *             session key establishment
      */
-    protected abstract void setKexSeed(byte ... seed);
+    protected abstract void setKexSeed(byte... seed);
 
     /**
      * @return A comma-separated list of all the signature protocols to be
@@ -1441,31 +1461,31 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
     protected abstract void checkKeys() throws IOException;
 
     protected void receiveKexInit(Buffer buffer) throws IOException {
-        Map<KexProposalOption,String> proposal = new 
EnumMap<KexProposalOption, String>(KexProposalOption.class);
+        Map<KexProposalOption, String> proposal = new 
EnumMap<KexProposalOption, String>(KexProposalOption.class);
         byte[] seed = receiveKexInit(buffer, proposal);
         receiveKexInit(proposal, seed);
     }
-    
-    protected abstract void receiveKexInit(Map<KexProposalOption,String> 
proposal, byte[] seed) throws IOException;
+
+    protected abstract void receiveKexInit(Map<KexProposalOption, String> 
proposal, byte[] seed) throws IOException;
 
     // returns the proposal argument
-    protected Map<KexProposalOption,String> 
mergeProposals(Map<KexProposalOption,String> current, 
Map<KexProposalOption,String> proposal) {
+    protected Map<KexProposalOption, String> 
mergeProposals(Map<KexProposalOption, String> current, Map<KexProposalOption, 
String> proposal) {
         if (current == proposal) {
             return proposal; // debug breakpoint
         }
 
-        synchronized(current) {
+        synchronized (current) {
             if (!current.isEmpty()) {
                 current.clear();    // debug breakpoint
             }
-            
+
             if (GenericUtils.isEmpty(proposal)) {
                 return proposal; // debug breakpoint
             }
-            
+
             current.putAll(proposal);
         }
-        
+
         return proposal;
     }
 
@@ -1500,6 +1520,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     /**
      * Check if timeout has occurred.
+     *
      * @return
      */
     @Override
@@ -1509,6 +1530,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     /**
      * What is timeout value in milliseconds for authentication stage
+     *
      * @return
      */
     @Override
@@ -1518,6 +1540,7 @@ public abstract class AbstractSession extends 
CloseableUtils.AbstractInnerClosea
 
     /**
      * What is timeout value in milliseconds for communication
+     *
      * @return
      */
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSessionFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSessionFactory.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSessionFactory.java
index 20c86ac..afb0184 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSessionFactory.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSessionFactory.java
@@ -34,7 +34,7 @@ public abstract class AbstractSessionFactory extends 
AbstractSessionIoHandler {
     protected final List<SessionListener> listeners = new 
CopyOnWriteArrayList<>();
 
     protected AbstractSessionFactory() {
-       super();
+        super();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionService.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionService.java 
b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionService.java
index fcc242b..c03eb14 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionService.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/ConnectionService.java
@@ -32,6 +32,7 @@ import org.apache.sshd.common.forward.TcpipForwarder;
 public interface ConnectionService extends Service {
     /**
      * Register a newly created channel with a new unique identifier
+     *
      * @param channel The {@link Channel} to register
      * @return The assigned id of this channel
      * @throws IOException If failed to initialize and register the channel
@@ -47,6 +48,7 @@ public interface ConnectionService extends Service {
 
     /**
      * Retrieve the tcpip forwarder
+     *
      * @return
      */
     TcpipForwarder getTcpipForwarder();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/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
index fb09479..9749345 100644
--- 
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
@@ -21,18 +21,16 @@ package org.apache.sshd.common.session;
 
 import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.util.Transformer;
+import org.apache.sshd.common.util.buffer.Buffer;
 
 /**
  * @author <a href="mailto:[email protected]";>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;
-                }
-            };
+    Transformer<ConnectionServiceRequestHandler, 
RequestHandler<ConnectionService>> SVC2HNDLR = Transformer.Utils.identity();
+
+    Result process(ConnectionService service, String request, boolean 
wantReply, Buffer buffer) throws Exception;
 
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/PendingWriteFuture.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/PendingWriteFuture.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/PendingWriteFuture.java
index 0c8de8c..79bd0f2 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/PendingWriteFuture.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/PendingWriteFuture.java
@@ -21,12 +21,12 @@ package org.apache.sshd.common.session;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.AbstractIoWriteFuture;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 
 /**
  * Future holding a packet pending key exchange termination.
+ *
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
 public class PendingWriteFuture extends AbstractIoWriteFuture implements 
SshFutureListener<IoWriteFuture> {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/Session.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/Session.java 
b/sshd-core/src/main/java/org/apache/sshd/common/session/Session.java
index 4548ecc..fc5673a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/Session.java
@@ -71,6 +71,7 @@ public interface Session extends Closeable {
      * @return the user name.
      */
     String getUsername();
+
     void setUsername(String username);
 
     /**
@@ -94,8 +95,9 @@ public interface Session extends Closeable {
 
     /**
      * Retrieve one of the negotiated values during the KEX stage
+     *
      * @param paramType The request {@link KexProposalOption} value - ignored
-     * if {@code null} 
+     *                  if {@code null}
      * @return The negotiated parameter value - {@code null} if invalid
      * parameter or no negotiated value
      */
@@ -104,7 +106,7 @@ public interface Session extends Closeable {
     /**
      * Retrieve a configuration property as an integer
      *
-     * @param name the name of the property
+     * @param name         the name of the property
      * @param defaultValue the default value
      * @return the value of the configuration property or the default value if 
not found
      */
@@ -123,7 +125,7 @@ public interface Session extends Closeable {
      * Create a new buffer for the specified SSH packet and reserve the needed 
space
      * (5 bytes) for the packet header.
      *
-     * @param cmd the SSH command
+     * @param cmd           the SSH command
      * @param estimatedSize estimated number of bytes the buffer will hold, 0 
if unknown.
      * @return a new buffer ready for write
      */
@@ -146,9 +148,9 @@ public interface Session extends Closeable {
      * {@link org.apache.sshd.common.io.IoWriteFuture} will be set with a
      * {@link java.util.concurrent.TimeoutException} exception to indicate a 
timeout.
      *
-     * @param buffer the buffer to encode and spend
+     * @param buffer  the buffer to encode and spend
      * @param timeout the timeout
-     * @param unit the time unit of the timeout parameter
+     * @param unit    the time unit of the timeout parameter
      * @return a future that can be used to check when the packet has actually 
been sent
      * @throws java.io.IOException if an error occurred when encoding sending 
the packet
      */
@@ -214,7 +216,7 @@ public interface Session extends Closeable {
      * Typically it is used as a static variable that is shared between the 
producer
      * and the consumer. To further restrict access the setting or getting it 
from
      * the Session you can add static get and set methods, e.g:
-     *
+     * <p/>
      * <pre>
      * private static final AttributeKey&lt;MyValue&gt; MY_KEY = new 
AttributeKey&lt;MyValue&gt;();
      *
@@ -228,7 +230,6 @@ public interface Session extends Closeable {
      * </pre>
      *
      * @param <T> type of value stored in the attribute.
-     *
      * @author <a href="mailto:[email protected]";>Apache MINA SSHD 
Project</a>
      */
     public class AttributeKey<T> {
@@ -241,6 +242,7 @@ public interface Session extends Closeable {
 
     /**
      * Check if timeout has occurred.
+     *
      * @return the timeout status, never {@code null}
      */
     TimeoutStatus getTimeoutStatus();
@@ -254,11 +256,13 @@ public interface Session extends Closeable {
      * @return Timeout value in milliseconds for communication
      */
     long getIdleTimeout();
-    
+
     boolean isAuthenticated();
+
     void setAuthenticated() throws IOException;
-    
+
     byte[] getSessionId();
+
     KeyExchange getKex();
 
     /**
@@ -267,7 +271,7 @@ public interface Session extends Closeable {
      * asynchronously.
      *
      * @param reason the reason code for this disconnect
-     * @param msg the text message
+     * @param msg    the text message
      * @throws IOException if an error occurred sending the packet
      */
     void disconnect(int reason, String msg) throws IOException;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java 
b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
index 7f5bbc2..e4e881c 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
@@ -33,12 +33,14 @@ public interface SessionListener extends EventListener {
 
     /**
      * A new session just been created
+     *
      * @param session
      */
     void sessionCreated(Session session);
 
     /**
      * An event has been triggered
+     *
      * @param session
      * @param event
      */
@@ -46,6 +48,7 @@ public interface SessionListener extends EventListener {
 
     /**
      * A session has been closed
+     *
      * @param session
      */
     void sessionClosed(Session session);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/session/SessionTimeoutListener.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionTimeoutListener.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionTimeoutListener.java
index fcabbe1..b0ba992 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionTimeoutListener.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionTimeoutListener.java
@@ -54,7 +54,7 @@ public class SessionTimeoutListener extends 
AbstractLoggingBean implements Sessi
         for (AbstractSession session : sessions) {
             try {
                 session.checkForTimeouts();
-            } catch(Exception e) {
+            } catch (Exception e) {
                 log.warn("An error occurred while checking session=" + session 
+ " timeouts", e);
             }
         }

Reply via email to