Class TokenUtil

java.lang.Object
org.elasticsearch.hadoop.mr.security.TokenUtil

public class TokenUtil extends Object
Provides the main logic for obtaining Hadoop specific Tokens containing Elasticsearch authentication info, caching them in User objects (Subjects or Hadoop UGI), and adding them to jobs and job configurations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, org.elasticsearch.hadoop.util.ClusterName clusterName, User user, Job job)
    Retrieves an authentication token from the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.
    static void
    addTokenForJobConf(org.elasticsearch.hadoop.rest.RestClient client, org.elasticsearch.hadoop.util.ClusterName clusterName, User user, JobConf job)
    Retrieves an authentication token from the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job configuration.
    static void
    obtainAndCache(org.elasticsearch.hadoop.rest.RestClient client, User user)
    Obtain an authentication token for the given user and add it to the user's credentials.
    obtainToken(org.elasticsearch.hadoop.rest.RestClient client, User user)
    Obtain and return an authentication token for the current user.
    static void
    obtainTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, User user, JobConf jobConf)
    Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job.
    static void
    obtainTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, User user, Job job)
    Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • TokenUtil

      public TokenUtil()
  • Method Details

    • obtainToken

      public static Token<EsTokenIdentifier> obtainToken(org.elasticsearch.hadoop.rest.RestClient client, User user)
      Obtain and return an authentication token for the current user.
      Parameters:
      client - The Elasticsearch client
      Returns:
      the authentication token instance in Hadoop Token format.
    • obtainAndCache

      public static void obtainAndCache(org.elasticsearch.hadoop.rest.RestClient client, User user) throws IOException
      Obtain an authentication token for the given user and add it to the user's credentials.
      Parameters:
      client - The Elasticsearch client
      user - The user for obtaining and storing the token
      Throws:
      IOException - If making a remote call to the authentication service fails
    • obtainTokenForJob

      public static void obtainTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, User user, Job job)
      Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job. This version always obtains a fresh authentication token instead of checking for existing ones on the current user.
      Parameters:
      client - The Elasticsearch client
      user - The user for whom to obtain the token
      job - The job instance in which the token should be stored
    • obtainTokenForJob

      public static void obtainTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, User user, JobConf jobConf)
      Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job. This version always obtains a fresh authentication token instead of checking for existing ones on the current user.
      Parameters:
      client - The Elasticsearch client
      user - The user for whom to obtain the token
      jobConf - The job configuration in which the token should be stored
    • addTokenForJob

      public static void addTokenForJob(org.elasticsearch.hadoop.rest.RestClient client, org.elasticsearch.hadoop.util.ClusterName clusterName, User user, Job job)
      Retrieves an authentication token from the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.
      Parameters:
      client - The Elasticsearch client
      clusterName - the name of the cluster you are connecting to
      user - The user for whom to obtain the token
      job - The job instance in which the token should be stored
      Throws:
      IOException - If making a remote call fails
      InterruptedException - If executing as the given user is interrupted
    • addTokenForJobConf

      public static void addTokenForJobConf(org.elasticsearch.hadoop.rest.RestClient client, org.elasticsearch.hadoop.util.ClusterName clusterName, User user, JobConf job)
      Retrieves an authentication token from the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job configuration.
      Parameters:
      client - The Elasticsearch client
      clusterName - the name of the cluster you are connecting to
      user - The user for whom to obtain the token
      job - The job instance in which the token should be stored
      Throws:
      IOException - If making a remote call fails
      InterruptedException - If executing as the given user is interrupted