All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sshtools.ssh.PasswordAuthentication Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved.
 *
 * For product documentation visit https://www.sshtools.com/
 *
 * This file is part of J2SSH Maverick.
 *
 * J2SSH Maverick is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * J2SSH Maverick is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with J2SSH Maverick.  If not, see .
 */
package com.sshtools.ssh;

/**
 * 

* Basic password authentication class used for SSH password authentication. * Once a connection has been established to an SSH server the user is normally * required to authenticate themselves. This class implements a basic password * SshAuthentication that can be passed * into the SshClient to authenticate. As a * username is required to establish a connection it is not required that it be * set on the password object, however if you wish to change the username you * can do so (this may not be allowed by some server implementations). *

* *

* Use password authentication as follows:

* *
 * SshConnector con = SshConnector.getInstance();
 * SshClient ssh = con.connect(new SocketTransport("beagle2.mars.net", 22),
 * 		"martianx");
 * 
 * PasswordAuthentication pwd = new PasswordAuthentication();
 * pwd.setPassword("likeidgivethataway!");
 * 
 * if (!ssh.isAuthenticated()) {
 * 	if (ssh.authenticate(pwd) == SshAuthentication.COMPLETE) {
 * 		// Transfer some files or do something else interesting
 * 	}
 * }
 * 
* *
*

*

* It is recommended that in situations where you may be connecting to an SSH2 * server, that the Ssh2PasswordAuthentication * subclass is used instead. This extends the basic functionality provided here * by supporting the changing of the users password. *

* * @see com.sshtools.ssh2.Ssh2PasswordAuthentication * @author Lee David Painter */ public class PasswordAuthentication implements SshAuthentication { String password; String username; /** * Set the password. * * @param password */ public void setPassword(String password) { this.password = password; } /** * Get the password. * * @return the password */ public String getPassword() { return password; } public String getMethod() { return "password"; } /** * Set the username. */ public void setUsername(String username) { this.username = username; } /** * Get the username. */ public String getUsername() { return username; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy