Clean up NetconfClientConfiguration
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / authentication / LoginPasswordHandler.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
9
10 import java.io.IOException;
11 import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture;
12 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
13
14 /**
15  * Class Providing username/password authentication option to
16  * {@link org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler}.
17  */
18 public final class LoginPasswordHandler extends AuthenticationHandler {
19     private final String username;
20     private final String password;
21
22     public LoginPasswordHandler(final String username, final String password) {
23         this.username = username;
24         this.password = password;
25     }
26
27     @Override
28     public String getUsername() {
29         return username;
30     }
31
32     @Override
33     public AuthFuture authenticate(final ClientSession session) throws IOException {
34         session.addPasswordIdentity(password);
35         return session.auth();
36     }
37 }