com.holonplatform.jaxrs.server.auth

## Class AuthenticationFeature

- java.lang.Object
- - com.holonplatform.jaxrs.server.auth.AuthenticationFeature

- All Implemented Interfaces:
    javax.ws.rs.core.Feature

      public class AuthenticationFeature
      extends Object
      implements javax.ws.rs.core.Feature

  A JAX-RS `Feature` which can be registered in server application to enable authentication support using `Authenticate` annotation.

  JAX-RS resource classes and/or methods annotated with `Authenticate` will be protected from unauthorized access, performing client authentication using the `AuthContext` security context `Realm`.

  Using this feature, the `SecurityContext` of the JAX-RS requests bound to `Authenticate` annotated resources will be replaced with an `AuthContext` compatible implementation and will be used to perform authentication when required.

  Allowed authentication schemes can be specified using `Authenticate.schemes()` annotation attribute. If any scheme is specified, a scheme-matching `AuthenticationToken.AuthenticationTokenResolver` must be registered in `Realm` to perform authentication with given scheme.

  The `Realm` to use is obtained either from a registered `ContextResolver` of `Realm` type, if available, or as a `Context` resource using `Realm.getCurrent()`.

  When authentication informations provided by a client according to allowed authentication schemes (if any) for an `Authenticate` resource are missing or invalid, a `401 - Unauthorized` status response is returned, including a `HttpHeaders.WWW_AUTHENTICATE` header for each allowed authentication scheme, if any.

  Since:
    5.0.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `AUTH_CONTEXT_PROPERTY_NAME` Current request `AuthContext` reference property name
    `static String` | `DISABLE_AUTHENTICATION` JAX-RS configuration property name to put in the application configuration to disable the `AuthenticationFeature` registration.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AuthenticationFeature()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `configure(javax.ws.rs.core.FeatureContext context)`

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

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

- - ### Field Detail

    - #### DISABLE_AUTHENTICATION

          public static final String DISABLE_AUTHENTICATION

      JAX-RS configuration property name to put in the application configuration to disable the `AuthenticationFeature` registration.
      See Also:
        Constant Field Values

    - #### AUTH_CONTEXT_PROPERTY_NAME

          public static final String AUTH_CONTEXT_PROPERTY_NAME

      Current request `AuthContext` reference property name

  - ### Constructor Detail

    - #### AuthenticationFeature

          public AuthenticationFeature()

  - ### Method Detail

    - #### configure

          public boolean configure(javax.ws.rs.core.FeatureContext context)

      Specified by:
        `configure` in interface `javax.ws.rs.core.Feature`

Copyright © 2019 The Holon Platform. All rights reserved.