Class ClientUserAuthService

All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ClientSessionHolder, Closeable, PropertyResolver, Service, SessionContextHolder, SessionHolder<Session>

public class ClientUserAuthService extends AbstractCloseable implements Service, ClientSessionHolder
Client side ssh-auth service.
  • Field Details

    • authFutureHolder

      protected final AtomicReference<AuthFuture> authFutureHolder
      The AuthFuture that is being used by the current auth request. It is set while an authentication is ongoing.
    • clientSession

      protected final ClientSessionImpl clientSession
    • authFactories

      protected final List<UserAuthFactory> authFactories
    • clientMethods

      protected final List<String> clientMethods
    • serverMethods

      protected List<String> serverMethods
    • properties

      private final Map<String,Object> properties
    • service

      private String service
    • currentUserAuth

      private UserAuth currentUserAuth
    • currentMethod

      private int currentMethod
    • pubkeyAuth

      private UserAuth pubkeyAuth
    • initLock

      private final Object initLock
    • started

      private boolean started
    • initialRequestSender

      private Runnable initialRequestSender
  • Constructor Details

    • ClientUserAuthService

      public ClientUserAuthService(Session s)
  • Method Details

    • getSession

      public ClientSession getSession()
      Specified by:
      getSession in interface SessionHolder<Session>
    • getClientSession

      public ClientSession getClientSession()
      Specified by:
      getClientSession in interface ClientSessionHolder
      Returns:
      The underlying ClientSession used
    • getProperties

      public Map<String,Object> getProperties()
      Description copied from interface: PropertyResolver

      A map of properties that can be used to configure the SSH server or client. This map will never be changed by either the server or client and is not supposed to be changed at runtime (changes are not bound to have any effect on a running client or server), though it may affect the creation of sessions later as these values are usually not cached.

      Note: the type of the mapped property should match the expected configuration value type - Long, Integer, Boolean, String, etc.... If it doesn't, the toString() result of the mapped value is used to convert it to the required type. E.g., if the mapped value is the string "1234" and the expected value is a long then it will be parsed into one. Also, if the mapped value is an Integer but a long is expected, then it will be converted into one.

      Specified by:
      getProperties in interface PropertyResolver
      Returns:
      a valid Map containing configuration values, never null. Note: may be immutable.
    • start

      public void start()
      Specified by:
      start in interface Service
    • getCurrentServiceName

      public String getCurrentServiceName()
    • auth

      public AuthFuture auth(String service) throws IOException
      Throws:
      IOException
    • updateCurrentAuthFuture

      protected AuthFuture updateCurrentAuthFuture(ClientSession session, String service) throws IOException
      Throws:
      IOException
    • createAuthFuture

      protected AuthFuture createAuthFuture(ClientSession session, String service) throws IOException
      Throws:
      IOException
    • sendInitialAuthRequest

      protected IoWriteFuture sendInitialAuthRequest(ClientSession session, String service) throws IOException
      Throws:
      IOException
    • process

      public void process(int cmd, Buffer buffer) throws Exception
      Description copied from interface: Service
      Service the request.
      Specified by:
      process in interface Service
      Parameters:
      cmd - The incoming command type
      buffer - The Buffer containing optional command parameters
      Throws:
      Exception - If failed to process the command
    • processUserAuth

      protected void processUserAuth(int cmd, Buffer buffer, AuthFuture authFuture) throws Exception
      Execute one step in user authentication.
      Parameters:
      cmd - the command
      buffer - the input Buffer, with the reading position after the command byte
      authFuture - the AuthFuture
      Throws:
      Exception - If failed to process
    • tryNext

      protected void tryNext(int cmd, AuthFuture authFuture) throws Exception
      Throws:
      Exception
    • clearUserAuth

      private void clearUserAuth()
    • destroyUserAuth

      private void destroyUserAuth()
    • destroyPubkeyAuth

      private void destroyPubkeyAuth()
    • preClose

      protected void preClose()
      Description copied from class: AbstractCloseable
      preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true
      Overrides:
      preClose in class AbstractCloseable