com.holonplatform.auth

## Interface AuthenticationToken

- All Superinterfaces:
    CredentialsContainer, Serializable
  All Known Implementing Classes:
    AccountCredentialsToken, BearerAuthenticationToken

      public interface AuthenticationToken
      extends CredentialsContainer, Serializable

  Represents the token for an authentication request, to be processed by `Authenticator.authenticate(AuthenticationToken)` to obtain a valid `Authentication` for a principal (for example a user).

  Because applications represent user data and credentials in different ways, implementations of this interface are application-specific.

  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `AuthenticationToken.AuthenticationTokenResolver<R extends Message>` Resolver to obtain an `AuthenticationToken` from an authentication request using a generic `Message`.

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

      `CredentialsContainer.CredentialsMatcher`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AuthenticationToken` | `accountCredentials(String accountId, String secret)` Create a basic `AuthenticationToken` to represent a generic account authentication.
    `static AuthenticationToken` | `bearer(String token)` Create an `AuthenticationToken` to represent a `HttpHeaders.SCHEME_BEARER` token authentication.
    `Object` | `getCredentials()` Returns the credentials submitted during the authentication process that verifies the submitted `getPrincipal()` account identity.
    `Object` | `getPrincipal()` Get the principal to which this authentication token refers, i.e. the account identity submitted during the authentication process.
    `static AuthenticationToken.AuthenticationTokenResolver<HttpRequest>` | `httpBasicResolver()` Build a default `AuthenticationToken.AuthenticationTokenResolver` for HTTP BASIC authentication scheme.
    `static AuthenticationToken.AuthenticationTokenResolver<HttpRequest>` | `httpBearerResolver()` Build a default `AuthenticationToken.AuthenticationTokenResolver` for HTTP BEARER authentication scheme.

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

      `defaultMatcher`

- - ### Method Detail

    - #### getPrincipal

          Object getPrincipal()

      Get the principal to which this authentication token refers, i.e. the account identity submitted during the authentication process.
      Returns:
        Principal to authenticate (for example a username)

    - #### getCredentials

          Object getCredentials()

      Returns the credentials submitted during the authentication process that verifies the submitted `getPrincipal()` account identity.
      Specified by:
        `getCredentials` in interface `CredentialsContainer`
      Returns:
        the credential submitted by the user during the authentication process

    - #### accountCredentials

          static AuthenticationToken accountCredentials(String accountId,
                                                        String secret)

      Create a basic `AuthenticationToken` to represent a generic account authentication. Account is identified by an id and a secret (of String type).

      This AuthenticationToken could for example represent the widely-used user authentication mechanism providing username and password.

      Parameters:
        `accountId` - Account id
        `secret` - Secret (for example a password)
      Returns:
        AuthenticationToken

    - #### bearer

          static AuthenticationToken bearer(String token)

      Create an `AuthenticationToken` to represent a `HttpHeaders.SCHEME_BEARER` token authentication.
      Parameters:
        `token` - Bearer token value
      Returns:
        AuthenticationToken

    - #### httpBasicResolver

          static AuthenticationToken.AuthenticationTokenResolver<HttpRequest> httpBasicResolver()

      Build a default `AuthenticationToken.AuthenticationTokenResolver` for HTTP BASIC authentication scheme.
      Returns:
        BASIC `AuthenticationToken.AuthenticationTokenResolver`

    - #### httpBearerResolver

          static AuthenticationToken.AuthenticationTokenResolver<HttpRequest> httpBearerResolver()

      Build a default `AuthenticationToken.AuthenticationTokenResolver` for HTTP BEARER authentication scheme.
      Returns:
        BEARER `AuthenticationToken.AuthenticationTokenResolver`

Copyright © 2017 The Holon Platform. All rights reserved.