Interface Authenticator


public interface Authenticator
An authenticator.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    default Optional<String>
    Returns the client type for which to use this authenticator.
    default void
    Disposes of all resources used by this authenticator, after a call to this method the authenticator should be regarded as unusable.
    Performs login validation for the user specified by the remote session and returns a remote session with the same connectionId and user but possibly a different databaseUser to propagate to further login procedures.
    default void
    Called after the given session has been disconnected
  • Method Details

    • clientType

      default Optional<String> clientType()
      Returns the client type for which to use this authenticator. If none is specified, this authenticator is shared between all client types.

      Note that the client type is the client's own claim, so a client claiming another one is not authenticated by this authenticator. A server with authenticators therefore refuses a connection passing none of them, unless its client type is exempt, see ServerConfiguration.AUTHENTICATOR_EXEMPTIONS.

      Returns:
      the String identifying the client type for which to use this authenticator or an empty optional in case this authenticator should be shared
    • login

      Performs login validation for the user specified by the remote session and returns a remote session with the same connectionId and user but possibly a different databaseUser to propagate to further login procedures.

      Called once per session, that is, once per connection: a client holding more than one connection logs in once for each and is logged out once for each, so an authenticator keeping state per user, a licence seat say, should expect several sessions per user.

      The returned session must be for the same connection as the one received, the server rejecting the login otherwise; RemoteSession.withDatabaseUser(User) guarantees that.

      Parameters:
      session - the session
      Returns:
      a new session with the same connectionId but not necessarily the same databaseUser
      Throws:
      LoginException - in case the login fails
      See Also:
    • logout

      default void logout(RemoteSession session)
      Called after the given session has been disconnected
      Parameters:
      session - the remote session
    • close

      default void close()
      Disposes of all resources used by this authenticator, after a call to this method the authenticator should be regarded as unusable. This method should be called by a server using this authenticator on shutdown, giving the authenticator a chance to release resources in an orderly manner. Any exception thrown by this method is logged and ignored.
    • authenticators

      static List<Authenticator> authenticators()
      Returns:
      a list containing all the authenticators registered with ServiceLoader.