private static void storeTokenInJobConf(String tokenStr) throws Exception { SessionUtils.setTokenStr(Utils.getUGI(), tokenStr, HiveAuthConstants.HS2_CLIENT_TOKEN); System.out.println("Stored token " + tokenStr); }
/** * Add a given service to delegation token string. * * @param tokenStr * @param tokenService * @return * @throws IOException */ public static String addServiceToToken(String tokenStr, String tokenService) throws IOException { Token<DelegationTokenIdentifier> delegationToken = createToken(tokenStr, tokenService); return delegationToken.encodeToUrlString(); }
private String getClientDelegationToken(Map<String, String> jdbcConnConf) throws SQLException { String tokenStr = null; if (JdbcConnectionParams.AUTH_TOKEN.equalsIgnoreCase(jdbcConnConf.get(JdbcConnectionParams.AUTH_TYPE))) { // check delegation token in job conf if any try { tokenStr = SessionUtils.getTokenStrForm(HiveAuthConstants.HS2_CLIENT_TOKEN); } catch (IOException e) { throw new SQLException("Error reading token ", e); } } return tokenStr; }
/** * 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 hmsDelegationTokenStr) throws HiveSQLException { this.hmsDelegationTokenStr = hmsDelegationTokenStr; if (hmsDelegationTokenStr != null) { getHiveConf().setVar(HiveConf.ConfVars.METASTORE_TOKEN_SIGNATURE, HS2TOKEN); try { SessionUtils.setTokenStr(sessionUgi, hmsDelegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi: " + e, e); } } }
/** * Create a delegation token object for the given token string and service. Add the token to given * UGI * * @param ugi * @param tokenStr * @param tokenService * @throws IOException */ public static void setTokenStr(UserGroupInformation ugi, String tokenStr, String tokenService) throws IOException { Token<DelegationTokenIdentifier> delegationToken = createToken(tokenStr, tokenService); ugi.addToken(delegationToken); }
private String getClientDelegationToken(Map<String, String> jdbcConnConf) throws SQLException { String tokenStr = null; if (JdbcConnectionParams.AUTH_TOKEN.equalsIgnoreCase(jdbcConnConf.get(JdbcConnectionParams.AUTH_TYPE))) { // check delegation token in job conf if any try { tokenStr = SessionUtils.getTokenStrForm(HiveAuthConstants.HS2_CLIENT_TOKEN); } catch (IOException e) { throw new SQLException("Error reading token ", e); } } return tokenStr; }
/** * 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 hmsDelegationTokenStr) throws HiveSQLException { this.hmsDelegationTokenStr = hmsDelegationTokenStr; if (hmsDelegationTokenStr != null) { getHiveConf().setVar(HiveConf.ConfVars.METASTORE_TOKEN_SIGNATURE, HS2TOKEN); try { SessionUtils.setTokenStr(sessionUgi, hmsDelegationTokenStr, HS2TOKEN); } catch (IOException e) { throw new HiveSQLException("Couldn't setup delegation token in the ugi: " + e, e); } } }
/** * Add a given service to delegation token string. * * @param tokenStr * @param tokenService * @return * @throws IOException */ public static String addServiceToToken(String tokenStr, String tokenService) throws IOException { Token<DelegationTokenIdentifier> delegationToken = createToken(tokenStr, tokenService); return delegationToken.encodeToUrlString(); }
/** * Create a delegation token object for the given token string and service. Add the token to given * UGI * * @param ugi * @param tokenStr * @param tokenService * @throws IOException */ public static void setTokenStr(UserGroupInformation ugi, String tokenStr, String tokenService) throws IOException { Token<DelegationTokenIdentifier> delegationToken = createToken(tokenStr, tokenService); ugi.addToken(delegationToken); }