private String getShortName(String userName) throws IOException {
    String ret = null;

    if (userName != null) {
      if (hiveAuthFactory != null && hiveAuthFactory.isSASLKerberosUser()) {
        // KerberosName.getShorName can only be used for kerberos user, but not for the user
        // logged in via other authentications such as LDAP
        KerberosNameShim fullKerberosName = ShimLoader.getHadoopShims().getKerberosNameShim(userName);
        ret = fullKerberosName.getShortName();
      } else {
        int indexOfDomainMatch = ServiceUtils.indexOfDomainMatch(userName);
        ret = (indexOfDomainMatch <= 0) ? userName : userName.substring(0, indexOfDomainMatch);
      }
    }

    return ret;
  }
Returns the effective username.
1. If hive.server2.allow.user.substitution = false: the username of the connecting user
2. If hive.server2.allow.user.substitution = true: the username of the end user,
that the connecting user is trying to proxy for.
This includes a check whether the connecting user is allowed to proxy for the end user.
@param req
@return
@throws HiveSQLException
service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java