[ https://issues.apache.org/jira/browse/SSHD-220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13661344#comment-13661344 ]
Andrew C commented on SSHD-220: ------------------------------- In git: https://github.com/cagney/mina-sshd-service/tree/sshd-220 I wonder if we can set up pull requests. > 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 > Attachments: sshd-220.patch > > > 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