You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/11/18 04:55:00 UTC

[05/12] mina-sshd git commit: [SSHD-862] Established SessionContext 'succinct' representation of a session

[SSHD-862] Established SessionContext 'succinct' representation of a session


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

Branch: refs/heads/master
Commit: c649ac5abc008215d95268ad0df5d80dbe12c065
Parents: 8be6ef9
Author: Lyor Goldstein <lg...@apache.org>
Authored: Tue Nov 13 08:22:40 2018 +0200
Committer: Lyor Goldstein <lg...@apache.org>
Committed: Sun Nov 18 06:54:47 2018 +0200

----------------------------------------------------------------------
 CHANGES.md                                      |  2 +
 .../apache/sshd/common/PropertyResolver.java    |  5 +-
 .../sshd/common/session/SessionContext.java     | 96 ++++++++++++++++++++
 .../util/net/ConnectionEndpointsIndicator.java  | 37 ++++++++
 .../client/session/AbstractClientSession.java   |  4 +-
 .../forward/ExplicitPortForwardingTracker.java  |  4 +-
 .../org/apache/sshd/common/io/IoSession.java    | 15 +--
 .../org/apache/sshd/common/session/Session.java | 83 ++++-------------
 .../common/session/helpers/AbstractSession.java |  2 +-
 .../common/session/helpers/SessionHelper.java   |  7 +-
 .../server/channel/PuttyRequestHandler.java     |  7 +-
 .../server/session/AbstractServerSession.java   |  4 +-
 .../session/helpers/AbstractSessionTest.java    |  5 +-
 .../java/org/apache/sshd/server/ServerTest.java |  5 +-
 14 files changed, 181 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 95c17cf..8af2a71 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -12,6 +12,8 @@
 
 * `DEFAULT_PORT` moved from `SshConfigFileReader` to `SshConstants`
 
