Skip to content

Commit

Permalink
Remove obsolete row filter and column mask methods
Browse files Browse the repository at this point in the history
The current deprecation policy, introduced around the time these methods
were deprecated, is that we promise to keep deprecated methods for one
more release. According to this, removal is long overdue.
  • Loading branch information
ksobolew authored and kokosing committed Jun 28, 2022
1 parent d809130 commit ac8d2d4
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
*/
package io.trino.security;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSecurityContext;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
Expand All @@ -28,8 +24,6 @@ public class TestInjectedConnectorAccessControl
public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(ConnectorAccessControl.class, InjectedConnectorAccessControl.class, ImmutableSet.of(
InjectedConnectorAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
InjectedConnectorAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(ConnectorAccessControl.class, InjectedConnectorAccessControl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -608,20 +608,6 @@ default void checkCanExecuteFunction(ConnectorSecurityContext context, FunctionK
denyExecuteFunction(function.toString());
}

/**
* Get a row filter associated with the given table and identity.
* <p>
* The filter must be a scalar SQL expression of boolean type over the columns in the table.
*
* @return the filter, or {@link Optional#empty()} if not applicable
* @deprecated use {@link #getRowFilters(ConnectorSecurityContext, SchemaTableName)} instead
*/
@Deprecated
default Optional<ViewExpression> getRowFilter(ConnectorSecurityContext context, SchemaTableName tableName)
{
return Optional.empty();
}

/**
* Get row filters associated with the given table and identity.
* <p>
Expand All @@ -634,21 +620,6 @@ default List<ViewExpression> getRowFilters(ConnectorSecurityContext context, Sch
return emptyList();
}

/**
* Get a column mask associated with the given table, column and identity.
* <p>
* The mask must be a scalar SQL expression of a type coercible to the type of the column being masked. The expression
* must be written in terms of columns in the table.
*
* @return the mask, or {@link Optional#empty()} if not applicable
* @deprecated use {@link #getColumnMasks(ConnectorSecurityContext, SchemaTableName, String, Type)} instead
*/
@Deprecated
default Optional<ViewExpression> getColumnMask(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type)
{
return Optional.empty();
}

/**
* Get column masks associated with the given table, column and identity.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,20 +829,6 @@ default void checkCanExecuteTableProcedure(SystemSecurityContext systemSecurityC
denyExecuteTableProcedure(table.toString(), procedure);
}

/**
* Get a row filter associated with the given table and identity.
* <p>
* The filter must be a scalar SQL expression of boolean type over the columns in the table.
*
* @return the filter, or {@link Optional#empty()} if not applicable
* @deprecated use {@link #getRowFilters(SystemSecurityContext, CatalogSchemaTableName)} instead
*/
@Deprecated
default Optional<ViewExpression> getRowFilter(SystemSecurityContext context, CatalogSchemaTableName tableName)
{
return Optional.empty();
}

/**
* Get row filters associated with the given table and identity.
* <p>
Expand All @@ -852,22 +838,7 @@ default Optional<ViewExpression> getRowFilter(SystemSecurityContext context, Cat
*/
default List<ViewExpression> getRowFilters(SystemSecurityContext context, CatalogSchemaTableName tableName)
{
return getRowFilter(context, tableName).map(List::of).orElseGet(List::of);
}

/**
* Get a column mask associated with the given table, column and identity.
* <p>
* The mask must be a scalar SQL expression of a type coercible to the type of the column being masked. The expression
* must be written in terms of columns in the table.
*
* @return the mask, or {@link Optional#empty()} if not applicable
* @deprecated use {@link #getColumnMasks(SystemSecurityContext, CatalogSchemaTableName, String, Type)} instead
*/
@Deprecated
default Optional<ViewExpression> getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type)
{
return Optional.empty();
return List.of();
}

/**
Expand All @@ -880,7 +851,7 @@ default Optional<ViewExpression> getColumnMask(SystemSecurityContext context, Ca
*/
default List<ViewExpression> getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type)
{
return getColumnMask(context, tableName, columnName, type).map(List::of).orElseGet(List::of);
return List.of();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,12 @@ public void checkCanExecuteFunction(ConnectorSecurityContext context, FunctionKi
delegate().checkCanExecuteFunction(context, functionKind, function);
}

@Override
public Optional<ViewExpression> getRowFilter(ConnectorSecurityContext context, SchemaTableName tableName)
{
return delegate().getRowFilter(context, tableName);
}

@Override
public List<ViewExpression> getRowFilters(ConnectorSecurityContext context, SchemaTableName tableName)
{
return delegate().getRowFilters(context, tableName);
}

@Override
public Optional<ViewExpression> getColumnMask(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type)
{
return delegate().getColumnMask(context, tableName, columnName, type);
}

@Override
public List<ViewExpression> getColumnMasks(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,24 +487,12 @@ public Iterable<EventListener> getEventListeners()
return delegate().getEventListeners();
}

@Override
public Optional<ViewExpression> getRowFilter(SystemSecurityContext context, CatalogSchemaTableName tableName)
{
return delegate().getRowFilter(context, tableName);
}

@Override
public List<ViewExpression> getRowFilters(SystemSecurityContext context, CatalogSchemaTableName tableName)
{
return delegate().getRowFilters(context, tableName);
}

@Override
public Optional<ViewExpression> getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type)
{
return delegate().getColumnMask(context, tableName, columnName, type);
}

@Override
public List<ViewExpression> getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,19 @@
*/
package io.trino.plugin.base.classloader;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorMetadata;
import io.trino.spi.connector.ConnectorNodePartitioningProvider;
import io.trino.spi.connector.ConnectorPageSink;
import io.trino.spi.connector.ConnectorPageSinkProvider;
import io.trino.spi.connector.ConnectorPageSourceProvider;
import io.trino.spi.connector.ConnectorRecordSetProvider;
import io.trino.spi.connector.ConnectorSecurityContext;
import io.trino.spi.connector.ConnectorSplitManager;
import io.trino.spi.connector.ConnectorSplitSource;
import io.trino.spi.connector.RecordSet;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.SystemTable;
import io.trino.spi.eventlistener.EventListener;
import io.trino.spi.ptf.ConnectorTableFunction;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import java.lang.reflect.Method;
Expand All @@ -47,9 +43,7 @@ public class TestClassLoaderSafeWrappers
public void test()
throws Exception
{
testClassLoaderSafe(ConnectorAccessControl.class, ClassLoaderSafeConnectorAccessControl.class, ImmutableSet.of(
ClassLoaderSafeConnectorAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
ClassLoaderSafeConnectorAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
testClassLoaderSafe(ConnectorAccessControl.class, ClassLoaderSafeConnectorAccessControl.class);
testClassLoaderSafe(ConnectorMetadata.class, ClassLoaderSafeConnectorMetadata.class);
testClassLoaderSafe(ConnectorPageSink.class, ClassLoaderSafeConnectorPageSink.class);
testClassLoaderSafe(ConnectorPageSinkProvider.class, ClassLoaderSafeConnectorPageSinkProvider.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
*/
package io.trino.plugin.base.security;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSecurityContext;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
Expand All @@ -28,8 +24,6 @@ public class TestAllowAllAccessControl
public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(ConnectorAccessControl.class, AllowAllAccessControl.class, ImmutableSet.of(
AllowAllAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
AllowAllAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(ConnectorAccessControl.class, AllowAllAccessControl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
*/
package io.trino.plugin.base.security;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.CatalogSchemaTableName;
import io.trino.spi.security.SystemAccessControl;
import io.trino.spi.security.SystemSecurityContext;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
Expand All @@ -28,8 +24,6 @@ public class TestAllowAllSystemAccessControl
public void testEverythingImplemented()
throws ReflectiveOperationException
{
assertAllMethodsOverridden(SystemAccessControl.class, AllowAllSystemAccessControl.class, ImmutableSet.of(
AllowAllSystemAccessControl.class.getMethod("getRowFilter", SystemSecurityContext.class, CatalogSchemaTableName.class),
AllowAllSystemAccessControl.class.getMethod("getColumnMask", SystemSecurityContext.class, CatalogSchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(SystemAccessControl.class, AllowAllSystemAccessControl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import io.trino.spi.security.Privilege;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.spi.security.ViewExpression;
import io.trino.spi.type.Type;
import org.testng.Assert.ThrowingRunnable;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -538,9 +537,7 @@ public void testSchemaRulesForCheckCanShowTables()
public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(ConnectorAccessControl.class, FileBasedAccessControl.class, ImmutableSet.of(
FileBasedAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
FileBasedAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(ConnectorAccessControl.class, FileBasedAccessControl.class);
}

private static ConnectorSecurityContext user(String name, Set<String> groups)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.trino.spi.security.SystemSecurityContext;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.spi.security.ViewExpression;
import io.trino.spi.type.Type;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -1370,8 +1369,6 @@ public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(SystemAccessControl.class, FileBasedSystemAccessControl.class, ImmutableSet.of(
FileBasedSystemAccessControl.class.getMethod("getRowFilter", SystemSecurityContext.class, CatalogSchemaTableName.class),
FileBasedSystemAccessControl.class.getMethod("getColumnMask", SystemSecurityContext.class, CatalogSchemaTableName.class, String.class, Type.class),
FileBasedSystemAccessControl.class.getMethod("checkCanViewQueryOwnedBy", SystemSecurityContext.class, Identity.class),
FileBasedSystemAccessControl.class.getMethod("filterViewQueryOwnedBy", SystemSecurityContext.class, Collection.class),
FileBasedSystemAccessControl.class.getMethod("checkCanKillQueryOwnedBy", SystemSecurityContext.class, Identity.class)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
*/
package io.trino.plugin.hive.security;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSecurityContext;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
Expand All @@ -28,8 +24,6 @@ public class TestLegacyAccessControl
public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(ConnectorAccessControl.class, LegacyAccessControl.class, ImmutableSet.of(
LegacyAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
LegacyAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(ConnectorAccessControl.class, LegacyAccessControl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
*/
package io.trino.plugin.hive.security;

import com.google.common.collect.ImmutableSet;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSecurityContext;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.type.Type;
import org.testng.annotations.Test;

import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
Expand All @@ -28,8 +24,6 @@ public class TestSqlStandardAccessControl
public void testEverythingImplemented()
throws NoSuchMethodException
{
assertAllMethodsOverridden(ConnectorAccessControl.class, SqlStandardAccessControl.class, ImmutableSet.of(
SqlStandardAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class),
SqlStandardAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class)));
assertAllMethodsOverridden(ConnectorAccessControl.class, SqlStandardAccessControl.class);
}
}

0 comments on commit ac8d2d4

Please sign in to comment.