Class DelegationTokenAuthenticationHandler

java.lang.Object
org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationHandler
All Implemented Interfaces:
org.apache.hadoop.security.authentication.server.AuthenticationHandler
Direct Known Subclasses:
KerberosDelegationTokenAuthenticationHandler, MultiSchemeDelegationTokenAuthenticationHandler, PseudoDelegationTokenAuthenticationHandler

@Private @Evolving public abstract class DelegationTokenAuthenticationHandler extends Object implements org.apache.hadoop.security.authentication.server.AuthenticationHandler
An AuthenticationHandler that implements Kerberos SPNEGO mechanism for HTTP and supports Delegation Token functionality.

In addition to the wrapped AuthenticationHandler configuration properties, this handler supports the following properties prefixed with the type of the wrapped AuthenticationHandler:

  • delegation-token.token-kind: the token kind for generated tokens (no default, required property).
  • delegation-token.update-interval.sec: secret manager master key update interval in seconds (default 1 day).
  • delegation-token.max-lifetime.sec: maximum life of a delegation token in seconds (default 7 days).
  • delegation-token.renewal-interval.sec: renewal interval for delegation tokens in seconds (default 1 day).
  • delegation-token.removal-scan-interval.sec: delegation tokens removal scan interval in seconds (default 1 hour).
  • Field Details

  • Constructor Details

    • DelegationTokenAuthenticationHandler

      public DelegationTokenAuthenticationHandler(org.apache.hadoop.security.authentication.server.AuthenticationHandler handler)
  • Method Details

    • init

      public void init(Properties config) throws javax.servlet.ServletException
      Specified by:
      init in interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
      Throws:
      javax.servlet.ServletException
    • setExternalDelegationTokenSecretManager

      public void setExternalDelegationTokenSecretManager(AbstractDelegationTokenSecretManager secretManager)
      Sets an external DelegationTokenSecretManager instance to manage creation and verification of Delegation Tokens.

      This is useful for use cases where secrets must be shared across multiple services.

      Parameters:
      secretManager - a DelegationTokenSecretManager instance
    • initTokenManager

      @VisibleForTesting public void initTokenManager(Properties config)
    • initJsonFactory

      @VisibleForTesting public void initJsonFactory(Properties config)
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
    • getType

      public String getType()
      Specified by:
      getType in interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
    • isManagementOperation

      protected final boolean isManagementOperation(javax.servlet.http.HttpServletRequest request) throws IOException
      This method checks if the given HTTP request corresponds to a management operation.
      Parameters:
      request - The HTTP request
      Returns:
      true if the given HTTP request corresponds to a management operation false otherwise
      Throws:
      IOException - In case of I/O error.
    • managementOperation

      public boolean managementOperation(org.apache.hadoop.security.authentication.server.AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, org.apache.hadoop.security.authentication.client.AuthenticationException
      Specified by:
      managementOperation in interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
      Throws:
      IOException
      org.apache.hadoop.security.authentication.client.AuthenticationException
    • authenticate

      public org.apache.hadoop.security.authentication.server.AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, org.apache.hadoop.security.authentication.client.AuthenticationException
      Authenticates a request looking for the delegation query-string parameter and verifying it is a valid token. If there is not delegation query-string parameter, it delegates the authentication to the KerberosAuthenticationHandler unless it is disabled.
      Specified by:
      authenticate in interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
      Parameters:
      request - the HTTP client request.
      response - the HTTP client response.
      Returns:
      the authentication token for the authenticated request.
      Throws:
      IOException - thrown if an IO error occurred.
      org.apache.hadoop.security.authentication.client.AuthenticationException - thrown if the authentication failed.