com.maverick.ssh2
Class Ssh2PasswordAuthentication
java.lang.Object
com.maverick.ssh.PasswordAuthentication
com.maverick.ssh2.Ssh2PasswordAuthentication
- All Implemented Interfaces:
- AuthenticationClient, SshAuthentication
- public class Ssh2PasswordAuthentication
- extends PasswordAuthentication
- implements AuthenticationClient
Implements Password authentication as defined in the SSH Authenticaiton
Protocol. To use password authentication first construct an instance and
set the username and password fields.
PasswordAuthentication pwd = new PasswordAuthentication();
pwd.setUsername("username");
pwd.setPassword("password");
int result = ssh.authenticate(pwd);
When the authentication returns the result should be evaluated. If the
authentication has completed no further processing is required, however
if the result is failed you should check the password change flag to
determine if the attempt failed because the user is required to change
their password. If this is required set the new password on the instance using
setNewPassword and call the
authentication procedure again. If the authenticaiton fails again the password
may not be acceptable.
if(result==SshAuthentication.FAILED) {
if(pwd.requiresPasswordChange()) {
pwd.setNewPassword("foo");
// Perform authentication again
result = ssh.authenticate(pwd);
}
}
- Author:
- Lee David Painter
Method Summary |
void |
authenticate(AuthenticationProtocol authentication,
java.lang.String servicename)
Implementaion of the authentication method. |
boolean |
requiresPasswordChange()
Indicates whether the users password requires changing. |
void |
setNewPassword(java.lang.String newpassword)
After performing an initial authentication attempt a flag may be
set to indicate that a password change is required. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Ssh2PasswordAuthentication
public Ssh2PasswordAuthentication()
- Construct the method
setNewPassword
public void setNewPassword(java.lang.String newpassword)
- After performing an initial authentication attempt a flag may be
set to indicate that a password change is required. Use this method
to set the new password and retry the authentication attempt.
- Parameters:
newpassword
-
requiresPasswordChange
public boolean requiresPasswordChange()
- Indicates whether the users password requires changing. This will always
return
false
untill after an initial authentication attempt.
Then it MAY be true
so should always be checked upon a failed
attempt.
- Returns:
true
if the user must change their password otherwise
false
.
authenticate
public void authenticate(AuthenticationProtocol authentication,
java.lang.String servicename)
throws SshException,
com.maverick.ssh2.AuthenticationResult
- Implementaion of the authentication method.
- Specified by:
authenticate
in interface AuthenticationClient
- Parameters:
authentication
- servicename
-
- Throws:
java.io.IOException
AuthenticationResult
SshException
Copyright © 2003 3SP LTD. All Rights Reserved.