From a39bf4cea6859678f6d807db0673f7d34d0bf1ba Mon Sep 17 00:00:00 2001 From: Bolke de Bruin Date: Mon, 1 Feb 2016 22:20:35 +0100 Subject: [PATCH] Use KerberosName for getShortName instead of local implementation --- .../org/apache/hive/service/cli/thrift/ThriftCLIService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java index d9a9e3b..8dff264 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java @@ -34,6 +34,8 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.common.ServerUtils; +import org.apache.hadoop.hive.shims.HadoopShims.KerberosNameShim; +import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hive.service.AbstractService; import org.apache.hive.service.ServiceException; import org.apache.hive.service.ServiceUtils; @@ -408,7 +410,7 @@ private String getIpAddress() { * @return * @throws HiveSQLException */ - private String getUserName(TOpenSessionReq req) throws HiveSQLException { + private String getUserName(TOpenSessionReq req) throws HiveSQLException, IOException { String userName = null; // Kerberos if (isKerberosAuthMode()) { @@ -434,12 +436,12 @@ private String getUserName(TOpenSessionReq req) throws HiveSQLException { return effectiveClientUser; } - private String getShortName(String userName) { + private String getShortName(String userName) throws IOException { String ret = null; + if (userName != null) { - int indexOfDomainMatch = ServiceUtils.indexOfDomainMatch(userName); - ret = (indexOfDomainMatch <= 0) ? userName : - userName.substring(0, indexOfDomainMatch); + KerberosNameShim fullKerberosName = ShimLoader.getHadoopShims().getKerberosNameShim(userName); + ret = fullKerberosName.getShortName(); } return ret; -- 2.5.4 (Apple Git-61)