Class TokenUtil
java.lang.Object
org.apache.hadoop.hbase.security.token.TokenUtil
Utility methods for obtaining authentication tokens.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addTokenForJob
(Connection conn, User user, org.apache.hadoop.mapreduce.Job job) Checks for an authentication token for the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.static void
addTokenForJob
(Connection conn, org.apache.hadoop.mapred.JobConf job, User user) Checks for an authentication token for the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.static boolean
addTokenIfMissing
(Connection conn, User user) Checks if an authentication tokens exists for the connected cluster, obtaining one if needed and adding it to the user's credentials.private static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>
getAuthToken
(Connection conn, User user) Get the authentication token of the user for the cluster specified in the configurationprivate static org.apache.hadoop.io.Text
getClusterId
(org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> token) static void
obtainAndCacheToken
(Connection conn, User user) static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>
obtainToken
(org.apache.hadoop.conf.Configuration conf) Deprecated.Since 2.0.0 and will be removed in 4.0.0.static CompletableFuture<org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>>
obtainToken
(AsyncConnection conn) Deprecated.External users should not use this method, will be removed in 4.0.0.static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>
obtainToken
(Connection conn) Deprecated.External users should not use this method, will be removed in 4.0.0.static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>
obtainToken
(Connection conn, User user) Deprecated.External users should not use this method, will be removed in 4.0.0.static void
obtainTokenForJob
(Connection conn, User user, org.apache.hadoop.mapreduce.Job job) 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
(Connection conn, org.apache.hadoop.mapred.JobConf job, User user) Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job.static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>
toToken
(org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token proto) Deprecated.External users should not use this method, will be removed in 4.0.0.static org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token
toToken
(org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> token) Deprecated.External users should not use this method, will be removed in 4.0.0.
-
Field Details
-
LOG
-
-
Constructor Details
-
TokenUtil
public TokenUtil()
-
-
Method Details
-
obtainToken
@Deprecated public static CompletableFuture<org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier>> obtainToken(AsyncConnection conn) Deprecated.External users should not use this method, will be removed in 4.0.0. Please post on the HBase dev mailing list if you need this method. Internal HBase code should useClientTokenUtil
instead. -
obtainToken
@Deprecated public static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> obtainToken(org.apache.hadoop.conf.Configuration conf) throws IOException Deprecated.Since 2.0.0 and will be removed in 4.0.0.It was removed in HBase-2.0 but added again as spark code relies on this method to obtain delegation token- Throws:
IOException
-
obtainToken
@Deprecated public static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> obtainToken(Connection conn) throws IOException Deprecated.External users should not use this method, will be removed in 4.0.0. Please post on the HBase dev mailing list if you need this method. Internal HBase code should useClientTokenUtil
instead.- Throws:
IOException
-
toToken
@Deprecated public static org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token toToken(org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> token) Deprecated.External users should not use this method, will be removed in 4.0.0. Please post on the HBase dev mailing list if you need this method. Internal HBase code should useClientTokenUtil
instead. -
obtainToken
@Deprecated public static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> obtainToken(Connection conn, User user) throws IOException, InterruptedException Deprecated.External users should not use this method, will be removed in 4.0.0. Please post on the HBase dev mailing list if you need this method. Internal HBase code should useClientTokenUtil
instead.- Throws:
IOException
InterruptedException
-
obtainAndCacheToken
public static void obtainAndCacheToken(Connection conn, User user) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
toToken
@Deprecated public static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> toToken(org.apache.hadoop.hbase.shaded.protobuf.generated.AuthenticationProtos.Token proto) Deprecated.External users should not use this method, will be removed in 4.0.0. Please post on the HBase dev mailing list if you need this method. Internal HBase code should useClientTokenUtil
instead. -
getClusterId
private static org.apache.hadoop.io.Text getClusterId(org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> token) throws IOException - Throws:
IOException
-
obtainTokenForJob
public static void obtainTokenForJob(Connection conn, User user, org.apache.hadoop.mapreduce.Job job) throws IOException, InterruptedException Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job.- Parameters:
conn
- The HBase cluster connectionuser
- 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 to the authentication service failsInterruptedException
- If executing as the given user is interrupted
-
obtainTokenForJob
public static void obtainTokenForJob(Connection conn, org.apache.hadoop.mapred.JobConf job, User user) throws IOException, InterruptedException Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job.- Parameters:
conn
- The HBase cluster connectionuser
- The user for whom to obtain the tokenjob
- The job configuration in which the token should be stored- Throws:
IOException
- If making a remote call to the authentication service failsInterruptedException
- If executing as the given user is interrupted
-
addTokenForJob
public static void addTokenForJob(Connection conn, org.apache.hadoop.mapred.JobConf job, User user) throws IOException, InterruptedException Checks for an authentication token for the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.- Parameters:
conn
- The HBase cluster connectionuser
- The user for whom to obtain the tokenjob
- The job configuration in which the token should be stored- Throws:
IOException
- If making a remote call to the authentication service failsInterruptedException
- If executing as the given user is interrupted
-
addTokenForJob
public static void addTokenForJob(Connection conn, User user, org.apache.hadoop.mapreduce.Job job) throws IOException, InterruptedException Checks for an authentication token for the given user, obtaining a new token if necessary, and adds it to the credentials for the given map reduce job.- Parameters:
conn
- The HBase cluster connectionuser
- 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 to the authentication service failsInterruptedException
- If executing as the given user is interrupted
-
addTokenIfMissing
public static boolean addTokenIfMissing(Connection conn, User user) throws IOException, InterruptedException Checks if an authentication tokens exists for the connected cluster, obtaining one if needed and adding it to the user's credentials.- Parameters:
conn
- The HBase cluster connectionuser
- The user for whom to obtain the token- Returns:
- true if the token was added, false if it already existed
- Throws:
IOException
- If making a remote call to the authentication service failsInterruptedException
- If executing as the given user is interrupted
-
getAuthToken
private static org.apache.hadoop.security.token.Token<AuthenticationTokenIdentifier> getAuthToken(Connection conn, User user) throws IOException Get the authentication token of the user for the cluster specified in the configuration- Returns:
- null if the user does not have the token, otherwise the auth token for the cluster.
- Throws:
IOException
-