public void setSessionUGI(String owner) throws HiveSQLException {
    if (owner == null) {
      throw new HiveSQLException("No username provided for impersonation");
    }
    try {
      sessionUgi = UserGroupInformation.createProxyUser(
          owner, UserGroupInformation.getLoginUser());
    } catch (IOException e) {
      throw new HiveSQLException("Couldn't setup proxy user", e);
    }
  }
HiveSessionImplwithUGI.
HiveSession with connecting user's UGI and delegation token if required.
Note: this object may be shared between threads in HS2.
service/src/java/org/apache/hive/service/cli/session/HiveSessionImplwithUGI.java