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);
}
}
CANCELLED, COMPLETE, FAILED, FURTHER_AUTHENTICATION_REQUIRED, PUBLIC_KEY_ACCEPTABLE| Constructor and Description |
|---|
Ssh2PasswordAuthentication()
Construct the method
|
Ssh2PasswordAuthentication(String password) |
| Modifier and Type | Method and Description |
|---|---|
void |
authenticate(AuthenticationProtocol authentication,
String servicename)
Implementation of the authentication method.
|
boolean |
requiresPasswordChange()
Indicates whether the users password requires changing.
|
void |
setNewPassword(String newpassword)
After performing an initial authentication attempt a flag may be set to
indicate that a password change is required.
|
getMethod, getPassword, getUsername, setPassword, setUsernameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMethod, getUsername, setUsernamepublic Ssh2PasswordAuthentication()
public Ssh2PasswordAuthentication(String password)
public void setNewPassword(String newpassword)
newpassword - public boolean requiresPasswordChange()
false until after an initial authentication attempt.
Then it MAY be true so should always be checked upon a
failed attempt.true if the user must change their password
otherwise false.public void authenticate(AuthenticationProtocol authentication, String servicename) throws SshException, AuthenticationResult
authenticate in interface AuthenticationClientauthentication - servicename - IOExceptionAuthenticationResultSshExceptionCopyright © 2025. All rights reserved.