dbName = normalizeIdentifier(dbName); PrincipalPrivilegeSet ret = new PrincipalPrivilegeSet(); try { openTransaction(); dbUserPriv.put(userName, getDBPrivilege(catName, dbName, userName, PrincipalType.USER)); ret.setUserPrivileges(dbUserPriv); PrincipalType.GROUP)); ret.setGroupPrivileges(dbGroupPriv); .put(roleName, getDBPrivilege(catName, dbName, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(dbRolePriv);
public Object getFieldValue(_Fields field) { switch (field) { case USER_PRIVILEGES: return getUserPrivileges(); case GROUP_PRIVILEGES: return getGroupPrivileges(); case ROLE_PRIVILEGES: return getRolePrivileges(); } throw new IllegalStateException(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof PrincipalPrivilegeSet) return this.equals((PrincipalPrivilegeSet)that); return false; }
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; } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case USER_PRIVILEGES: return isSetUserPrivileges(); case GROUP_PRIVILEGES: return isSetGroupPrivileges(); case ROLE_PRIVILEGES: return isSetRolePrivileges(); } throw new IllegalStateException(); }
private static RequiredPrivileges getRequiredPrivsFromThrift(PrincipalPrivilegeSet thrifPrivs) throws HiveAuthzPluginException { RequiredPrivileges reqPrivs = new RequiredPrivileges(); // add user privileges Map<String, List<PrivilegeGrantInfo>> userPrivs = thrifPrivs.getUserPrivileges(); if (userPrivs != null && userPrivs.size() != 1) { throw new HiveAuthzPluginException("Invalid number of user privilege objects: " + userPrivs.size()); } addRequiredPrivs(reqPrivs, userPrivs); // add role privileges Map<String, List<PrivilegeGrantInfo>> rolePrivs = thrifPrivs.getRolePrivileges(); addRequiredPrivs(reqPrivs, rolePrivs); return reqPrivs; }
List<String> groupNames) throws InvalidObjectException, MetaException { boolean commited = false; PrincipalPrivilegeSet ret = new PrincipalPrivilegeSet(); try { openTransaction(); ret.setUserPrivileges(userPriv); ret.setGroupPrivileges(groupPriv);
/** * 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); }
case 6: // PRIVILEGES if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.privileges = new PrincipalPrivilegeSet(); struct.privileges.read(iprot); struct.setPrivilegesIsSet(true); } else {
protected PrincipalPrivilegeSet deepCopy(PrincipalPrivilegeSet pps) { PrincipalPrivilegeSet copy = null; if (pps != null) { copy = new PrincipalPrivilegeSet(pps); } return copy; }
@Override public boolean hasPrivilegeWithGrantOptionOnTable(String user, String databaseName, String tableName, HivePrivilege hivePrivilege) { try (HiveMetastoreClient metastoreClient = clientProvider.createMetastoreClient()) { PrincipalPrivilegeSet principalPrivilegeSet = metastoreClient.getPrivilegeSet(new HiveObjectRef(HiveObjectType.TABLE, databaseName, tableName, null, null), user, null); for (PrivilegeGrantInfo privilegeGrantInfo : principalPrivilegeSet.getUserPrivileges().get(user)) { if (privilegeGrantInfo.getPrivilege().equalsIgnoreCase(hivePrivilege.name()) && privilegeGrantInfo.isGrantOption()) { return true; } } return false; } catch (TException e) { throw new PrestoException(HIVE_METASTORE_ERROR, e); } }
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 RequiredPrivileges getRequiredPrivsFromThrift(PrincipalPrivilegeSet thrifPrivs) throws HiveAuthzPluginException { RequiredPrivileges reqPrivs = new RequiredPrivileges(); // add user privileges Map<String, List<PrivilegeGrantInfo>> userPrivs = thrifPrivs.getUserPrivileges(); if (userPrivs != null && userPrivs.size() != 1) { throw new HiveAuthzPluginException("Invalid number of user privilege objects: " + userPrivs.size()); } addRequiredPrivs(reqPrivs, userPrivs); // add role privileges Map<String, List<PrivilegeGrantInfo>> rolePrivs = thrifPrivs.getRolePrivileges(); addRequiredPrivs(reqPrivs, rolePrivs); return reqPrivs; }
public boolean equals(PrincipalPrivilegeSet that) { if (that == null) return false; boolean this_present_userPrivileges = true && this.isSetUserPrivileges(); boolean that_present_userPrivileges = true && that.isSetUserPrivileges(); if (this_present_userPrivileges || that_present_userPrivileges) { if (!(this_present_userPrivileges && that_present_userPrivileges)) return false; if (!this.userPrivileges.equals(that.userPrivileges)) return false; } boolean this_present_groupPrivileges = true && this.isSetGroupPrivileges(); boolean that_present_groupPrivileges = true && that.isSetGroupPrivileges(); if (this_present_groupPrivileges || that_present_groupPrivileges) { if (!(this_present_groupPrivileges && that_present_groupPrivileges)) return false; if (!this.groupPrivileges.equals(that.groupPrivileges)) return false; } boolean this_present_rolePrivileges = true && this.isSetRolePrivileges(); boolean that_present_rolePrivileges = true && that.isSetRolePrivileges(); if (this_present_rolePrivileges || that_present_rolePrivileges) { if (!(this_present_rolePrivileges && that_present_rolePrivileges)) return false; if (!this.rolePrivileges.equals(that.rolePrivileges)) return false; } return true; }
/** * 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); }
struct.privileges = new PrincipalPrivilegeSet(); struct.privileges.read(iprot); struct.setPrivilegesIsSet(true);
public PrincipalPrivilegeSet deepCopy() { return new PrincipalPrivilegeSet(this); }
List<String> groupNames) throws InvalidObjectException, MetaException { boolean commited = false; PrincipalPrivilegeSet ret = new PrincipalPrivilegeSet(); tableName = normalizeIdentifier(tableName); dbName = normalizeIdentifier(dbName); partUserPriv.put(userName, getPartitionPrivilege(catName, dbName, tableName, partition, userName, PrincipalType.USER)); ret.setUserPrivileges(partUserPriv); partition, groupName, PrincipalType.GROUP)); ret.setGroupPrivileges(partGroupPriv); partition, roleName, PrincipalType.ROLE)); ret.setRolePrivileges(partRolePriv);
if (privileges.getUserPrivileges() != null && privileges.getUserPrivileges().size() > 0) { Collection<List<PrivilegeGrantInfo>> privCollection = privileges.getUserPrivileges().values(); if (privileges.getGroupPrivileges() != null && privileges.getGroupPrivileges().size() > 0) { Collection<List<PrivilegeGrantInfo>> groupPrivCollection = privileges .getGroupPrivileges().values(); List<String> groupPrivs = getPrivilegeStringList(groupPrivCollection); if (groupPrivs != null && groupPrivs.size() > 0) { if (privileges.getRolePrivileges() != null && privileges.getRolePrivileges().size() > 0) { Collection<List<PrivilegeGrantInfo>> rolePrivsCollection = privileges .getRolePrivileges().values();
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; } }