## org.apache.hadoop.mapreduce.security
Class TokenCache

    java.lang.Object
      org.apache.hadoop.mapreduce.security.TokenCache

    public class TokenCache

extends Object

This class provides user facing APIs for transferring secrets from the job client to the tasks. The secrets can be stored just before submission of jobs and read during the task execution.

Field Summary
`static String` `JOB_TOKEN_HDFS_FILE` file name used on HDFS for generated job token
`static String` `JOB_TOKENS_FILENAME` conf setting for job tokens cache file name

Constructor Summary
`TokenCache()`

Method Summary
`static void` `cleanUpTokenReferral(Configuration conf)` Remove jobtoken referrals which don't make sense in the context of the task execution.
`static Token<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>` `getDelegationToken(Credentials credentials, String namenode)`
`static Token<JobTokenIdentifier>` `getJobToken(Credentials credentials)`
`static byte[]` `getSecretKey(Credentials credentials, Text alias)` auxiliary method to get user's secret keys..
`static Credentials` `loadTokens(String jobTokenFile, Configuration conf)` load job token from a file
`static void` `obtainTokensForNamenodes(Credentials credentials, Path[] ps, Configuration conf)` Convenience method to obtain delegation tokens from namenodes corresponding to the paths passed.
`static void` `setJobToken(Token<? extends TokenIdentifier> t, Credentials credentials)` store job token

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### JOB_TOKEN_HDFS_FILE

    public static final String JOB_TOKEN_HDFS_FILE

  file name used on HDFS for generated job token

  See Also:
    Constant Field Values

### JOB_TOKENS_FILENAME

    public static final String JOB_TOKENS_FILENAME

  conf setting for job tokens cache file name

  See Also:
    Constant Field Values

Constructor Detail

### TokenCache

    public TokenCache()

Method Detail

### getSecretKey

    public static byte[] getSecretKey(Credentials credentials,
                                      Text alias)

  auxiliary method to get user's secret keys..

  Parameters:
    `alias` -
  Returns:
    secret key from the storage

### obtainTokensForNamenodes

    public static void obtainTokensForNamenodes(Credentials credentials,
                                                Path[] ps,
                                                Configuration conf)
                                         throws IOException

  Convenience method to obtain delegation tokens from namenodes corresponding to the paths passed.

  Parameters:
    `ps` - array of paths
    `conf` - configuration
  Throws:
    `IOException`

### cleanUpTokenReferral

    public static void cleanUpTokenReferral(Configuration conf)

  Remove jobtoken referrals which don't make sense in the context of the task execution.

  Parameters:
    `conf` - configuration object.

### getDelegationToken

    public static Token<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier> getDelegationToken(Credentials credentials,
                                                                                                                       String namenode)

  Parameters:
    `namenode` -
  Returns:
    delegation token

### loadTokens

    public static Credentials loadTokens(String jobTokenFile,
                                         Configuration conf)
                                  throws IOException

  load job token from a file

  Parameters:
    `conf` -
  Throws:
    `IOException`

### setJobToken

    public static void setJobToken(Token<? extends TokenIdentifier> t,
                                   Credentials credentials)

  store job token

  Parameters:
    `t` -

### getJobToken

    public static Token<JobTokenIdentifier> getJobToken(Credentials credentials)

  Returns:
    job token

Copyright © 2009 The Apache Software Foundation