public class TokenUtils extends Object
This class is compatible with Hadoop 2.
| Modifier and Type | Field and Description |
|---|---|
static String |
OTHER_NAMENODES |
static String |
TOKEN_RENEWER |
| Constructor and Description |
|---|
TokenUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
getAllFSTokens(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
com.google.common.base.Optional<String> userToProxy,
List<String> remoteFSURIList) |
static void |
getAllFSTokensImpl(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
List<String> remoteFSURIList) |
static org.apache.hadoop.security.UserGroupInformation |
getHadoopAndHiveTokensForProxyUser(State state,
com.google.common.base.Optional<File> tokenFile,
org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.hive.metastore.IMetaStoreClient client,
String targetUser)
Get Hadoop tokens (tokens for job history server, job tracker, hive and HDFS) using Kerberos keytab,
on behalf on a proxy user, embed tokens into a
UserGroupInformation as returned result, persist in-memory
credentials if tokenFile specified
Note that when a super-user is fetching tokens for other users,
fetchHcatToken(String, HiveConf, String, IMetaStoreClient) getDelegationToken} explicitly
contains a string parameter indicating proxy user, while other hadoop services require impersonation first. |
static void |
getHadoopFSTokens(State state,
com.google.common.base.Optional<File> tokenFile,
org.apache.hadoop.security.Credentials cred,
String renewer) |
static void |
getHadoopTokens(State state,
com.google.common.base.Optional<File> tokenFile,
org.apache.hadoop.security.Credentials cred)
Get Hadoop tokens (tokens for job history server, job tracker and HDFS) using Kerberos keytab.
|
static void |
getHiveToken(State state,
org.apache.hadoop.hive.metastore.IMetaStoreClient hiveClient,
org.apache.hadoop.security.Credentials cred,
String userToProxy,
org.apache.hadoop.security.UserGroupInformation ugi) |
static void |
getLocalFSToken(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer) |
static org.apache.hadoop.io.Text |
getMRTokenRenewerInternal(org.apache.hadoop.mapred.JobConf jobConf) |
static void |
getRemoteFSTokenFromURI(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
List<String> remoteNamenodesList) |
static String |
obtainKerberosPrincipal(State state)
Obtain kerberos principal in a dynamic way, where the instance's value is determined by the hostname of the machine
that the job is currently running on.
|
public static final String OTHER_NAMENODES
public static final String TOKEN_RENEWER
public static org.apache.hadoop.security.UserGroupInformation getHadoopAndHiveTokensForProxyUser(State state, com.google.common.base.Optional<File> tokenFile, org.apache.hadoop.security.UserGroupInformation ugi, org.apache.hadoop.hive.metastore.IMetaStoreClient client, String targetUser) throws IOException, InterruptedException
UserGroupInformation as returned result, persist in-memory
credentials if tokenFile specified
Note that when a super-user is fetching tokens for other users,
fetchHcatToken(String, HiveConf, String, IMetaStoreClient) getDelegationToken} explicitly
contains a string parameter indicating proxy user, while other hadoop services require impersonation first.state - A State object that should contain properties.tokenFile - If present, the file will store materialized credentials.ugi - The UserGroupInformation that used to impersonate into the proxy user by a "doAs block".targetUser - The user to be impersonated as, for fetching hadoop tokens.UserGroupInformation containing negotiated credentials.IOExceptionInterruptedExceptionpublic static void getHadoopFSTokens(State state, com.google.common.base.Optional<File> tokenFile, org.apache.hadoop.security.Credentials cred, String renewer) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic static void getHadoopTokens(State state, com.google.common.base.Optional<File> tokenFile, org.apache.hadoop.security.Credentials cred) throws IOException, InterruptedException
state - A State object that should contain property USER_TO_PROXY,
KEYTAB_USER and KEYTAB_LOCATION. To obtain tokens for
other namenodes, use property OTHER_NAMENODES with comma separated HDFS URIs.tokenFile - If present, the file will store materialized credentials.cred - A im-memory representation of credentials.IOExceptionInterruptedExceptionpublic static String obtainKerberosPrincipal(State state) throws UnknownHostException
KEYTAB_USER is not following pattern specified in KEYTAB_USER_PATTERN.UnknownHostExceptionpublic static void getHiveToken(State state, org.apache.hadoop.hive.metastore.IMetaStoreClient hiveClient, org.apache.hadoop.security.Credentials cred, String userToProxy, org.apache.hadoop.security.UserGroupInformation ugi)
userToProxy - The user that hiveClient is impersonating as to fetch the delegation tokens.ugi - The UserGroupInformation that to be added with negotiated credentials.public static void getAllFSTokens(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
com.google.common.base.Optional<String> userToProxy,
List<String> remoteFSURIList)
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic static void getAllFSTokensImpl(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
List<String> remoteFSURIList)
public static void getLocalFSToken(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer)
throws IOException
IOExceptionpublic static void getRemoteFSTokenFromURI(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.Credentials cred,
String renewer,
List<String> remoteNamenodesList)
throws IOException
IOExceptionpublic static org.apache.hadoop.io.Text getMRTokenRenewerInternal(org.apache.hadoop.mapred.JobConf jobConf)
throws IOException
IOException