protected
String proxyUser;
....
public
void
setConf(Configuration conf) {
UserGroupInformation ugi =
null
;
if
(HiveConf.getBoolVar(conf,HiveConf.ConfVars.HIVE_USE_CUSTOM_PROXY)){
proxyUser = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_CUSTOM_PROXY_USER);
if
((
""
).equals(proxyUser)||proxyUser ==
null
||(
"hdfs"
).equals(proxyUser)){
throw
new
RuntimeException(
"User proxy user, but set the wrong username ["
+proxyUser+
"]"
);
}
try
{
ugi = ShimLoader.getHadoopShims().createRemoteUser(proxyUser,
null
);
}
catch
(Exception e) {
throw
new
RuntimeException(e);
}
if
(ugi ==
null
) {
throw
new
RuntimeException(
"Can not initialize ProxyUserAuthenticator for user ["
+proxyUser+
"]"
);
}
this
.userName = ShimLoader.getHadoopShims().getShortUserName(ugi);
if
(ugi.getGroupNames() !=
null
) {
this
.groupNames = Arrays.asList(ugi.getGroupNames());
}
}
else
{
try
{
ugi = ShimLoader.getHadoopShims().getUGIForConf(conf);
}
catch
(Exception e) {
throw
new
RuntimeException(e);
}
if
(ugi ==
null
) {
throw
new
RuntimeException(
"Can not initialize HadoopDefaultAuthenticator."
);
}
this
.userName = ShimLoader.getHadoopShims().getShortUserName(ugi);
if
(ugi.getGroupNames() !=
null
) {
this
.groupNames = Arrays.asList(ugi.getGroupNames());
}
}
}