public static void copyJobSecretToTableProperties(TableDesc tbl) throws IOException {
    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    for (Text key : credentials.getAllSecretKeys()) {
      String keyString = key.toString();
      if (keyString.startsWith(TableDesc.SECRET_PREFIX + TableDesc.SECRET_DELIMIT)) {
        String[] comps = keyString.split(TableDesc.SECRET_DELIMIT);
        String tblName = comps[1];
        String keyName = comps[2];
        if (tbl.getTableName().equalsIgnoreCase(tblName)) {
          tbl.getProperties().put(keyName, new String(credentials.getSecretKey(key)));
        }
      }
    }
  }
Copy job credentials to table properties
@param tbl
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java