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:12 UTC

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

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");