com.holonplatform.auth.internal

## Class AccountAuthenticator

- java.lang.Object
- - com.holonplatform.auth.internal.AccountAuthenticator

- All Implemented Interfaces:
    Authenticator<AccountCredentialsToken>

      public class AccountAuthenticator
      extends Object
      implements Authenticator<AccountCredentialsToken>

  `Authenticator` which uses an `Account.AccountProvider` to load `Account` data for authentication and a `CredentialsContainer.CredentialsMatcher` for credentials validation.

  This Authenticator supports `AccountCredentialsToken` token type.

  Since:
    5.0.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.holonplatform.auth.Authenticator

      `Authenticator.MessageAuthenticator`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AccountAuthenticator(Account.AccountProvider accountService)` Constructor using default `CredentialsContainer.CredentialsMatcher`
    `AccountAuthenticator(Account.AccountProvider accountService, CredentialsContainer.CredentialsMatcher credentialsMatcher)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Authentication` | `authenticate(AccountCredentialsToken authenticationToken)` Attempts to perform authentication using given `AuthenticationToken`.
    `Account.AccountProvider` | `getAccountService()` Account service to load `Account` data
    `CredentialsContainer.CredentialsMatcher` | `getCredentialsMatcher()` CredentialsMatcher to use for AuthenticationToken credentials validation
    `Class<? extends AccountCredentialsToken>` | `getTokenType()` Get supported `AuthenticationToken` type

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.auth.Authenticator

      `create`

- - ### Constructor Detail

    - #### AccountAuthenticator

          public AccountAuthenticator(Account.AccountProvider accountService)

      Constructor using default `CredentialsContainer.CredentialsMatcher`
      Parameters:
        `accountService` - Account service to load `Account` data (not null)

    - #### AccountAuthenticator

          public AccountAuthenticator(Account.AccountProvider accountService,
                                      CredentialsContainer.CredentialsMatcher credentialsMatcher)

      Constructor
      Parameters:
        `accountService` - Account service to load `Account` data (not null)
        `credentialsMatcher` - CredentialsMatcher to use for AuthenticationToken credentials validation

  - ### Method Detail

    - #### getAccountService

          public Account.AccountProvider getAccountService()

      Account service to load `Account` data
      Returns:
        Account service

    - #### getCredentialsMatcher

          public CredentialsContainer.CredentialsMatcher getCredentialsMatcher()

      CredentialsMatcher to use for AuthenticationToken credentials validation
      Returns:
        CredentialsMatcher

    - #### getTokenType

          public Class<? extends AccountCredentialsToken> getTokenType()

      Description copied from interface: `Authenticator`
      Get supported `AuthenticationToken` type
      Specified by:
        `getTokenType` in interface `Authenticator<AccountCredentialsToken>`
      Returns:
        Supported `AuthenticationToken` type

    - #### authenticate

          public Authentication authenticate(AccountCredentialsToken authenticationToken)
                                      throws AuthenticationException

      Description copied from interface: `Authenticator`
      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.

      Specified by:
        `authenticate` in interface `Authenticator<AccountCredentialsToken>`
      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`

Copyright © 2019 The Holon Platform. All rights reserved.