public interface

UserAuth

net.schmizz.sshj.userauth.UserAuth
Known Indirect Subclasses

Class Overview

User authentication API. See RFC 4252.

Summary

Public Methods
abstract void authenticate(String username, Service nextService, Iterable<AuthMethod> methods)
Attempt to authenticate username using each of methods in order.
abstract String getBanner()
Returns the authentication banner (if any).
abstract Deque<UserAuthException> getSavedExceptions()
abstract int getTimeout()
abstract boolean hadPartialSuccess()
abstract void setTimeout(int timeout)
Set the timeout for any method to successfully authenticate before it is abandoned.

Public Methods

public abstract void authenticate (String username, Service nextService, Iterable<AuthMethod> methods)

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 getSavedExceptions().

Further attempts may also be made by catching UserAuthException and retrying with this method.

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

public abstract String getBanner ()

Returns the authentication banner (if any). In some cases this is available even before the first authentication request has been made.

Returns
  • the banner, or an empty string if none was received

public abstract Deque<UserAuthException> getSavedExceptions ()

Returns
  • saved exceptions that might have been ignored because there were more authentication method available.

public abstract int getTimeout ()

Returns
  • the timeout for a method to successfully authenticate before it is abandoned.

public abstract boolean hadPartialSuccess ()

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.

public abstract void setTimeout (int timeout)

Set the timeout for any method to successfully authenticate before it is abandoned.

Parameters
timeout The timeout in seconds