mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew C (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SSHD-220) Return AuthFuture.getException() != null when the connection closes during authentication
Date Tue, 12 Mar 2013 16:21:13 GMT
Andrew C created SSHD-220:
-----------------------------

             Summary: Return AuthFuture.getException() != null when the connection closes
during authentication
                 Key: SSHD-220
                 URL: https://issues.apache.org/jira/browse/SSHD-220
             Project: MINA SSHD
          Issue Type: Bug
    Affects Versions: 0.8.0
            Reporter: Andrew C


One problem I found when implementing my service path was that ClientSessionImpl.waitFor wants
to root around in the internals of UserAuthService to determine if the server is waiting for
user authentication.

This patch is a partial back port of the changes I made to address that problem.  Instead
of using waitFor(WAIT_AUTH), the authentication code can directly wait on the AuthFuture returned
vis:

            AuthFuture authFuture;
            do {
                if (hasKeys) {
                    authFuture = session.authAgent(login);
                } else {
                    System.out.print("Password:");
                    BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
                    String password = r.readLine();
                    authFuture = session.authPassword(login, password);
                }
                authFuture.await();
            } while (authFuture.isFailure());
            if (!authFuture.isSuccess()) {
                System.err.println("error");
                System.exit(-1);
            }

looking at the details:

- it factors out the duplicated code that was handling the wait for the server, and processing
server/client messages
- if the connection fails, that's reported by getException()!=null and everything else being
false.
- the internals also authFuture to wait for the server (just like the above)
- even makes it possible to delete WAIT_AUTH if so desired

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message