com.maverick.ssh
Class PasswordAuthentication

java.lang.Object
  extended bycom.maverick.ssh.PasswordAuthentication
All Implemented Interfaces:
SshAuthentication
Direct Known Subclasses:
Ssh2PasswordAuthentication

public class PasswordAuthentication
extends java.lang.Object
implements SshAuthentication

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. Although this feature is not supported by SSH1 it does not break the authentication process to use the Ssh2PasswordAuthentication implementation .

Author:
Lee David Painter
See Also:
Ssh2PasswordAuthentication

Field Summary
 
Fields inherited from interface com.maverick.ssh.SshAuthentication
CANCELLED, COMPLETE, FAILED, FURTHER_AUTHENTICATION_REQUIRED, PUBLIC_KEY_ACCEPTABLE
 
Constructor Summary
PasswordAuthentication()
           
 
Method Summary
 java.lang.String getMethod()
          The SSH authentication method name
 java.lang.String getPassword()
          Get the password.
 java.lang.String getUsername()
          Get the username.
 void setPassword(java.lang.String password)
          Set the password.
 void setUsername(java.lang.String username)
          Set the username.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordAuthentication

public PasswordAuthentication()
Method Detail

setPassword

public void setPassword(java.lang.String password)
Set the password.

Parameters:
password -

getPassword

public java.lang.String getPassword()
Get the password.

Returns:
the pasword

getMethod

public java.lang.String getMethod()
Description copied from interface: SshAuthentication
The SSH authentication method name

Specified by:
getMethod in interface SshAuthentication
Returns:
String

setUsername

public void setUsername(java.lang.String username)
Set the username.

Specified by:
setUsername in interface SshAuthentication
Parameters:
username -

getUsername

public java.lang.String getUsername()
Get the username.

Specified by:
getUsername in interface SshAuthentication
Returns:
the username used.


Copyright © 2003 3SP LTD. All Rights Reserved.