X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fauthentication%2FLoginPassword.java;h=ab94e59a93dcf4e70494f7bf65ba66a28b5915c0;hb=96e61c15761ca887620f53d6f20ac574d16287f8;hp=67027d8014881f7b1286a2eb6229ae3258a32a8a;hpb=478ce1fa1dc30974b7cf23fd5258f1af5366d547;p=controller.git diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java index 67027d8014..ab94e59a93 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java @@ -8,13 +8,13 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication; -import ch.ethz.ssh2.Connection; - import java.io.IOException; +import org.apache.sshd.ClientSession; +import org.apache.sshd.client.future.AuthFuture; /** * Class Providing username/password authentication option to - * {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.SshHandler} + * {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler} */ public class LoginPassword extends AuthenticationHandler { private final String username; @@ -26,11 +26,13 @@ public class LoginPassword extends AuthenticationHandler { } @Override - public void authenticate(Connection connection) throws IOException { - boolean isAuthenticated = connection.authenticateWithPassword(username, password); + public String getUsername() { + return username; + } - if (!isAuthenticated) { - throw new IOException("Authentication failed."); - } + @Override + public AuthFuture authenticate(final ClientSession session) throws IOException { + session.addPasswordIdentity(password); + return session.auth(); } }