Skip to content

Commit

Permalink
Add AccessDeniedException overloadings with extraInfo
Browse files Browse the repository at this point in the history
Some of the AccessDeniedException methods lack an
overloading with the extraInfo argument.  This commit
adds some of those overloadings for methods where an
explanation of why access was denied is informative.
  • Loading branch information
djsstarburst authored and dain committed May 17, 2022
1 parent b2f0351 commit 28ffbd7
Showing 1 changed file with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ public static void denyRenameSchema(String schemaName, String newSchemaName, Str

public static void denySetSchemaAuthorization(String schemaName, TrinoPrincipal principal)
{
throw new AccessDeniedException(format("Cannot set authorization for schema %s to %s", schemaName, principal));
denySetSchemaAuthorization(schemaName, principal, null);
}

public static void denySetSchemaAuthorization(String schemaName, TrinoPrincipal principal, String extraInfo)
{
throw new AccessDeniedException(format("Cannot set authorization for schema %s to %s%s", schemaName, principal, formatExtraInfo(extraInfo)));
}

public static void denyShowSchemas()
Expand All @@ -165,7 +170,12 @@ public static void denyShowSchemas(String extraInfo)

public static void denyShowCreateSchema(String schemaName)
{
throw new AccessDeniedException(format("Cannot show create schema for %s", schemaName));
denyShowCreateSchema(schemaName, null);
}

public static void denyShowCreateSchema(String schemaName, String extraInfo)
{
throw new AccessDeniedException(format("Cannot show create schema for %s%s", schemaName, formatExtraInfo(extraInfo)));
}

public static void denyShowCreateTable(String tableName)
Expand Down Expand Up @@ -275,7 +285,12 @@ public static void denyDropColumn(String tableName, String extraInfo)

public static void denySetTableAuthorization(String tableName, TrinoPrincipal principal)
{
throw new AccessDeniedException(format("Cannot set authorization for table %s to %s", tableName, principal));
denySetTableAuthorization(tableName, principal, null);
}

public static void denySetTableAuthorization(String tableName, TrinoPrincipal principal, String extraInfo)
{
throw new AccessDeniedException(format("Cannot set authorization for table %s to %s%s", tableName, principal, formatExtraInfo(extraInfo)));
}

public static void denyRenameColumn(String tableName)
Expand Down Expand Up @@ -385,7 +400,12 @@ public static void denyRenameView(String viewName, String newViewName, String ex

public static void denySetViewAuthorization(String viewName, TrinoPrincipal principal)
{
throw new AccessDeniedException(format("Cannot set authorization for view %s to %s", viewName, principal));
denySetViewAuthorization(viewName, principal, null);
}

public static void denySetViewAuthorization(String viewName, TrinoPrincipal principal, String extraInfo)
{
throw new AccessDeniedException(format("Cannot set authorization for view %s to %s%s", viewName, principal, formatExtraInfo(extraInfo)));
}

public static void denyDropView(String viewName)
Expand Down Expand Up @@ -600,7 +620,12 @@ public static void denySetRole(String role)

public static void denyExecuteProcedure(String procedureName)
{
throw new AccessDeniedException(format("Cannot execute procedure %s", procedureName));
denyExecuteProcedure(procedureName, null);
}

public static void denyExecuteProcedure(String procedureName, String extraInfo)
{
throw new AccessDeniedException(format("Cannot execute procedure %s%s", procedureName, formatExtraInfo(extraInfo)));
}

public static void denyExecuteFunction(String functionName)
Expand Down

0 comments on commit 28ffbd7

Please sign in to comment.