Class UserAuthImpl
java.lang.Object
net.schmizz.sshj.AbstractService
net.schmizz.sshj.userauth.UserAuthImpl
- All Implemented Interfaces:
ErrorNotifiable, SSHPacketHandler, Service, UserAuth
UserAuth implementation.-
Nested Class Summary
Nested classes/interfaces inherited from interface ErrorNotifiable
ErrorNotifiable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Promise<Boolean, UserAuthException> private Stringprivate AuthMethodprivate Serviceprivate booleanFields inherited from class AbstractService
log, name, trans -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticate(String username, Service nextService, AuthMethod method, int timeoutMs) Attempt to authenticateusernameusing each ofmethodsin order.The available authentication methods.Returns the authentication banner (if any).booleanvoidDelegate handling of some SSH packet to this object.private AuthParamsmakeAuthParams(String username, Service nextService) voidnotifyError(SSHException error) Notifies this object of anerror.Methods inherited from class AbstractService
getName, notifyUnimplemented, request
-
Field Details
-
authenticated
-
banner
-
partialSuccess
private volatile boolean partialSuccess -
allowedMethods
-
currentMethod
-
nextService
-
-
Constructor Details
-
UserAuthImpl
-
-
Method Details
-
authenticate
public boolean authenticate(String username, Service nextService, AuthMethod method, int timeoutMs) throws UserAuthException, TransportException Description copied from interface:UserAuthAttempt to authenticateusernameusing each ofmethodsin order.nextServiceis theServicethat will be enabled on successful authentication. Authentication fails if there are no method available, i.e. if all the method failed or there were method available but could not be attempted because the server did not allow them. Further attempts may also be made by catchingUserAuthExceptionand retrying with this method.- Specified by:
authenticatein interfaceUserAuth- Parameters:
username- the user to authenticatenextService- the service to set on successful authenticationmethod- theAuthMethod's to try- Returns:
- whether authentication was successful
- Throws:
UserAuthException- in case of authentication failureTransportException- if there was a transport-layer error
-
getBanner
Description copied from interface:UserAuthReturns the authentication banner (if any). In some cases this is available even before the first authentication request has been made. -
hadPartialSuccess
public boolean hadPartialSuccess()- Specified by:
hadPartialSuccessin interfaceUserAuth- Returns:
- whether authentication was partially successful. Some server's may be configured to require multiple
authentications; and this value will be
trueif at least one of the method supplied succeeded.
-
getAllowedMethods
Description copied from interface:UserAuthThe available authentication methods. This is only defined once an unsuccessful authentication has taken place.- Specified by:
getAllowedMethodsin interfaceUserAuth
-
handle
Description copied from interface:SSHPacketHandlerDelegate handling of some SSH packet to this object.- Specified by:
handlein interfaceSSHPacketHandler- Overrides:
handlein classAbstractService- Parameters:
msg- the SSHmessage identifierbuf-SSHPacketcontaining rest of the request- Throws:
SSHException- if there is a non-recoverable error
-
notifyError
Description copied from interface:ErrorNotifiableNotifies this object of anerror.- Specified by:
notifyErrorin interfaceErrorNotifiable- Overrides:
notifyErrorin classAbstractService
-
makeAuthParams
-