Package net.schmizz.sshj.userauth
Class UserAuthImpl
- java.lang.Object
-
- net.schmizz.sshj.AbstractService
-
- net.schmizz.sshj.userauth.UserAuthImpl
-
- All Implemented Interfaces:
ErrorNotifiable
,SSHPacketHandler
,Service
,UserAuth
public class UserAuthImpl extends AbstractService implements UserAuth
UserAuth
implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
ErrorNotifiable.Util
-
-
Field Summary
-
Fields inherited from class net.schmizz.sshj.AbstractService
log, name, trans
-
-
Constructor Summary
Constructors Constructor Description UserAuthImpl(Transport trans)
-
Method Summary
Modifier and Type Method Description boolean
authenticate(java.lang.String username, Service nextService, AuthMethod method, int timeoutMs)
Attempt to authenticateusername
using each ofmethods
in order.java.util.Collection<java.lang.String>
getAllowedMethods()
The available authentication methods.java.lang.String
getBanner()
Returns the authentication banner (if any).boolean
hadPartialSuccess()
void
handle(Message msg, SSHPacket buf)
Delegate handling of some SSH packet to this object.void
notifyError(SSHException error)
Notifies this object of anerror
.-
Methods inherited from class net.schmizz.sshj.AbstractService
getName, notifyUnimplemented, request
-
-
-
-
Constructor Detail
-
UserAuthImpl
public UserAuthImpl(Transport trans)
-
-
Method Detail
-
authenticate
public boolean authenticate(java.lang.String username, Service nextService, AuthMethod method, int timeoutMs) throws UserAuthException, TransportException
Description copied from interface:UserAuth
Attempt to authenticateusername
using each ofmethods
in order.nextService
is theService
that 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 catchingUserAuthException
and retrying with this method.- Specified by:
authenticate
in 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
public java.lang.String getBanner()
Description copied from interface:UserAuth
Returns 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:
hadPartialSuccess
in interfaceUserAuth
- Returns:
- whether authentication was partially successful. Some server's may be configured to require multiple
authentications; and this value will be
true
if at least one of the method supplied succeeded.
-
getAllowedMethods
public java.util.Collection<java.lang.String> getAllowedMethods()
Description copied from interface:UserAuth
The available authentication methods. This is only defined once an unsuccessful authentication has taken place.- Specified by:
getAllowedMethods
in interfaceUserAuth
-
handle
public void handle(Message msg, SSHPacket buf) throws SSHException
Description copied from interface:SSHPacketHandler
Delegate handling of some SSH packet to this object.- Specified by:
handle
in interfaceSSHPacketHandler
- Overrides:
handle
in classAbstractService
- Parameters:
msg
- the SSHmessage identifier
buf
-SSHPacket
containing rest of the request- Throws:
SSHException
- if there is a non-recoverable error
-
notifyError
public void notifyError(SSHException error)
Description copied from interface:ErrorNotifiable
Notifies this object of anerror
.- Specified by:
notifyError
in interfaceErrorNotifiable
- Overrides:
notifyError
in classAbstractService
-
-