/** * Remove any role privileges that don't belong to the roles in curRoles * @param thriftPrivs * @param curRoles * @return */ private static void filterPrivsByCurrentRoles(PrincipalPrivilegeSet thriftPrivs, List<String> curRoles) { // check if there are privileges to be filtered if(thriftPrivs == null || thriftPrivs.getRolePrivileges() == null || thriftPrivs.getRolePrivilegesSize() == 0 ){ // no privileges to filter return; } // add the privs for roles in curRoles to new role-to-priv map Map<String, List<PrivilegeGrantInfo>> filteredRolePrivs = new HashMap<String, List<PrivilegeGrantInfo>>(); for(String role : curRoles){ List<PrivilegeGrantInfo> privs = thriftPrivs.getRolePrivileges().get(role); if(privs != null){ filteredRolePrivs.put(role, privs); } } thriftPrivs.setRolePrivileges(filteredRolePrivs); }
/** * Remove any role privileges that don't belong to the roles in curRoles * @param thriftPrivs * @param curRoles * @return */ private static void filterPrivsByCurrentRoles(PrincipalPrivilegeSet thriftPrivs, List<String> curRoles) { // check if there are privileges to be filtered if(thriftPrivs == null || thriftPrivs.getRolePrivileges() == null || thriftPrivs.getRolePrivilegesSize() == 0 ){ // no privileges to filter return; } // add the privs for roles in curRoles to new role-to-priv map Map<String, List<PrivilegeGrantInfo>> filteredRolePrivs = new HashMap<String, List<PrivilegeGrantInfo>>(); for(String role : curRoles){ List<PrivilegeGrantInfo> privs = thriftPrivs.getRolePrivileges().get(role); if(privs != null){ filteredRolePrivs.put(role, privs); } } thriftPrivs.setRolePrivileges(filteredRolePrivs); }
.put(roleName, getDBPrivilege(catName, dbName, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(dbRolePriv);
partition, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(partRolePriv);
roleName, PrincipalType.ROLE)); ret.setRolePrivileges(tableRolePriv);
columnName, partitionName, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(columnRolePriv);
public void setFieldValue(_Fields field, Object value) { switch (field) { case USER_PRIVILEGES: if (value == null) { unsetUserPrivileges(); } else { setUserPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case GROUP_PRIVILEGES: if (value == null) { unsetGroupPrivileges(); } else { setGroupPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case ROLE_PRIVILEGES: if (value == null) { unsetRolePrivileges(); } else { setRolePrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; } }
private static class ThreadLocalHive extends ThreadLocal<Hive> { @Override protected Hive initialValue() { return null; } @Override public synchronized void set(Hive hiveObj) { Hive currentHive = this.get(); if (currentHive != hiveObj) { // Remove/close current thread-local Hive object before overwriting with new Hive object. remove(); super.set(hiveObj); } } @Override public synchronized void remove() { Hive currentHive = this.get(); if (currentHive != null) { // Close the metastore connections before removing it from thread local hiveDB. currentHive.close(false); super.remove(); } } }
principalPrivs.setUserPrivileges(grants.getUserGrants()); principalPrivs.setGroupPrivileges(grants.getGroupGrants()); principalPrivs.setRolePrivileges(grants.getRoleGrants()); tt.setPrivileges(principalPrivs);
principalPrivs.setUserPrivileges(grants.getUserGrants()); principalPrivs.setGroupPrivileges(grants.getGroupGrants()); principalPrivs.setRolePrivileges(grants.getRoleGrants()); tTbl.setPrivileges(principalPrivs);
/** * Remove any role privileges that don't belong to the roles in curRoles * @param thriftPrivs * @param curRoles * @return */ private static void filterPrivsByCurrentRoles(PrincipalPrivilegeSet thriftPrivs, List<String> curRoles) { // check if there are privileges to be filtered if(thriftPrivs == null || thriftPrivs.getRolePrivileges() == null || thriftPrivs.getRolePrivilegesSize() == 0 ){ // no privileges to filter return; } // add the privs for roles in curRoles to new role-to-priv map Map<String, List<PrivilegeGrantInfo>> filteredRolePrivs = new HashMap<String, List<PrivilegeGrantInfo>>(); for(String role : curRoles){ List<PrivilegeGrantInfo> privs = thriftPrivs.getRolePrivileges().get(role); if(privs != null){ filteredRolePrivs.put(role, privs); } } thriftPrivs.setRolePrivileges(filteredRolePrivs); }
.put(name, getDBPrivilege(dbName, name, PrincipalType.ROLE)); ret.setRolePrivileges(dbRolePriv);
roleName, PrincipalType.ROLE)); ret.setRolePrivileges(tableRolePriv);
.put(roleName, getDBPrivilege(dbName, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(dbRolePriv);
partition, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(partRolePriv);
public void setFieldValue(_Fields field, Object value) { switch (field) { case USER_PRIVILEGES: if (value == null) { unsetUserPrivileges(); } else { setUserPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case GROUP_PRIVILEGES: if (value == null) { unsetGroupPrivileges(); } else { setGroupPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case ROLE_PRIVILEGES: if (value == null) { unsetRolePrivileges(); } else { setRolePrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case USER_PRIVILEGES: if (value == null) { unsetUserPrivileges(); } else { setUserPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case GROUP_PRIVILEGES: if (value == null) { unsetGroupPrivileges(); } else { setGroupPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case ROLE_PRIVILEGES: if (value == null) { unsetRolePrivileges(); } else { setRolePrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case USER_PRIVILEGES: if (value == null) { unsetUserPrivileges(); } else { setUserPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case GROUP_PRIVILEGES: if (value == null) { unsetGroupPrivileges(); } else { setGroupPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case ROLE_PRIVILEGES: if (value == null) { unsetRolePrivileges(); } else { setRolePrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case USER_PRIVILEGES: if (value == null) { unsetUserPrivileges(); } else { setUserPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case GROUP_PRIVILEGES: if (value == null) { unsetGroupPrivileges(); } else { setGroupPrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; case ROLE_PRIVILEGES: if (value == null) { unsetRolePrivileges(); } else { setRolePrivileges((Map<String,List<PrivilegeGrantInfo>>)value); } break; } }
principalPrivs.setUserPrivileges(grants.getUserGrants()); principalPrivs.setGroupPrivileges(grants.getGroupGrants()); principalPrivs.setRolePrivileges(grants.getRoleGrants()); tTbl.setPrivileges(principalPrivs);