use of io.prestosql.spi.security.Privilege in project hetu-core by openlookeng.
the class RevokeTask method execute.
@Override
public ListenableFuture<?> execute(Revoke statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, HeuristicIndexerManager heuristicIndexerManager) {
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
Set<Privilege> privileges;
if (statement.getPrivileges().isPresent()) {
privileges = statement.getPrivileges().get().stream().map(privilege -> parsePrivilege(statement, privilege)).collect(toImmutableSet());
} else {
// All privileges
privileges = EnumSet.allOf(Privilege.class);
}
// verify current identity has permissions to revoke permissions
for (Privilege privilege : privileges) {
accessControl.checkCanRevokeTablePrivilege(session.getRequiredTransactionId(), session.getIdentity(), privilege, tableName, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
}
metadata.revokeTablePrivileges(session, tableName, privileges, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
return immediateFuture(null);
}
use of io.prestosql.spi.security.Privilege in project hetu-core by openlookeng.
the class GrantTask method execute.
@Override
public ListenableFuture<?> execute(Grant statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, HeuristicIndexerManager heuristicIndexerManager) {
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
Set<Privilege> privileges;
if (statement.getPrivileges().isPresent()) {
privileges = statement.getPrivileges().get().stream().map(privilege -> parsePrivilege(statement, privilege)).collect(toImmutableSet());
} else {
// All privileges
privileges = EnumSet.allOf(Privilege.class);
}
// verify current identity has permissions to grant permissions
for (Privilege privilege : privileges) {
accessControl.checkCanGrantTablePrivilege(session.getRequiredTransactionId(), session.getIdentity(), privilege, tableName, createPrincipal(statement.getGrantee()), statement.isWithGrantOption());
}
metadata.grantTablePrivileges(session, tableName, privileges, createPrincipal(statement.getGrantee()), statement.isWithGrantOption());
return immediateFuture(null);
}
use of io.prestosql.spi.security.Privilege in project hetu-core by openlookeng.
the class SqlStandardAccessControlMetadata method revokeTablePrivileges.
@Override
public void revokeTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, HivePrincipal grantee, boolean grantOption) {
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream().map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption, new HivePrincipal(USER, session.getUser()), new HivePrincipal(USER, session.getUser()))).collect(toSet());
metastore.revokeTablePrivileges(schemaName, tableName, grantee, hivePrivilegeInfos);
}
use of io.prestosql.spi.security.Privilege in project hetu-core by openlookeng.
the class SqlStandardAccessControlMetadata method grantTablePrivileges.
@Override
public void grantTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, HivePrincipal grantee, boolean grantOption) {
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream().map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption, new HivePrincipal(USER, session.getUser()), new HivePrincipal(USER, session.getUser()))).collect(toSet());
metastore.grantTablePrivileges(schemaName, tableName, grantee, hivePrivilegeInfos);
}
use of io.prestosql.spi.security.Privilege in project boostkit-bigdata by kunpengcompute.
the class SqlStandardAccessControlMetadata method revokeTablePrivileges.
@Override
public void revokeTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, HivePrincipal grantee, boolean grantOption) {
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream().map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption, new HivePrincipal(USER, session.getUser()), new HivePrincipal(USER, session.getUser()))).collect(toSet());
metastore.revokeTablePrivileges(schemaName, tableName, grantee, hivePrivilegeInfos);
}
Aggregations