Class UserAuthPassword
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.client.auth.AbstractUserAuth
-
- org.apache.sshd.client.auth.password.UserAuthPassword
-
- All Implemented Interfaces:
UserAuth,ClientSessionHolder,UserAuthInstance<ClientSession>,NamedResource
public class UserAuthPassword extends AbstractUserAuth
Implements the client-side "password" authentication mechanism
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringcurrentprivate intmaxAttemptsstatic java.lang.StringNAMEprivate intnOfAttemptsprivate java.util.Iterator<java.lang.String>passwords-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
-
Constructor Summary
Constructors Constructor Description UserAuthPassword()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinit(ClientSession session, java.lang.String service)protected booleanprocessAuthDataRequest(ClientSession session, java.lang.String service, Buffer buffer)protected java.lang.StringresolveAttemptedPassword(ClientSession session, java.lang.String service)protected booleansendAuthDataRequest(ClientSession session, java.lang.String service)protected IoWriteFuturesendPassword(Buffer buffer, ClientSession session, java.lang.String oldPassword, java.lang.String newPassword)Sends the password via aSSH_MSG_USERAUTH_REQUESTmessage.voidsignalAuthMethodFailure(ClientSession session, java.lang.String service, boolean partial, java.util.List<java.lang.String> serverMethods, Buffer buffer)Signals reception ofSSH_MSG_USERAUTH_FAILUREmessagevoidsignalAuthMethodSuccess(ClientSession session, java.lang.String service, Buffer buffer)Signal reception ofSSH_MSG_USERAUTH_SUCCESSmessage-
Methods inherited from class org.apache.sshd.client.auth.AbstractUserAuth
destroy, getClientSession, getName, getService, getSession, isCancellable, process, setCancellable, toString
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
passwords
private java.util.Iterator<java.lang.String> passwords
-
current
private java.lang.String current
-
maxAttempts
private int maxAttempts
-
nOfAttempts
private int nOfAttempts
-
-
Method Detail
-
init
public void init(ClientSession session, java.lang.String service) throws java.lang.Exception
- Specified by:
initin interfaceUserAuth- Overrides:
initin classAbstractUserAuth- Parameters:
session- TheClientSessionservice- The requesting service name- Throws:
java.lang.Exception- If failed to initialize the mechanism
-
sendAuthDataRequest
protected boolean sendAuthDataRequest(ClientSession session, java.lang.String service) throws java.lang.Exception
- Specified by:
sendAuthDataRequestin classAbstractUserAuth- Throws:
java.lang.Exception
-
resolveAttemptedPassword
protected java.lang.String resolveAttemptedPassword(ClientSession session, java.lang.String service) throws java.lang.Exception
- Throws:
java.lang.Exception
-
processAuthDataRequest
protected boolean processAuthDataRequest(ClientSession session, java.lang.String service, Buffer buffer) throws java.lang.Exception
- Specified by:
processAuthDataRequestin classAbstractUserAuth- Throws:
java.lang.Exception
-
sendPassword
protected IoWriteFuture sendPassword(Buffer buffer, ClientSession session, java.lang.String oldPassword, java.lang.String newPassword) throws java.lang.Exception
Sends the password via aSSH_MSG_USERAUTH_REQUESTmessage. If old and new password are not the same then it requests a password modification from the server (which may be denied if the server does not support this feature).- Parameters:
buffer- TheBufferto re-use for sending the messagesession- The targetClientSessionoldPassword- The previous passwordnewPassword- The new password- Returns:
- An
IoWriteFuturethat can be used to wait and check on the success/failure of the request packet being sent - Throws:
java.lang.Exception- If failed to send the message.
-
signalAuthMethodSuccess
public void signalAuthMethodSuccess(ClientSession session, java.lang.String service, Buffer buffer) throws java.lang.Exception
Description copied from interface:UserAuthSignal reception ofSSH_MSG_USERAUTH_SUCCESSmessage- Parameters:
session- TheClientSessionservice- The requesting service namebuffer- TheBuffercontaining the success message (after having consumed the relevant data from it)- Throws:
java.lang.Exception- If failed to handle the callback - Note: may cause session close
-
signalAuthMethodFailure
public void signalAuthMethodFailure(ClientSession session, java.lang.String service, boolean partial, java.util.List<java.lang.String> serverMethods, Buffer buffer) throws java.lang.Exception
Description copied from interface:UserAuthSignals reception ofSSH_MSG_USERAUTH_FAILUREmessage- Parameters:
session- TheClientSessionservice- The requesting service namepartial-trueif some partial authentication success so farserverMethods- TheListof authentication methods that can continuebuffer- TheBuffercontaining the failure message (after having consumed the relevant data from it)- Throws:
java.lang.Exception- If failed to handle the callback - Note: may cause session close
-
-