+* Moved some session "summary" related definitions from `Session` to `SessionContext` (which `Session` extends)
+
 * Added new `sessionDisconnect` method to `SessionListener`
 
 * `ReservedSessionMessagesHandler#handleUnimplementedMessage` has an extra `cmd` argument

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
index 91c3d41..d7f5f19 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
@@ -57,7 +57,7 @@ public interface PropertyResolver {
 
     /**
      * @return The parent resolver that can be used to query for missing
-     *         properties - {@code null} if no parent
+     * properties - {@code null} if no parent
      */
     PropertyResolver getParentPropertyResolver();
 
@@ -81,7 +81,8 @@ public interface PropertyResolver {
      * be converted into one.
      * </P>
      *
-     * @return a valid <code>Map</code> containing configuration values, never {@code null}
+     * @return a valid <code>Map</code> containing configuration values, never {@code null}.
+     * <b>Note:</b> may be immutable.
      */
     Map<String, Object> getProperties();
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-common/src/main/java/org/apache/sshd/common/session/SessionContext.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/session/SessionContext.java b/sshd-common/src/main/java/org/apache/sshd/common/session/SessionContext.java
new file mode 100644
index 0000000..87827bd
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/session/SessionContext.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.session;
+
+import org.apache.sshd.common.AttributeRepository;
+import org.apache.sshd.common.PropertyResolver;
+import org.apache.sshd.common.auth.UsernameHolder;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.net.ConnectionEndpointsIndicator;
+
+/**
+ * A &quot;succinct&quot; summary of the most important attributes of an SSH session
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface SessionContext
+        extends ConnectionEndpointsIndicator,
+                UsernameHolder,
+                PropertyResolver,
+                AttributeRepository {
+    /**
+     * Default prefix expected for the client / server identification string
+     * @see <A HREF="https://tools.ietf.org/html/rfc4253#section-4.2">RFC 4253 - section 4.2</A>
+     */
+    String DEFAULT_SSH_VERSION_PREFIX = "SSH-2.0-";
+
+    /**
+     * Backward compatible special prefix
+     * @see <A HREF="https://tools.ietf.org/html/rfc4253#section-5">RFC 4253 - section 5</A>
+     */
+    String FALLBACK_SSH_VERSION_PREFIX = "SSH-1.99-";
+
+    /**
+     * Maximum number of characters for any single line sent as part
+     * of the initial handshake - according to
+     * <A HREF="https://tools.ietf.org/html/rfc4253#section-4.2">RFC 4253 - section 4.2</A>:</BR>
+     *
+     * <P><CODE>
+     *      The maximum length of the string is 255 characters,
+     *      including the Carriage Return and Line Feed.
+     * </CODE></P>
+     */
+    int MAX_VERSION_LINE_LENGTH = 256;
+
+    /**
+     * @return A <U>clone</U> of the established session identifier - {@code null} if
+     * not yet established
+     */
+    byte[] getSessionId();
+
+    /**
+     * Retrieve the client version for this session.
+     *
+     * @return the client version - may be {@code null}/empty if versions not yet exchanged
+     */
+    String getClientVersion();
+
+    /**
+     * Retrieve the server version for this session.
+     *
+     * @return the server version - may be {@code null}/empty if versions not yet exchanged
+     */
+    String getServerVersion();
+
+    /**
+     * @return {@code true} if session has successfully completed the authentication phase
+     */
+    boolean isAuthenticated();
+
+    /**
+     * @param version The reported client/server version
+     * @return {@code true} if version not empty and starts with either
+     * {@value #DEFAULT_SSH_VERSION_PREFIX} or {@value #FALLBACK_SSH_VERSION_PREFIX}
+     */
+    static boolean isValidVersionPrefix(String version) {
+        return GenericUtils.isNotEmpty(version)
+            && (version.startsWith(DEFAULT_SSH_VERSION_PREFIX) || version.startsWith(FALLBACK_SSH_VERSION_PREFIX));
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-common/src/main/java/org/apache/sshd/common/util/net/ConnectionEndpointsIndicator.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/net/ConnectionEndpointsIndicator.java b/sshd-common/src/main/java/org/apache/sshd/common/util/net/ConnectionEndpointsIndicator.java
new file mode 100644
index 0000000..9d56e13
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/net/ConnectionEndpointsIndicator.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.net;
+
+import java.net.SocketAddress;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface ConnectionEndpointsIndicator {
+    /**
+     * @return the socket address of remote peer.
+     */
+    SocketAddress getRemoteAddress();
+
+    /**
+     * @return the socket address of local machine which is associated with this session.
+     */
+    SocketAddress getLocalAddress();
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index 3fac01c..1c329ef 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -59,7 +59,7 @@ import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KexState;
 import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.session.helpers.AbstractConnectionService;
 import org.apache.sshd.common.session.helpers.AbstractSession;
 import org.apache.sshd.common.util.GenericUtils;
@@ -392,7 +392,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
             log.debug("readIdentification({}) Server version string: {}", this, serverVersion);
         }
 
-        if (!Session.isValidVersionPrefix(serverVersion)) {
+        if (!SessionContext.isValidVersionPrefix(serverVersion)) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
                     "Unsupported protocol version: " + serverVersion);
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/client/session/forward/ExplicitPortForwardingTracker.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/forward/ExplicitPortForwardingTracker.java b/sshd-core/src/main/java/org/apache/sshd/client/session/forward/ExplicitPortForwardingTracker.java
index b8642ed..08cfefc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/forward/ExplicitPortForwardingTracker.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/forward/ExplicitPortForwardingTracker.java
@@ -24,12 +24,13 @@ import java.util.Objects;
 
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.forward.PortForwardingManager;
+import org.apache.sshd.common.util.net.ConnectionEndpointsIndicator;
 import org.apache.sshd.common.util.net.SshdSocketAddress;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class ExplicitPortForwardingTracker extends PortForwardingTracker {
+public class ExplicitPortForwardingTracker extends PortForwardingTracker implements ConnectionEndpointsIndicator {
     private final boolean localForwarding;
     private final SshdSocketAddress remoteAddress;
 
@@ -44,6 +45,7 @@ public class ExplicitPortForwardingTracker extends PortForwardingTracker {
         return localForwarding;
     }
 
+    @Override
     public SshdSocketAddress getRemoteAddress() {
         return remoteAddress;
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
index 3a3545c..c110eae 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoSession.java
@@ -18,11 +18,10 @@
  */
 package org.apache.sshd.common.io;
 
-import java.net.SocketAddress;
-
 import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.util.net.ConnectionEndpointsIndicator;
 
-public interface IoSession extends PacketWriter, Closeable {
+public interface IoSession extends ConnectionEndpointsIndicator, PacketWriter, Closeable {
 
     /**
      * @return a unique identifier for this session. Every session has its own
@@ -74,16 +73,6 @@ public interface IoSession extends PacketWriter, Closeable {
     Object removeAttribute(Object key);
 
     /**
-     * @return the socket address of remote peer.
-     */
-    SocketAddress getRemoteAddress();
-
-    /**
-     * @return the socket address of local machine which is associated with this session.
-     */
-    SocketAddress getLocalAddress();
-
-    /**
      * @return the {@link IoService} that created this session.
      */
     IoService getService();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/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 06516da..0ecab07 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
@@ -19,6 +19,7 @@
 package org.apache.sshd.common.session;
 
 import java.io.IOException;
+import java.net.SocketAddress;
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
@@ -27,7 +28,6 @@ import org.apache.sshd.common.AttributeStore;
 import org.apache.sshd.common.Closeable;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.FactoryManagerHolder;
-import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.Service;
 import org.apache.sshd.common.auth.MutableUserHolder;
 import org.apache.sshd.common.channel.ChannelListenerManager;
@@ -44,7 +44,6 @@ import org.apache.sshd.common.kex.KexFactoryManager;
 import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KeyExchange;
 import org.apache.sshd.common.mac.MacInformation;
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 
 /**
@@ -54,7 +53,10 @@ import org.apache.sshd.common.util.buffer.Buffer;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public interface Session
-        extends KexFactoryManager,
+        extends SessionContext,
+                AttributeStore,
+                MutableUserHolder,
+                KexFactoryManager,
                 SessionListenerManager,
                 ReservedSessionMessagesManager,
                 ChannelListenerManager,
@@ -63,35 +65,8 @@ public interface Session
                 UnknownChannelReferenceHandlerManager,
                 FactoryManagerHolder,
                 PortForwardingInformationProvider,
-                PropertyResolver,
-                AttributeStore,
-                Closeable,
-                MutableUserHolder,
-                PacketWriter {
-
-    /**
-     * Default prefix expected for the client / server identification string
-     * @see <A HREF="https://tools.ietf.org/html/rfc4253#section-4.2">RFC 4253 - section 4.2</A>
-     */
-    String DEFAULT_SSH_VERSION_PREFIX = "SSH-2.0-";
-
-    /**
-     * Backward compatible special prefix
-     * @see <A HREF="https://tools.ietf.org/html/rfc4253#section-5">RFC 4253 - section 5</A>
-     */
-    String FALLBACK_SSH_VERSION_PREFIX = "SSH-1.99-";
-
-    /**
-     * Maximum number of characters for any single line sent as part
-     * of the initial handshake - according to
-     * <A HREF="https://tools.ietf.org/html/rfc4253#section-4.2">RFC 4253 - section 4.2</A>:</BR>
-     *
-     * <P><CODE>
-     *      The maximum length of the string is 255 characters,
-     *      including the Carriage Return and Line Feed.
-     * </CODE></P>
-     */
-    int MAX_VERSION_LINE_LENGTH = 256;
+                PacketWriter,
+                Closeable {
 
     /**
      * Timeout status.
@@ -103,20 +78,6 @@ public interface Session
     }
 
     /**
-     * Retrieve the client version for this session.
-     *
-     * @return the client version.
-     */
-    String getClientVersion();
-
-    /**
-     * Retrieve the server version for this session.
-     *
-     * @return the server version.
-     */
-    String getServerVersion();
-
-    /**
      * Retrieve one of the negotiated values during the KEX stage
      *
      * @param paramType The request {@link KexProposalOption} value
@@ -273,6 +234,18 @@ public interface Session
      */
     IoSession getIoSession();
 
+    @Override
+    default SocketAddress getLocalAddress() {
+        IoSession s = getIoSession();
+        return (s == null) ? null : s.getLocalAddress();
+    }
+
+    @Override
+    default SocketAddress getRemoteAddress() {
+        IoSession s = getIoSession();
+        return (s == null) ? null : s.getRemoteAddress();
+    }
+
     /**
      * Check if timeout has occurred.
      *
@@ -298,8 +271,6 @@ public interface Session
      */
     long resetIdleTimeout();
 
-    boolean isAuthenticated();
-
     /**
      * @return Timeout value in milliseconds for authentication stage
      */
@@ -320,12 +291,6 @@ public interface Session
 
     void setAuthenticated() throws IOException;
 
-    /**
-     * @return The established session identifier - {@code null} if
-     * not yet established
-     */
-    byte[] getSessionId();
-
     KeyExchange getKex();
 
     /**
@@ -351,16 +316,6 @@ public interface Session
     }
 
     /**
-     * @param version The reported client/server version
-     * @return {@code true} if version not empty and starts with either
-     * {@value #DEFAULT_SSH_VERSION_PREFIX} or {@value #FALLBACK_SSH_VERSION_PREFIX}
-     */
-    static boolean isValidVersionPrefix(String version) {
-        return GenericUtils.isNotEmpty(version)
-            && (version.startsWith(DEFAULT_SSH_VERSION_PREFIX) || version.startsWith(FALLBACK_SSH_VERSION_PREFIX));
-    }
-
-    /**
      * Attempts to use the session's attribute, if not found then tries the factory manager
      *
      * @param <T> The generic attribute type

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 1f5efbb..db3b17a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -282,7 +282,7 @@ public abstract class AbstractSession extends SessionHelper {
             decoderBuffer.putBuffer(buffer);
             // One of those property will be set by the constructor and the other
             // one should be set by the readIdentification method
-            if (clientVersion == null || serverVersion == null) {
+            if ((clientVersion == null) || (serverVersion == null)) {
                 if (readIdentification(decoderBuffer)) {
                     decoderBuffer.compact();
                 } else {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 25cbf2f..6a4574d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -60,6 +60,7 @@ import org.apache.sshd.common.random.Random;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
 import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.session.SessionListener;
 import org.apache.sshd.common.session.UnknownChannelReferenceHandler;
 import org.apache.sshd.common.util.GenericUtils;
@@ -619,7 +620,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
     /**
      * Resolves the identification to send to the peer session by consulting
      * the associated {@link FactoryManager}. If a value is set, then it is
-     * <U>appended</U> to the standard {@link #DEFAULT_SSH_VERSION_PREFIX}.
+     * <U>appended</U> to the standard {@link SessionContext#DEFAULT_SSH_VERSION_PREFIX}.
      * Otherwise a default value is returned consisting of the prefix and
      * the core artifact name + version in <U>uppercase</U> - e.g.,'
      * &quot;SSH-2.0-SSHD-CORE-1.2.3.4&quot;
@@ -630,7 +631,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
     protected String resolveIdentificationString(String configPropName) {
         FactoryManager manager = getFactoryManager();
         String ident = manager.getString(configPropName);
-        return DEFAULT_SSH_VERSION_PREFIX + (GenericUtils.isEmpty(ident) ? manager.getVersion() : ident);
+        return SessionContext.DEFAULT_SSH_VERSION_PREFIX + (GenericUtils.isEmpty(ident) ? manager.getVersion() : ident);
     }
 
     /**
@@ -669,7 +670,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
             FactoryManager.MAX_IDENTIFICATION_SIZE, FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE);
         List<String> ident = null;
         int rpos = buffer.rpos();
-        for (byte[] data = new byte[MAX_VERSION_LINE_LENGTH];;) {
+        for (byte[] data = new byte[SessionContext.MAX_VERSION_LINE_LENGTH];;) {
             int pos = 0;    // start accumulating line from scratch
             for (boolean needLf = false;;) {
                 if (buffer.available() == 0) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
index a5eabe1..79a166c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
@@ -27,6 +27,7 @@ import org.apache.sshd.common.channel.AbstractChannelRequestHandler;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.channel.PtyMode;
 import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 
@@ -98,12 +99,12 @@ public class PuttyRequestHandler extends AbstractChannelRequestHandler {
 
     /**
      * @param clientVersion The client identification string - ignored if {@code null}/empty
-     * @return {@code true} if the identification starts with the {@link Session#DEFAULT_SSH_VERSION_PREFIX}
+     * @return {@code true} if the identification starts with the {@link SessionContext#DEFAULT_SSH_VERSION_PREFIX}
      * and it contains the &quot;putty&quot; string (case insensitive)
      */
     public static boolean isPuttyClient(String clientVersion) {
-        return (GenericUtils.length(clientVersion) > Session.DEFAULT_SSH_VERSION_PREFIX.length())
-            && clientVersion.startsWith(Session.DEFAULT_SSH_VERSION_PREFIX)
+        return (GenericUtils.length(clientVersion) > SessionContext.DEFAULT_SSH_VERSION_PREFIX.length())
+            && clientVersion.startsWith(SessionContext.DEFAULT_SSH_VERSION_PREFIX)
             && clientVersion.toLowerCase().contains("putty");
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
index 04e7fd0..96053f1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
@@ -43,7 +43,7 @@ import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KexState;
 import org.apache.sshd.common.keyprovider.KeyPairProvider;
 import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.session.helpers.AbstractSession;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
@@ -358,7 +358,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
         }
 
         String errorMessage = null;
-        if (!Session.isValidVersionPrefix(clientVersion)) {
+        if (!SessionContext.isValidVersionPrefix(clientVersion)) {
             errorMessage = "Unsupported protocol version: " + clientVersion;
         }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
index cf6779f..388bc7a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
@@ -44,6 +44,7 @@ import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
 import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
@@ -120,11 +121,11 @@ public class AbstractSessionTest extends BaseTestSupport {
 
     @Test(expected = IllegalStateException.class)
     public void testReadIdentLongLine() {
-        StringBuilder sb = new StringBuilder(Session.MAX_VERSION_LINE_LENGTH + Integer.SIZE);
+        StringBuilder sb = new StringBuilder(SessionContext.MAX_VERSION_LINE_LENGTH + Integer.SIZE);
         sb.append("SSH-2.0-software");
         do {
             sb.append("01234567890123456789012345678901234567890123456789");
-        } while (sb.length() < Session.MAX_VERSION_LINE_LENGTH);
+        } while (sb.length() < SessionContext.MAX_VERSION_LINE_LENGTH);
 
         Buffer buf = new ByteArrayBuffer(sb.toString().getBytes(StandardCharsets.UTF_8));
         String ident = readIdentification(session, buf);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c649ac5a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index 9944cde..5c3889f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -60,6 +60,7 @@ import org.apache.sshd.common.channel.WindowClosedException;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.session.SessionContext;
 import org.apache.sshd.common.session.SessionListener;
 import org.apache.sshd.common.session.helpers.AbstractConnectionService;
 import org.apache.sshd.common.session.helpers.AbstractSession;
@@ -787,11 +788,11 @@ public class ServerTest extends BaseTestSupport {
     public void testIdentificationStringsOverrides() throws Exception {
         String clientIdent = getCurrentTestName() + "-client";
         PropertyResolverUtils.updateProperty(client, ClientFactoryManager.CLIENT_IDENTIFICATION, clientIdent);
-        final String expClientIdent = Session.DEFAULT_SSH_VERSION_PREFIX + clientIdent;
+        final String expClientIdent = SessionContext.DEFAULT_SSH_VERSION_PREFIX + clientIdent;
 
         String serverIdent = getCurrentTestName() + "-server";
         PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.SERVER_IDENTIFICATION, serverIdent);
-        String expServerIdent = Session.DEFAULT_SSH_VERSION_PREFIX + serverIdent;
+        String expServerIdent = SessionContext.DEFAULT_SSH_VERSION_PREFIX + serverIdent;
         SessionListener listener = new SessionListener() {
             @Override
             public void sessionException(Session session, Throwable t) {