Search in sources :

Example 1 with PrivilegeInfo

use of com.facebook.presto.spi.security.PrivilegeInfo in project presto by prestodb.

the class HiveMetadata method buildGrants.

private List<GrantInfo> buildGrants(ConnectorSession session, SchemaTableName tableName, PrestoPrincipal principal) {
    ImmutableList.Builder<GrantInfo> result = ImmutableList.builder();
    MetastoreContext metastoreContext = getMetastoreContext(session);
    Set<HivePrivilegeInfo> hivePrivileges = metastore.listTablePrivileges(metastoreContext, 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(), tableName, Optional.of(hivePrivilege.getGrantor()), Optional.empty());
            result.add(grant);
        }
    }
    return result.build();
}
Also used : HivePrivilegeInfo(com.facebook.presto.hive.metastore.HivePrivilegeInfo) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) GrantInfo(com.facebook.presto.spi.security.GrantInfo) HivePrivilegeInfo(com.facebook.presto.hive.metastore.HivePrivilegeInfo) PrivilegeInfo(com.facebook.presto.spi.security.PrivilegeInfo)

Aggregations

HivePrivilegeInfo (com.facebook.presto.hive.metastore.HivePrivilegeInfo)1 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)1 GrantInfo (com.facebook.presto.spi.security.GrantInfo)1 PrivilegeInfo (com.facebook.presto.spi.security.PrivilegeInfo)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1