You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2013/07/19 10:04:11 UTC

[1/2] git commit: [SSH-203] Make sure that after authentication, the state is actually modified only after the various internal fields have been updated

Updated Branches:
  refs/heads/master 2ab545896 -> ddbe54177


[SSH-203] Make sure that after authentication, the state is actually modified only after the various internal fields have been updated

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

Branch: refs/heads/master
Commit: bb9137b2f6ea451cb5e6fdd30c8de282ee60d051
Parents: 2ab5458
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Jul 19 10:01:28 2013 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Jul 19 10:01:28 2013 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/sshd/server/session/ServerSession.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bb9137b2/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 531dfd6..3c7b68d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -503,9 +503,9 @@ public class ServerSession extends AbstractSession {
 
                     buffer = createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS, 0);
                     writePacket(buffer);
-                    setState(State.Running);
                     this.authed = true;
                     unscheduleAuthTimer();
+                    setState(State.Running);
                     scheduleIdleTimer();
                     log.info("Session {}@{} authenticated", getUsername(), getIoSession().getRemoteAddress());
 


[2/2] git commit: Small simplification of the authentication logic

Posted by gn...@apache.org.
Small simplification of the authentication logic

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

Branch: refs/heads/master
Commit: ddbe541774e06ce6eddaf2477313ada42e5940e0
Parents: bb9137b
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Jul 19 10:03:58 2013 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Jul 19 10:03:58 2013 +0200

----------------------------------------------------------------------
 .../apache/sshd/server/session/ServerSession.java | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ddbe5417/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 3c7b68d..6cdf006 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -409,7 +409,6 @@ public class ServerSession extends AbstractSession {
 
         } else {
 
-            UserAuth auth = this.currentAuth;
             Boolean authed = Boolean.FALSE;
 
             if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_REQUEST) {
@@ -439,9 +438,9 @@ public class ServerSession extends AbstractSession {
                 log.debug("Authenticating user '{}' with service '{}' and method '{}'", new Object[] { username, service, method });
                 NamedFactory<UserAuth> factory = NamedFactory.Utils.get(userAuthFactories, method);
                 if (factory != null) {
-                    auth = factory.create();
+                    currentAuth = factory.create();
                     try {
-                        authed = auth.auth(this, username, service, buffer);
+                        authed = currentAuth.auth(this, username, service, buffer);
                     } catch (Exception e) {
                         // Continue
                         log.debug("Authentication failed: {}", e.getMessage());
@@ -464,14 +463,9 @@ public class ServerSession extends AbstractSession {
             if (authed == null) {
                 // authentication is still ongoing
                 log.debug("Authentication not finished");
-                currentAuth = auth;
             } else if (authed) {
                 log.debug("Authentication succeeded");
-                if (currentAuth != null) {
-                    username = currentAuth.getUserName();
-                } else {
-                    username = this.authUserName;
-                }
+                username = currentAuth.getUserName();
 
                 boolean success = false;
                 for (List<String> l : authMethods) {
@@ -525,10 +519,8 @@ public class ServerSession extends AbstractSession {
                     writePacket(buffer);
                 }
 
-                if (currentAuth != null) {
-                    currentAuth.destroy();
-                    currentAuth = null;
-                }
+                currentAuth.destroy();
+                currentAuth = null;
             } else {
                 log.debug("Authentication failed");