com.h3c.util.rs.auth

## Class AbstractTokenAuthFilter

- java.lang.Object
- - com.h3c.util.rs.auth.AbstractTokenAuthFilter

- All Implemented Interfaces:
    javax.servlet.Filter

      public abstract class AbstractTokenAuthFilter
      extends Object
      implements javax.servlet.Filter

  A token-based authentication filter. This filter uses `AuthenticationService` to authenticate the request by validating the token, expected to be present as a value of the header parameter `AuthConstants.TOKEN`.

  Upon successful validation, all authentication data will be injected into the request as parameters and will be passed downstream. This authentication data includes information such as domain, user and user roles. The `AuthConstants.AUTH_IDENTITY_STATUS` request parameter will be set to `AuthConstants.AUTH_IDENTITY_CONFIRMED`.

  If token validation fails, or if no token is present, the `AuthConstants.AUTH_IDENTITY_STATUS` request parameter will be set to `AuthConstants.AUTH_IDENTITY_INVALID`. It is up to the downstream filter to allow an invalid identity status or not.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractTokenAuthFilter(org.slf4j.Logger log)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract AuthenticationService` | `authenticator()` Get the authenticator to be used for validating the token.
    `void` | `destroy()`
    `void` | `doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp, javax.servlet.FilterChain chain)`
    `void` | `init(javax.servlet.FilterConfig filterConfig)`

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

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

- - ### Constructor Detail

    - #### AbstractTokenAuthFilter

          protected AbstractTokenAuthFilter(org.slf4j.Logger log)

  - ### Method Detail

    - #### init

          public void init(javax.servlet.FilterConfig filterConfig)
                    throws javax.servlet.ServletException

      Specified by:
        `init` in interface `javax.servlet.Filter`
      Throws:
        `javax.servlet.ServletException`

    - #### destroy

          public void destroy()

      Specified by:
        `destroy` in interface `javax.servlet.Filter`

    - #### authenticator

          protected abstract AuthenticationService authenticator()

      Get the authenticator to be used for validating the token.
      Returns:
        authentication service; null if none available at the time of request

    - #### doFilter

          public void doFilter(javax.servlet.ServletRequest req,
                      javax.servlet.ServletResponse resp,
                      javax.servlet.FilterChain chain)
                        throws IOException,
                               javax.servlet.ServletException

      Specified by:
        `doFilter` in interface `javax.servlet.Filter`
      Throws:
        `IOException`
        `javax.servlet.ServletException`

Copyright © 2014. All Rights Reserved.