use of org.apache.hadoop.hive.metastore.api.Role in project hive by apache.
the class HBaseReadWrite method scanRoles.
private List<Role> scanRoles(String regex) throws IOException {
Filter filter = null;
if (regex != null) {
filter = new RowFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator(regex));
}
Iterator<Result> iter = scan(ROLE_TABLE, null, null, CATALOG_CF, CATALOG_COL, filter);
List<Role> roles = new ArrayList<>();
while (iter.hasNext()) {
Result result = iter.next();
roles.add(HBaseUtils.deserializeRole(result.getRow(), result.getValue(CATALOG_CF, CATALOG_COL)));
}
return roles;
}
use of org.apache.hadoop.hive.metastore.api.Role in project hive by apache.
the class TestAdminUser method testCreateAdminNAddUser.
public void testCreateAdminNAddUser() throws IOException, Throwable {
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.USERS_IN_ADMIN_ROLE, "adminuser");
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, SQLStdHiveAuthorizerFactory.class.getName());
RawStore rawStore = new HMSHandler("testcreateroot", conf).getMS();
Role adminRole = rawStore.getRole(HiveMetaStore.ADMIN);
assertTrue(adminRole.getOwnerName().equals(HiveMetaStore.ADMIN));
assertEquals(rawStore.listPrincipalGlobalGrants(HiveMetaStore.ADMIN, PrincipalType.ROLE).get(0).getGrantInfo().getPrivilege(), "All");
assertEquals(rawStore.listRoles("adminuser", PrincipalType.USER).get(0).getRoleName(), HiveMetaStore.ADMIN);
}
use of org.apache.hadoop.hive.metastore.api.Role in project hive by apache.
the class AbstractTestAuthorizationApiAuthorizer method testCreateRole.
@Test
public void testCreateRole() throws Exception {
FunctionInvoker invoker = new FunctionInvoker() {
@Override
public void invoke() throws Exception {
msc.create_role(new Role("role1", 0, "owner"));
}
};
testFunction(invoker);
}
use of org.apache.hadoop.hive.metastore.api.Role in project hive by apache.
the class HBaseStore method addRole.
@Override
public boolean addRole(String roleName, String ownerName) throws InvalidObjectException, MetaException, NoSuchObjectException {
int now = (int) (System.currentTimeMillis() / 1000);
Role role = new Role(roleName, now, ownerName);
boolean commit = false;
openTransaction();
try {
if (getHBase().getRole(roleName) != null) {
throw new InvalidObjectException("Role " + roleName + " already exists");
}
getHBase().putRole(role);
commit = true;
return true;
} catch (IOException e) {
LOG.error("Unable to create role ", e);
throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.Role in project hive by apache.
the class HBaseImport method copyRoles.
private void copyRoles() throws NoSuchObjectException, InvalidObjectException, MetaException {
screen("Copying roles");
List<String> toCopy = doAll ? rdbmsStore.get().listRoleNames() : rolesToImport;
for (String roleName : toCopy) {
Role role = rdbmsStore.get().getRole(roleName);
screen("Copying role " + roleName);
hbaseStore.get().addRole(roleName, role.getOwnerName());
}
}
Aggregations