com.holonplatform.auth

## Interface Authenticator.MessageAuthenticator

- All Known Subinterfaces:
    Realm
  Enclosing interface:
    Authenticator<T extends AuthenticationToken>

      public static interface Authenticator.MessageAuthenticator

  Authenticator which support authentication using generic authentication request `Message`s.

  Authentication is performed using `AuthenticationToken.AuthenticationTokenResolver`s to parse request message into standard `AuthenticationToken`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAuthenticationTokenResolver(AuthenticationToken.AuthenticationTokenResolver<?> authenticationTokenResolver)` Add an `AuthenticationToken.AuthenticationTokenResolver` to translate messages into `AuthenticationToken`s.
    `Authentication` | `authenticate(Message<?,?> message, String... schemes)` Try to authenticate given `message` with the same contract as `Authenticator.authenticate(AuthenticationToken)`.
    `<T extends Message> List<AuthenticationToken.AuthenticationTokenResolver<T>>` | `getResolversForMessageType(Class<T> messageType)` Get available `AuthenticationToken.AuthenticationTokenResolver`s for given message type
    `boolean` | `supportsMessage(Class<? extends Message<?,?>> messageType)` Check whether this MessageAuthenticator supports given message type

- - ### Method Detail

    - #### addAuthenticationTokenResolver

          void addAuthenticationTokenResolver(AuthenticationToken.AuthenticationTokenResolver<?> authenticationTokenResolver)

      Add an `AuthenticationToken.AuthenticationTokenResolver` to translate messages into `AuthenticationToken`s.
      Parameters:
        `authenticationTokenResolver` - The `AuthenticationToken.AuthenticationTokenResolver` to add (not null)

    - #### supportsMessage

          boolean supportsMessage(Class<? extends Message<?,?>> messageType)

      Check whether this MessageAuthenticator supports given message type
      Parameters:
        `messageType` - Message type to check
      Returns:
        `true` if message type is supported

    - #### getResolversForMessageType

          <T extends Message> List<AuthenticationToken.AuthenticationTokenResolver<T>> getResolversForMessageType(Class<T> messageType)

      Get available `AuthenticationToken.AuthenticationTokenResolver`s for given message type
      Type Parameters:
        `T` - Message type
      Parameters:
        `messageType` - Message type
      Returns:
        List of AuthenticationTokenResolvers, in the order they were registered, or an empty list if none available

    - #### authenticate

          Authentication authenticate(Message<?,?> message,
                                      String... schemes)
                               throws AuthenticationException

      Try to authenticate given `message` with the same contract as `Authenticator.authenticate(AuthenticationToken)`.

      Message-based authentication is performed using a resolvers chain: all available resolvers for given message type are called in the order they where registered, and the first not null `AuthenticationToken` returned by a resolver is used for attempting authentication.

      Parameters:
        `message` - Request message
        `schemes` - Optional authentication schemes to use. If not null or empty, only `AuthenticationToken.AuthenticationTokenResolver`s bound to given scheme names will be used
      Returns:
        the Authentication that represents principal's account and authorization data
      Throws:
        `AuthenticationException` - Authentication failed

Copyright © 2019 The Holon Platform. All rights reserved.