Search in sources :

Example 1 with HiveTransactionHandle

use of com.facebook.presto.hive.HiveTransactionHandle in project presto by prestodb.

the class SqlStandardAccessControl method checkDatabasePermission.

private boolean checkDatabasePermission(ConnectorTransactionHandle transaction, Identity identity, String schemaName, HivePrivilege... requiredPrivileges) {
    SemiTransactionalHiveMetastore metastore = metastoreProvider.apply(((HiveTransactionHandle) transaction));
    Set<HivePrivilege> privilegeSet = metastore.getDatabasePrivileges(identity.getUser(), schemaName).stream().map(HivePrivilegeInfo::getHivePrivilege).collect(Collectors.toSet());
    return privilegeSet.containsAll(ImmutableSet.copyOf(requiredPrivileges));
}
Also used : SemiTransactionalHiveMetastore(com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore) HivePrivilegeInfo.toHivePrivilege(com.facebook.presto.hive.metastore.HivePrivilegeInfo.toHivePrivilege) HivePrivilege(com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege) HiveTransactionHandle(com.facebook.presto.hive.HiveTransactionHandle)

Example 2 with HiveTransactionHandle

use of com.facebook.presto.hive.HiveTransactionHandle in project presto by prestodb.

the class SqlStandardAccessControl method checkTablePermission.

private boolean checkTablePermission(ConnectorTransactionHandle transaction, Identity identity, SchemaTableName tableName, HivePrivilege... requiredPrivileges) {
    if (INFORMATION_SCHEMA_NAME.equals(tableName.getSchemaName())) {
        return true;
    }
    SemiTransactionalHiveMetastore metastore = metastoreProvider.apply(((HiveTransactionHandle) transaction));
    Set<HivePrivilege> privilegeSet = metastore.getTablePrivileges(identity.getUser(), tableName.getSchemaName(), tableName.getTableName()).stream().map(HivePrivilegeInfo::getHivePrivilege).collect(Collectors.toSet());
    return privilegeSet.containsAll(ImmutableSet.copyOf(requiredPrivileges));
}
Also used : SemiTransactionalHiveMetastore(com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore) HivePrivilegeInfo.toHivePrivilege(com.facebook.presto.hive.metastore.HivePrivilegeInfo.toHivePrivilege) HivePrivilege(com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege) HiveTransactionHandle(com.facebook.presto.hive.HiveTransactionHandle)

Aggregations

HiveTransactionHandle (com.facebook.presto.hive.HiveTransactionHandle)2 HivePrivilege (com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege)2 HivePrivilegeInfo.toHivePrivilege (com.facebook.presto.hive.metastore.HivePrivilegeInfo.toHivePrivilege)2 SemiTransactionalHiveMetastore (com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore)2