use of io.trino.spi.security.Privilege in project trino by trinodb.
the class DenyTask method executeDenyOnSchema.
private static void executeDenyOnSchema(Session session, Deny statement, Metadata metadata, AccessControl accessControl) {
CatalogSchemaName schemaName = createCatalogSchemaName(session, statement, Optional.of(statement.getName()));
if (!metadata.schemaExists(session, schemaName)) {
throw semanticException(SCHEMA_NOT_FOUND, statement, "Schema '%s' does not exist", schemaName);
}
Set<Privilege> privileges = parseStatementPrivileges(statement);
for (Privilege privilege : privileges) {
accessControl.checkCanDenySchemaPrivilege(session.toSecurityContext(), privilege, schemaName, createPrincipal(statement.getGrantee()));
}
metadata.denySchemaPrivileges(session, schemaName, privileges, createPrincipal(statement.getGrantee()));
}
use of io.trino.spi.security.Privilege in project trino by trinodb.
the class DenyTask method executeDenyOnTable.
private static void executeDenyOnTable(Session session, Deny statement, Metadata metadata, AccessControl accessControl) {
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (tableHandle.isEmpty()) {
throw semanticException(TABLE_NOT_FOUND, statement, "Table '%s' does not exist", tableName);
}
Set<Privilege> privileges = parseStatementPrivileges(statement);
for (Privilege privilege : privileges) {
accessControl.checkCanDenyTablePrivilege(session.toSecurityContext(), privilege, tableName, createPrincipal(statement.getGrantee()));
}
metadata.denyTablePrivileges(session, tableName, privileges, createPrincipal(statement.getGrantee()));
}
use of io.trino.spi.security.Privilege in project trino by trinodb.
the class RevokeTask method executeRevokeOnSchema.
private void executeRevokeOnSchema(Session session, Revoke statement) {
CatalogSchemaName schemaName = createCatalogSchemaName(session, statement, Optional.of(statement.getName()));
if (!metadata.schemaExists(session, schemaName)) {
throw semanticException(SCHEMA_NOT_FOUND, statement, "Schema '%s' does not exist", schemaName);
}
Set<Privilege> privileges = parseStatementPrivileges(statement);
for (Privilege privilege : privileges) {
accessControl.checkCanRevokeSchemaPrivilege(session.toSecurityContext(), privilege, schemaName, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
}
metadata.revokeSchemaPrivileges(session, schemaName, privileges, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
}
use of io.trino.spi.security.Privilege in project trino by trinodb.
the class RevokeTask method executeRevokeOnTable.
private void executeRevokeOnTable(Session session, Revoke statement) {
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (tableHandle.isEmpty()) {
throw semanticException(TABLE_NOT_FOUND, statement, "Table '%s' does not exist", tableName);
}
Set<Privilege> privileges = parseStatementPrivileges(statement);
for (Privilege privilege : privileges) {
accessControl.checkCanRevokeTablePrivilege(session.toSecurityContext(), privilege, tableName, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
}
metadata.revokeTablePrivileges(session, tableName, privileges, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor());
}
use of io.trino.spi.security.Privilege in project trino by trinodb.
the class GrantTask method executeGrantOnSchema.
private void executeGrantOnSchema(Session session, Grant statement) {
CatalogSchemaName schemaName = createCatalogSchemaName(session, statement, Optional.of(statement.getName()));
if (!metadata.schemaExists(session, schemaName)) {
throw semanticException(SCHEMA_NOT_FOUND, statement, "Schema '%s' does not exist", schemaName);
}
Set<Privilege> privileges = parseStatementPrivileges(statement);
for (Privilege privilege : privileges) {
accessControl.checkCanGrantSchemaPrivilege(session.toSecurityContext(), privilege, schemaName, createPrincipal(statement.getGrantee()), statement.isWithGrantOption());
}
metadata.grantSchemaPrivileges(session, schemaName, privileges, createPrincipal(statement.getGrantee()), statement.isWithGrantOption());
}
Aggregations