diff --git a/core/src/main/java/com/scalar/db/api/AbacAdmin.java b/core/src/main/java/com/scalar/db/api/AbacAdmin.java index 4ae41b7cfa..287b82c724 100644 --- a/core/src/main/java/com/scalar/db/api/AbacAdmin.java +++ b/core/src/main/java/com/scalar/db/api/AbacAdmin.java @@ -339,51 +339,48 @@ default Optional getUserTagInfo(String policyName, String username) } /** - * Applies the given policy to the given namespace. + * Creates a namespace policy with the given policy and the given namespace. * + * @param namespacePolicyName the namespace policy name * @param policyName the policy name * @param namespaceName the namespace name * @throws ExecutionException if the operation fails */ - default void applyPolicyToNamespace(String policyName, String namespaceName) + default void createNamespacePolicy( + String namespacePolicyName, String policyName, String namespaceName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Enables the given policy for the given namespace. + * Enables a namespace policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name + * @param namespacePolicyName the namespace policy name * @throws ExecutionException if the operation fails */ - default void enableNamespacePolicy(String policyName, String namespaceName) - throws ExecutionException { + default void enableNamespacePolicy(String namespacePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Disables the given policy for the given namespace. + * Disables a namespace policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name + * @param namespacePolicyName the namespace policy name * @throws ExecutionException if the operation fails */ - default void disableNamespacePolicy(String policyName, String namespaceName) - throws ExecutionException { + default void disableNamespacePolicy(String namespacePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Retrieves the namespace policy for the given namespace. + * Retrieves a namespace policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name + * @param namespacePolicyName the namespace policy name * @return the namespace policy. If the policy is not applied to the namespace, returns an empty * optional * @throws ExecutionException if the operation fails */ - default Optional getNamespacePolicy(String policyName, String namespaceName) + default Optional getNamespacePolicy(String namespacePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } @@ -399,55 +396,48 @@ default List getNamespacePolicies() throws ExecutionException { } /** - * Applies the given policy to the given table of the given namespace. + * Creates a table policy with the given policy and the given table. * + * @param tablePolicyName the table policy name * @param policyName the policy name * @param namespaceName the namespace name * @param tableName the table name * @throws ExecutionException if the operation fails */ - default void applyPolicyToTable(String policyName, String namespaceName, String tableName) + default void createTablePolicy( + String tablePolicyName, String policyName, String namespaceName, String tableName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Enables the given policy of the given table of the given namespace. + * Enables a table policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name - * @param tableName the table name + * @param tablePolicyName the table policy name * @throws ExecutionException if the operation fails */ - default void enableTablePolicy(String policyName, String namespaceName, String tableName) - throws ExecutionException { + default void enableTablePolicy(String tablePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Disables the given policy of the given table of the given namespace. + * Disables a table policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name - * @param tableName the table name + * @param tablePolicyName the table policy name * @throws ExecutionException if the operation fails */ - default void disableTablePolicy(String policyName, String namespaceName, String tableName) - throws ExecutionException { + default void disableTablePolicy(String tablePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } /** - * Retrieves the table policy for the given table of the given namespace. + * Retrieves a table policy that has the given name. * - * @param policyName the policy name - * @param namespaceName the namespace name - * @param tableName the table name + * @param tablePolicyName the table policy name * @return the table policy. If the policy is not applied to the table, returns an empty optional * @throws ExecutionException if the operation fails */ - default Optional getTablePolicy( - String policyName, String namespaceName, String tableName) throws ExecutionException { + default Optional getTablePolicy(String tablePolicyName) throws ExecutionException { throw new UnsupportedOperationException(CoreError.ABAC_NOT_ENABLED.buildMessage()); } @@ -731,6 +721,13 @@ interface GroupInfo { /** The namespace policy. */ interface NamespacePolicy { + /** + * Returns the namespace policy name. + * + * @return the namespace policy name + */ + String getName(); + /** * Returns the policy name. * @@ -755,6 +752,13 @@ interface NamespacePolicy { /** The table policy. */ interface TablePolicy { + /** + * Returns the table policy name. + * + * @return the table policy name + */ + String getName(); + /** * Returns the policy name. * diff --git a/core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java b/core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java index 518fd40549..cf3657b419 100644 --- a/core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java +++ b/core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java @@ -492,27 +492,27 @@ public Optional getUserTagInfo(String policyName, String username) } @Override - public void applyPolicyToNamespace(String policyName, String namespaceName) + public void createNamespacePolicy( + String namespacePolicyName, String policyName, String namespaceName) throws ExecutionException { - distributedTransactionAdmin.applyPolicyToNamespace(policyName, namespaceName); + distributedTransactionAdmin.createNamespacePolicy( + namespacePolicyName, policyName, namespaceName); } @Override - public void enableNamespacePolicy(String policyName, String namespaceName) - throws ExecutionException { - distributedTransactionAdmin.enableNamespacePolicy(policyName, namespaceName); + public void enableNamespacePolicy(String namespacePolicyName) throws ExecutionException { + distributedTransactionAdmin.enableNamespacePolicy(namespacePolicyName); } @Override - public void disableNamespacePolicy(String policyName, String namespaceName) - throws ExecutionException { - distributedTransactionAdmin.disableNamespacePolicy(policyName, namespaceName); + public void disableNamespacePolicy(String namespacePolicyName) throws ExecutionException { + distributedTransactionAdmin.disableNamespacePolicy(namespacePolicyName); } @Override - public Optional getNamespacePolicy(String policyName, String namespaceName) + public Optional getNamespacePolicy(String namespacePolicyName) throws ExecutionException { - return distributedTransactionAdmin.getNamespacePolicy(policyName, namespaceName); + return distributedTransactionAdmin.getNamespacePolicy(namespacePolicyName); } @Override @@ -521,27 +521,26 @@ public List getNamespacePolicies() throws ExecutionException { } @Override - public void applyPolicyToTable(String policyName, String namespaceName, String tableName) + public void createTablePolicy( + String tablePolicyName, String policyName, String namespaceName, String tableName) throws ExecutionException { - distributedTransactionAdmin.applyPolicyToTable(policyName, namespaceName, tableName); + distributedTransactionAdmin.createTablePolicy( + tablePolicyName, policyName, namespaceName, tableName); } @Override - public void enableTablePolicy(String policyName, String namespaceName, String tableName) - throws ExecutionException { - distributedTransactionAdmin.enableTablePolicy(policyName, namespaceName, tableName); + public void enableTablePolicy(String tablePolicyName) throws ExecutionException { + distributedTransactionAdmin.enableTablePolicy(tablePolicyName); } @Override - public void disableTablePolicy(String policyName, String namespaceName, String tableName) - throws ExecutionException { - distributedTransactionAdmin.disableTablePolicy(policyName, namespaceName, tableName); + public void disableTablePolicy(String tablePolicyName) throws ExecutionException { + distributedTransactionAdmin.disableTablePolicy(tablePolicyName); } @Override - public Optional getTablePolicy( - String policyName, String namespaceName, String tableName) throws ExecutionException { - return distributedTransactionAdmin.getTablePolicy(policyName, namespaceName, tableName); + public Optional getTablePolicy(String tablePolicyName) throws ExecutionException { + return distributedTransactionAdmin.getTablePolicy(tablePolicyName); } @Override