Search in sources :

Example 1 with PrivilegeInfo

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();
}
Also used : HivePrivilegeInfo(io.trino.plugin.hive.metastore.HivePrivilegeInfo) ImmutableList(com.google.common.collect.ImmutableList) GrantInfo(io.trino.spi.security.GrantInfo) PrivilegeInfo(io.trino.spi.security.PrivilegeInfo) HivePrivilegeInfo(io.trino.plugin.hive.metastore.HivePrivilegeInfo)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 HivePrivilegeInfo (io.trino.plugin.hive.metastore.HivePrivilegeInfo)1 GrantInfo (io.trino.spi.security.GrantInfo)1 PrivilegeInfo (io.trino.spi.security.PrivilegeInfo)1