Class TokenUtil
java.lang.Object
org.elasticsearch.hadoop.mr.security.TokenUtil
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddTokenForJob(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 voidaddTokenForJobConf(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 voidobtainAndCache(org.elasticsearch.hadoop.rest.RestClient client, User user) Obtain an authentication token for the given user and add it to the user's credentials.static Token<EsTokenIdentifier>obtainToken(org.elasticsearch.hadoop.rest.RestClient client, User user) Obtain and return an authentication token for the current user.static voidobtainTokenForJob(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 voidobtainTokenForJob(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.
-
Field Details
-
KEY_NAME_PREFIX
- See Also:
-
-
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 clientuser- 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 clientuser- The user for whom to obtain the tokenjob- 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 clientuser- The user for whom to obtain the tokenjobConf- 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 clientclusterName- the name of the cluster you are connecting touser- The user for whom to obtain the tokenjob- The job instance in which the token should be stored- Throws:
IOException- If making a remote call failsInterruptedException- 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 clientclusterName- the name of the cluster you are connecting touser- The user for whom to obtain the tokenjob- The job instance in which the token should be stored- Throws:
IOException- If making a remote call failsInterruptedException- If executing as the given user is interrupted
-