com.holonplatform.auth

## Interface Authenticator<T extends AuthenticationToken>

- Type Parameters:
    `T` - Supported token type
  All Known Subinterfaces:
    JwtAuthenticator, Realm
  All Known Implementing Classes:
    AbstractAuthenticationManagerAuthenticator, AccountAuthenticator, AccountCredentialsAuthenticationManagerAuthenticator, DefaultAuthenticationManagerAuthenticator, DefaultCallbackAuthenticator, DefaultJwtAuthenticator, DefaultRealm

      public interface Authenticator<T extends AuthenticationToken>

  Authenticator is responsible for authenticating accounts using an `AuthenticationToken`.

  Every Authenticator declares supported `AuthenticationToken` type though `getTokenType()` method.

  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `Authenticator.MessageAuthenticator` Authenticator which support authentication using generic authentication request `Message`s.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Authentication` | `authenticate(T authenticationToken)` Attempts to perform authentication using given `AuthenticationToken`.
    `static <T extends AuthenticationToken> Authenticator<T>` | `create(Class<? extends T> tokenType, Function<T,Authentication> authenticationFunction)` Create an `Authenticator` bound to the given token type and which uses the provided callback `Function` to perform the authentication strategy.
    `Class<? extends T>` | `getTokenType()` Get supported `AuthenticationToken` type

- - ### Method Detail

    - #### getTokenType

          Class<? extends T> getTokenType()

      Get supported `AuthenticationToken` type
      Returns:
        Supported `AuthenticationToken` type

    - #### authenticate

          Authentication authenticate(T authenticationToken)
                               throws AuthenticationException

      Attempts to perform authentication using given `AuthenticationToken`.

      If the authentication is successful, an `Authentication` instance is returned that represents the user's account data and provides authorization operations.

      If authentication is not successful, a suitable exception should be thrown. See the specific exceptions listed below for builtin available authentication errors.

      Parameters:
        `authenticationToken` - the authentication request token
      Returns:
        the Authentication that represents principal's account and authorization data
      Throws:
        `AuthenticationException` - Authentication failed
      See Also:
        `DisabledAccountException`, `LockedAccountException`, `UnknownAccountException`, `ExpiredCredentialsException`, `InvalidCredentialsException`, `UnsupportedTokenException`, `UnexpectedAuthenticationException`

    - #### create

          static <T extends AuthenticationToken> Authenticator<T> create(Class<? extends T> tokenType,
                                                                         Function<T,Authentication> authenticationFunction)

      Create an `Authenticator` bound to the given token type and which uses the provided callback `Function` to perform the authentication strategy. See `authenticate(AuthenticationToken)`.
      Type Parameters:
        `T` - Authentication token type
      Parameters:
        `tokenType` - Authentication token type (not null)
        `authenticationFunction` - Authentication strategy function (not null)
      Returns:
        The `Authenticator` instance

Copyright © 2019 The Holon Platform. All rights reserved.