public static void addTokenForJob(final Connection conn, final JobConf job, User user)
    throws IOException, InterruptedException {

    Token<AuthenticationTokenIdentifier> token = getAuthToken(conn, user);
    if (token == null) {
      token = ClientTokenUtil.obtainToken(conn, user);
    }
    job.getCredentials().addToken(token.getService(), token);
  }
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.
@param conn The HBase cluster connection
@param user The user for whom to obtain the token
@param job  The job configuration in which the token should be stored
@throws IOException          If making a remote call to the authentication service fails
@throws InterruptedException If executing as the given user is interrupted
hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/TokenUtil.java