org.apache.hadoop.mapreduce.security.token

## Class JobTokenSecretManager

- java.lang.Object
- - org.apache.hadoop.security.token.SecretManager<JobTokenIdentifier>
  - - org.apache.hadoop.mapreduce.security.token.JobTokenSecretManager

-     @InterfaceAudience.Private
       @InterfaceStability.Unstable
      public class JobTokenSecretManager
      extends org.apache.hadoop.security.token.SecretManager<JobTokenIdentifier>

  SecretManager for job token. It can be used to cache generated job tokens.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.hadoop.security.token.SecretManager

      `org.apache.hadoop.security.token.SecretManager.InvalidToken`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobTokenSecretManager()` Default constructor

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addTokenForJob(String jobId, org.apache.hadoop.security.token.Token<JobTokenIdentifier> token)` Add the job token of a job to cache
    `static byte[]` | `computeHash(byte[] msg, SecretKey key)` Compute the HMAC hash of the message using the key
    `JobTokenIdentifier` | `createIdentifier()` Create an empty job token identifier
    `byte[]` | `createPassword(JobTokenIdentifier identifier)` Create a new password/secret for the given job token identifier.
    `static SecretKey` | `createSecretKey(byte[] key)` Convert the byte[] to a secret key
    `void` | `removeTokenForJob(String jobId)` Remove the cached job token of a job from cache
    `byte[]` | `retrievePassword(JobTokenIdentifier identifier)` Look up the token password/secret for the given job token identifier.
    `SecretKey` | `retrieveTokenSecret(String jobId)` Look up the token password/secret for the given jobId.

    - ### Methods inherited from class org.apache.hadoop.security.token.SecretManager

      `checkAvailableForRead, createPassword, generateSecret, retriableRetrievePassword`

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

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

- - ### Constructor Detail

    - #### JobTokenSecretManager

          public JobTokenSecretManager()

      Default constructor

  - ### Method Detail

    - #### createSecretKey

          public static SecretKey createSecretKey(byte[] key)

      Convert the byte[] to a secret key
      Parameters:
        `key` - the byte[] to create the secret key from
      Returns:
        the secret key

    - #### computeHash

          public static byte[] computeHash(byte[] msg,
                                           SecretKey key)

      Compute the HMAC hash of the message using the key
      Parameters:
        `msg` - the message to hash
        `key` - the key to use
      Returns:
        the computed hash

    - #### createPassword

          public byte[] createPassword(JobTokenIdentifier identifier)

      Create a new password/secret for the given job token identifier.
      Specified by:
        `createPassword` in class `org.apache.hadoop.security.token.SecretManager<JobTokenIdentifier>`
      Parameters:
        `identifier` - the job token identifier
      Returns:
        token password/secret

    - #### addTokenForJob

          public void addTokenForJob(String jobId,
                                     org.apache.hadoop.security.token.Token<JobTokenIdentifier> token)

      Add the job token of a job to cache
      Parameters:
        `jobId` - the job that owns the token
        `token` - the job token

    - #### removeTokenForJob

          public void removeTokenForJob(String jobId)

      Remove the cached job token of a job from cache
      Parameters:
        `jobId` - the job whose token is to be removed

    - #### retrieveTokenSecret

          public SecretKey retrieveTokenSecret(String jobId)
                                        throws org.apache.hadoop.security.token.SecretManager.InvalidToken

      Look up the token password/secret for the given jobId.
      Parameters:
        `jobId` - the jobId to look up
      Returns:
        token password/secret as SecretKey
      Throws:
        `InvalidToken`
        `org.apache.hadoop.security.token.SecretManager.InvalidToken`

    - #### retrievePassword

          public byte[] retrievePassword(JobTokenIdentifier identifier)
                                  throws org.apache.hadoop.security.token.SecretManager.InvalidToken

      Look up the token password/secret for the given job token identifier.
      Specified by:
        `retrievePassword` in class `org.apache.hadoop.security.token.SecretManager<JobTokenIdentifier>`
      Parameters:
        `identifier` - the job token identifier to look up
      Returns:
        token password/secret as byte[]
      Throws:
        `InvalidToken`
        `org.apache.hadoop.security.token.SecretManager.InvalidToken`

    - #### createIdentifier

          public JobTokenIdentifier createIdentifier()

      Create an empty job token identifier
      Specified by:
        `createIdentifier` in class `org.apache.hadoop.security.token.SecretManager<JobTokenIdentifier>`
      Returns:
        a newly created empty job token identifier

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.