public class

UserAuthImpl

extends AbstractService
implements UserAuth
java.lang.Object
   ↳ net.schmizz.sshj.AbstractService
     ↳ net.schmizz.sshj.userauth.UserAuthImpl

Class Overview

UserAuth implementation.

Summary

Fields
private Set<String> allowedMethods
private final Event<UserAuthException> authenticated
private String banner
private AuthMethod currentMethod
private boolean partialSuccess
private final Deque<UserAuthException> savedEx
[Expand]
Inherited Fields
From class net.schmizz.sshj.AbstractService
Public Constructors
UserAuthImpl(Transport trans)
Public Methods
synchronized 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).
synchronized 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.
[Expand]
Inherited Methods
From class net.schmizz.sshj.AbstractService
From class java.lang.Object
From interface net.schmizz.sshj.Service
From interface net.schmizz.sshj.common.ErrorNotifiable
From interface net.schmizz.sshj.common.SSHPacketHandler
From interface net.schmizz.sshj.userauth.UserAuth

Fields

private Set<String> allowedMethods

private final Event<UserAuthException> authenticated

private String banner

private AuthMethod currentMethod

private boolean partialSuccess

private final Deque<UserAuthException> savedEx

Public Constructors

public UserAuthImpl (Transport trans)

Parameters
trans

Public Methods

public synchronized 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

public 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 synchronized Deque<UserAuthException> getSavedExceptions ()

public boolean hadPartialSuccess ()

public void handle (Message msg, SSHPacket buf)

Delegate handling of some SSH packet to this object.

Parameters
msg The SSH message identifier
buf SSHPacket containing rest of the request
Throws
SSHException

public void notifyError (SSHException error)

Notifies this object of an error.

Parameters
error