Utils.setTokenStr(ugiForRpc, delegationToken, HiveClientWithAuthzWithCaching.DRILL2HMS_TOKEN); } catch (IOException e) { throw new DrillRuntimeException("Couldn't setup delegation token in the UGI for Hive MetaStoreClient", e);
/** * Helper method that gets the delegation token using <i>processHiveClient</i> for given <i>proxyUserName</i> * and sets it in proxy user UserGroupInformation and proxy user HiveConf. */ protected static void getAndSetDelegationToken(final HiveConf proxyUserHiveConf, final UserGroupInformation proxyUGI, final HiveClient processHiveClient) { checkNotNull(processHiveClient, "process user Hive client required"); checkNotNull(proxyUserHiveConf, "Proxy user HiveConf required"); checkNotNull(proxyUGI, "Proxy user UserGroupInformation required"); try { final String delegationToken = processHiveClient.getDelegationToken(proxyUGI.getUserName()); Utils.setTokenStr(proxyUGI, delegationToken, "DremioDelegationTokenForHiveMetaStoreServer"); proxyUserHiveConf.set("hive.metastore.token.signature", "DremioDelegationTokenForHiveMetaStoreServer"); } catch (Exception e) { final String processUsername = ImpersonationUtil.getProcessUserUGI().getShortUserName(); throw UserException.permissionError(e) .message("Failed to generate Hive metastore delegation token for user %s. " + "Check Hadoop services (including metastore) have correct proxy user impersonation settings (%s, %s) " + "and services are restarted after applying those settings.", proxyUGI.getUserName(), String.format("hadoop.proxyuser.%s.hosts", processUsername), String.format("hadoop.proxyuser.%s.groups", processUsername) ) .addContext("Proxy user", proxyUGI.getUserName()) .build(logger); } }
/** * Enable delegation token for the session * save the token string and set the token.signature in hive conf. The metastore client uses * this token.signature to determine where to use kerberos or delegation token * @throws HiveException * @throws IOException */ private void setDelegationToken(String delegationTokenStr) throws HiveSQLException { this.delegationTokenStr = delegationTokenStr; if (delegationTokenStr != null) { getHiveConf().set("hive.metastore.token.signature", HS2TOKEN); try { Utils.setTokenStr(sessionUgi, delegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi", e); } } }
/** * Enable delegation token for the session * save the token string and set the token.signature in hive conf. The metastore client uses * this token.signature to determine where to use kerberos or delegation token * @throws HiveException * @throws IOException */ private void setDelegationToken(String delegationTokenStr) throws HiveSQLException { this.delegationTokenStr = delegationTokenStr; if (delegationTokenStr != null) { getHiveConf().set("hive.metastore.token.signature", HS2TOKEN); try { Utils.setTokenStr(sessionUgi, delegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi", e); } } }
/** * Enable delegation token for the session * save the token string and set the token.signature in hive conf. The metastore client uses * this token.signature to determine where to use kerberos or delegation token * @throws HiveException * @throws IOException */ private void setDelegationToken(String delegationTokenStr) throws HiveSQLException { this.delegationTokenStr = delegationTokenStr; if (delegationTokenStr != null) { getHiveConf().set("hive.metastore.token.signature", HS2TOKEN); try { Utils.setTokenStr(sessionUgi, delegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi", e); } } }
/** * Enable delegation token for the session * save the token string and set the token.signature in hive conf. The metastore client uses * this token.signature to determine where to use kerberos or delegation token * @throws HiveException * @throws IOException */ private void setDelegationToken(String delegationTokenStr) throws HiveSQLException { this.delegationTokenStr = delegationTokenStr; if (delegationTokenStr != null) { getHiveConf().set("hive.metastore.token.signature", HS2TOKEN); try { Utils.setTokenStr(sessionUgi, delegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi", e); } } }