net.schmizz.sshj.userauth
Class UserAuthImpl

java.lang.Object
  extended by net.schmizz.sshj.AbstractService
      extended by 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, timeout, trans
 
Constructor Summary
UserAuthImpl(Transport trans)
           
 
Method Summary
 void authenticate(String username, Service nextService, Iterable<AuthMethod> methods)
          Attempt to authenticate username using each of methods in order.
 String getBanner()
          Returns the authentication banner (if any).
 Deque<UserAuthException> getSavedExceptions()
           
 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 an error.
 
Methods inherited from class net.schmizz.sshj.AbstractService
getName, getTimeout, notifyUnimplemented, request, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.schmizz.sshj.userauth.UserAuth
getTimeout, setTimeout
 

Constructor Detail

UserAuthImpl

public UserAuthImpl(Transport trans)
Method Detail

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 authenticate
nextService - the service to set on successful authentication
methods - 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.