/** * Make sure that the warehouse variable is set up properly. * @throws MetaException if unable to instantiate */ private void initWh() throws MetaException, HiveException { if (wh == null){ if(!isRunFromMetaStore){ // Note, although HiveProxy has a method that allows us to check if we're being // called from the metastore or from the client, we don't have an initialized HiveProxy // till we explicitly initialize it as being from the client side. So, we have a // chicken-and-egg problem. So, we now track whether or not we're running from client-side // in the SBAP itself. hive_db = new HiveProxy(Hive.get(getConf(), StorageBasedAuthorizationProvider.class)); this.wh = new Warehouse(getConf()); if (this.wh == null){ // If wh is still null after just having initialized it, bail out - something's very wrong. throw new IllegalStateException("Unable to initialize Warehouse from clientside."); } }else{ // not good if we reach here, this was initialized at setMetaStoreHandler() time. // this means handler.getWh() is returning null. Error out. throw new IllegalStateException("Uninitialized Warehouse from MetastoreHandler"); } } }
authorize(hive_db.getDatabase(table.getDbName()), new Privilege[] {}, new Privilege[] { Privilege.ALTER_DATA });
.get_privilege_set(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), partValues, col, this.getAuthenticator().getUserName(), this .getAuthenticator().getGroupNames());
.get_privilege_set(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), partValues, col, this.getAuthenticator().getUserName(), this .getAuthenticator().getGroupNames());
authorize(hive_db.getDatabase(table.getDbName()), new Privilege[] {}, new Privilege[] { Privilege.ALTER_DATA });
hive_db.getDatabase(part.getTable().getDbName()), inputRequiredPriv, outputRequiredPriv, inputCheck, outputCheck)) { return true; partPrivileges = hive_db.get_privilege_set(HiveObjectType.PARTITION, part .getTable().getDbName(), part.getTable().getTableName(), part .getValues(), null, this.getAuthenticator().getUserName(), this
PrincipalPrivilegeSet dbPrivileges = hive_db.get_privilege_set( HiveObjectType.DATABASE, db.getName(), null, null, null, this .getAuthenticator().getUserName(), this.getAuthenticator()
/** * Check privileges on User, DB and table objects. * * @param table * @param inputRequiredPriv * @param outputRequiredPriv * @param inputCheck * @param outputCheck * @return true if the check passed * @throws HiveException */ private boolean authorizeUserDBAndTable(Table table, Privilege[] inputRequiredPriv, Privilege[] outputRequiredPriv, boolean[] inputCheck, boolean[] outputCheck) throws HiveException { if (authorizeUserAndDBPriv(hive_db.getDatabase(table.getDbName()), inputRequiredPriv, outputRequiredPriv, inputCheck, outputCheck)) { return true; } PrincipalPrivilegeSet tablePrivileges = hive_db.get_privilege_set( HiveObjectType.TABLE, table.getDbName(), table.getTableName(), null, null, this.getAuthenticator().getUserName(), this.getAuthenticator() .getGroupNames()); if (authorizePrivileges(tablePrivileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck)) { return true; } return false; }
/** * Make sure that the warehouse variable is set up properly. * @throws MetaException if unable to instantiate */ private void initWh() throws MetaException, HiveException { if (wh == null){ if(!isRunFromMetaStore){ // Note, although HiveProxy has a method that allows us to check if we're being // called from the metastore or from the client, we don't have an initialized HiveProxy // till we explicitly initialize it as being from the client side. So, we have a // chicken-and-egg problem. So, we now track whether or not we're running from client-side // in the SBAP itself. hive_db = new HiveProxy(Hive.get(getConf(), StorageBasedAuthorizationProvider.class)); this.wh = new Warehouse(getConf()); if (this.wh == null){ // If wh is still null after just having initialized it, bail out - something's very wrong. throw new IllegalStateException("Unable to initialize Warehouse from clientside."); } }else{ // not good if we reach here, this was initialized at setMetaStoreHandler() time. // this means handler.getWh() is returning null. Error out. throw new IllegalStateException("Uninitialized Warehouse from MetastoreHandler"); } } }
public PrincipalPrivilegeSet get_privilege_set(HiveObjectType column, String dbName, String tableName, List<String> partValues, String col, String userName, List<String> groupNames) throws HiveException { if (!isRunFromMetaStore()) { return hiveClient.get_privilege_set( column, dbName, tableName, partValues, col, userName, groupNames); } else { HiveObjectRef hiveObj = new HiveObjectRef(column, dbName, tableName, partValues, col); try { return handler.get_privilege_set(hiveObj, userName, groupNames); } catch (MetaException e) { throw new HiveException(e); } catch (TException e) { throw new HiveException(e); } } }
public void init(Configuration conf) throws HiveException { hive_db = new HiveProxy(Hive.get(conf, HiveAuthorizationProvider.class)); }
@Override public void init(Configuration conf) throws HiveException { hive_db = new HiveProxy(); }
public Database getDatabase(String dbName) throws HiveException { if (!isRunFromMetaStore()) { return hiveClient.getDatabase(dbName); } else { try { return handler.get_database_core(dbName); } catch (NoSuchObjectException e) { throw new HiveException(e); } catch (MetaException e) { throw new HiveException(e); } } }
@Override public void setMetaStoreHandler(HMSHandler handler) { hive_db.setHandler(handler); }
@Override public void setMetaStoreHandler(HMSHandler handler) { hive_db.setHandler(handler); this.wh = handler.getWh(); this.isRunFromMetaStore = true; }
protected boolean authorizeUserPriv(Privilege[] inputRequiredPriv, boolean[] inputCheck, Privilege[] outputRequiredPriv, boolean[] outputCheck) throws HiveException { PrincipalPrivilegeSet privileges = hive_db.get_privilege_set( HiveObjectType.GLOBAL, null, null, null, null, this.getAuthenticator() .getUserName(), this.getAuthenticator().getGroupNames()); return authorizePrivileges(privileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck); }
@Override public void init(Configuration conf) throws HiveException { hive_db = new HiveProxy(); }
.get_privilege_set(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), partValues, col, this.getAuthenticator().getUserName(), this .getAuthenticator().getGroupNames());
PrincipalPrivilegeSet dbPrivileges = hive_db.get_privilege_set( HiveObjectType.DATABASE, db.getName(), null, null, null, this .getAuthenticator().getUserName(), this.getAuthenticator()
hive_db.getDatabase(part.getTable().getDbName()), inputRequiredPriv, outputRequiredPriv, inputCheck, outputCheck)) { return true; partPrivileges = hive_db.get_privilege_set(HiveObjectType.PARTITION, part .getTable().getDbName(), part.getTable().getTableName(), part .getValues(), null, this.getAuthenticator().getUserName(), this