com.mindbright.ssh2
Class SSH2AuthPassword

java.lang.Object
  extended bycom.mindbright.ssh2.SSH2AuthPassword
All Implemented Interfaces:
SSH2AuthModule

public class SSH2AuthPassword
extends java.lang.Object
implements SSH2AuthModule

This class implements a module for password authentication as defined in the userauth protocol spec. It can either be used passively (i.e. the password is known beforehand), or it can be used interactively through the SSH2Interactor callback interface.

See Also:
SSH2AuthModule

Field Summary
static java.lang.String STANDARD_NAME
           
 
Constructor Summary
SSH2AuthPassword(SSH2Interactor interactor, java.lang.String prompt)
          Creates an instance which will always query the user.
SSH2AuthPassword(SSH2Interactor interactor, java.lang.String prompt, java.lang.String password)
          Creates an instance which will first test with the given password.
SSH2AuthPassword(java.lang.String password)
          Creates an instance which will never query the user.
 
Method Summary
 void clearSensitiveData()
          Clean up any sensitive data in this authentication module.
protected  java.lang.String getNewPassword(java.lang.String prompt, java.lang.String language)
           
protected  java.lang.String getPassword()
           
 java.lang.String getStandardName()
          Should give the standard name of this module as used in the userauth protocol.
 SSH2TransportPDU processMethodMessage(SSH2UserAuth userAuth, SSH2TransportPDU pdu)
          Processes the given method specific packet and returns a new packet which will be sent to peer to continue the authentication.
 boolean retryPointless()
          Returns true if there is not any point in trying this method again after it has failed once.
 void setNewPassword(java.lang.String newPassword)
           
 void setPassword(java.lang.String password)
           
 SSH2TransportPDU startAuthentication(SSH2UserAuth userAuth)
          Starts the execution of this module, called from the given SSH2UserAuth.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_NAME

public static final java.lang.String STANDARD_NAME
See Also:
Constant Field Values
Constructor Detail

SSH2AuthPassword

public SSH2AuthPassword(java.lang.String password)
Creates an instance which will never query the user. It will only use the given password. The password is only tried once, after that the module gives up.

Parameters:
password - Password to authenticate with once

SSH2AuthPassword

public SSH2AuthPassword(SSH2Interactor interactor,
                        java.lang.String prompt)
Creates an instance which will always query the user.

Parameters:
interactor - Interactor used to query the user
prompt - The prompt which will be shown to the user

SSH2AuthPassword

public SSH2AuthPassword(SSH2Interactor interactor,
                        java.lang.String prompt,
                        java.lang.String password)
Creates an instance which will first test with the given password. If that fails then the user will be queried interactively.

Parameters:
interactor - Interactor used to query the user
prompt - The prompt which will be shown to the user
password - Password to try to authenticate with once
Method Detail

setPassword

public void setPassword(java.lang.String password)

setNewPassword

public void setNewPassword(java.lang.String newPassword)

getPassword

protected java.lang.String getPassword()
                                throws SSH2UserCancelException
Throws:
SSH2UserCancelException

getNewPassword

protected java.lang.String getNewPassword(java.lang.String prompt,
                                          java.lang.String language)
                                   throws SSH2UserCancelException
Throws:
SSH2UserCancelException

getStandardName

public java.lang.String getStandardName()
Description copied from interface: SSH2AuthModule
Should give the standard name of this module as used in the userauth protocol.

Specified by:
getStandardName in interface SSH2AuthModule
Returns:
the standard name of the module

processMethodMessage

public SSH2TransportPDU processMethodMessage(SSH2UserAuth userAuth,
                                             SSH2TransportPDU pdu)
                                      throws SSH2UserCancelException
Description copied from interface: SSH2AuthModule
Processes the given method specific packet and returns a new packet which will be sent to peer to continue the authentication.

Specified by:
processMethodMessage in interface SSH2AuthModule
Parameters:
userAuth - the authentication layer responsible
pdu - the method specific packet
Returns:
the new packet to send to peer, or null if no packet should be sent.
Throws:
SSH2UserCancelException

startAuthentication

public SSH2TransportPDU startAuthentication(SSH2UserAuth userAuth)
                                     throws SSH2UserCancelException
Description copied from interface: SSH2AuthModule
Starts the execution of this module, called from the given SSH2UserAuth.

Specified by:
startAuthentication in interface SSH2AuthModule
Parameters:
userAuth - the authentication layer responsible
Returns:
the packet which starts this authentication method (i.e. when sent to peer)
Throws:
SSH2UserCancelException

clearSensitiveData

public void clearSensitiveData()
Description copied from interface: SSH2AuthModule
Clean up any sensitive data in this authentication module. This should be called once the authentication is done.

Specified by:
clearSensitiveData in interface SSH2AuthModule

retryPointless

public boolean retryPointless()
Description copied from interface: SSH2AuthModule
Returns true if there is not any point in trying this method again after it has failed once.

Specified by:
retryPointless in interface SSH2AuthModule