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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UserAuthImpl
public UserAuthImpl(Transport trans)
authenticate
public void authenticate(String username,
Service nextService,
Iterable<AuthMethod> methods)
throws UserAuthException,
TransportException
- Description copied from interface:
UserAuth
- Attempt to authenticate
username
using each of methods
in order. nextService
is the
Service
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. In this case, a UserAuthException
is thrown with its cause as the last authentication failure. Other UserAuthException
's
which may have been ignored may be accessed via UserAuth.getSavedExceptions()
.
Further attempts may also be made by catching UserAuthException
and retrying with this method.
- Specified by:
authenticate
in interface UserAuth
- Parameters:
username
- the user to authenticatenextService
- the service to set on successful authenticationmethods
- the AuthMethod
's to try
- Throws:
UserAuthException
- in case of authentication failure
TransportException
- if there was a transport-layer error
getSavedExceptions
public Deque<UserAuthException> getSavedExceptions()
- Specified by:
getSavedExceptions
in interface UserAuth
- Returns:
- saved exceptions that might have been ignored because there were more authentication method available.
getBanner
public 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.
- Specified by:
getBanner
in interface UserAuth
- Returns:
- the banner, or an empty string if none was received
hadPartialSuccess
public boolean hadPartialSuccess()
- Specified by:
hadPartialSuccess
in interface UserAuth
- 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.
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 interface SSHPacketHandler
- Overrides:
handle
in class AbstractService
- Parameters:
msg
- the SSH message 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 an
error
.
- Specified by:
notifyError
in interface ErrorNotifiable
- Overrides:
notifyError
in class AbstractService
Copyright © 2009-2012. All Rights Reserved.