use of io.trino.spi.security.PrivilegeInfo in project trino by trinodb.
the class SqlStandardAccessControlMetadata method buildGrants.
private List<GrantInfo> buildGrants(SchemaTableName tableName, Optional<HivePrincipal> principal) {
ImmutableList.Builder<GrantInfo> result = ImmutableList.builder();
Set<HivePrivilegeInfo> hivePrivileges = metastore.listTablePrivileges(tableName.getSchemaName(), tableName.getTableName(), principal);
for (HivePrivilegeInfo hivePrivilege : hivePrivileges) {
Set<PrivilegeInfo> prestoPrivileges = hivePrivilege.toPrivilegeInfo();
for (PrivilegeInfo prestoPrivilege : prestoPrivileges) {
GrantInfo grant = new GrantInfo(prestoPrivilege, hivePrivilege.getGrantee().toTrinoPrincipal(), tableName, Optional.of(hivePrivilege.getGrantor().toTrinoPrincipal()), Optional.empty());
result.add(grant);
}
}
return result.build();
}
Aggregations