Skip to content

Commit

Permalink
Remove deprecated checkCanCreateSchema
Browse files Browse the repository at this point in the history
Retaining the deprecated method was not sufficient for maintaining
compatibility, because the new method did not delegate to the old one.
Thus, if an implementor kept implementing only the old method, the
CREATE SCHEMA would get denied, irrespective of the implemented logic.
Removing the deprecated method makes the incompatibility clearer, as it
fails at the compilation time.
  • Loading branch information
findepi committed Jan 11, 2023
1 parent 1d6a0b4 commit 0fac087
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.trino.security;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.trino.metadata.QualifiedObjectName;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.CatalogSchemaName;
Expand Down Expand Up @@ -60,13 +59,6 @@ public void checkCanCreateSchema(ConnectorSecurityContext context, String schema
accessControl.checkCanCreateSchema(securityContext, getCatalogSchemaName(schemaName), properties);
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
checkArgument(context == null, "context must be null");
accessControl.checkCanCreateSchema(securityContext, getCatalogSchemaName(schemaName), ImmutableMap.of());
}

@Override
public void checkCanDropSchema(ConnectorSecurityContext context, String schemaName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ default void checkCanCreateSchema(ConnectorSecurityContext context, String schem
denyCreateSchema(schemaName);
}

/**
* Check if identity is allowed to create the specified schema.
*
* @throws io.trino.spi.security.AccessDeniedException if not allowed
*/
@Deprecated
default void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
denyCreateSchema(schemaName);
}

/**
* Check if identity is allowed to drop the specified schema.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,6 @@ default void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaNa
denyCreateSchema(schema.toString());
}

/**
* Check if identity is allowed to create the specified schema in a catalog.
*
* @throws AccessDeniedException if not allowed
*/
@Deprecated
default void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
denyCreateSchema(schema.toString());
}

/**
* Check if identity is allowed to drop the specified schema in a catalog.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public void checkCanCreateSchema(ConnectorSecurityContext context, String schema
}
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
delegate.checkCanCreateSchema(context, schemaName);
}
}

@Override
public void checkCanDropSchema(ConnectorSecurityContext context, String schemaName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public void checkCanCreateSchema(ConnectorSecurityContext context, String schema
{
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
}

@Override
public void checkCanDropSchema(ConnectorSecurityContext context, String schemaName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaNam
{
}

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
}

@Override
public void checkCanDropSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ public FileBasedAccessControl(CatalogName catalogName, AccessControlRules rules)

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName, Map<String, Object> properties)
{
checkCanCreateSchema(context, schemaName);
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
if (!isSchemaOwner(context, schemaName)) {
denyCreateSchema(schemaName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,6 @@ public Set<String> filterCatalogs(SystemSecurityContext context, Set<String> cat

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema, Map<String, Object> properties)
{
checkCanCreateSchema(context, schema);
}

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
if (!isSchemaOwner(context, schema)) {
denyCreateSchema(schema.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public void checkCanCreateSchema(ConnectorSecurityContext context, String schema
delegate().checkCanCreateSchema(context, schemaName, properties);
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
delegate().checkCanCreateSchema(context, schemaName);
}

@Override
public void checkCanDropSchema(ConnectorSecurityContext context, String schemaName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaNam
delegate().checkCanCreateSchema(context, schema, properties);
}

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
delegate().checkCanCreateSchema(context, schema);
}

@Override
public void checkCanDropSchema(SystemSecurityContext context, CatalogSchemaName schema)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public void checkCanCreateSchema(ConnectorSecurityContext context, String schema
{
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
}

@Override
public void checkCanDropSchema(ConnectorSecurityContext context, String schemaName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ public SqlStandardAccessControl(

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName, Map<String, Object> properties)
{
checkCanCreateSchema(context, schemaName);
}

@Override
public void checkCanCreateSchema(ConnectorSecurityContext context, String schemaName)
{
if (!isAdmin(context)) {
denyCreateSchema(schemaName);
Expand Down

0 comments on commit 0fac087

Please sign in to comment.