public static boolean addTokenIfMissing(Connection conn, User user)
    throws IOException, InterruptedException {
    Token<AuthenticationTokenIdentifier> token = getAuthToken(conn, user);
    if (token == null) {
      token = ClientTokenUtil.obtainToken(conn, user);
      user.getUGI().addToken(token.getService(), token);
      return true;
    }
    return false;
  }
Checks if an authentication tokens exists for the connected cluster, obtaining one if needed
and adding it to the user's credentials.
@param conn The HBase cluster connection
@param user The user for whom to obtain the token
@throws IOException          If making a remote call to the authentication service fails
@throws InterruptedException If executing as the given user is interrupted
@return true if the token was added, false if it already existed
hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/TokenUtil.java