forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#4236] feat(core): Supports the post-hook for the managers or …
…dispatcher
- Loading branch information
Showing
18 changed files
with
573 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
222 changes: 222 additions & 0 deletions
222
core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.authorization; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.gravitino.exceptions.GroupAlreadyExistsException; | ||
import org.apache.gravitino.exceptions.NoSuchGroupException; | ||
import org.apache.gravitino.exceptions.NoSuchMetalakeException; | ||
import org.apache.gravitino.exceptions.NoSuchRoleException; | ||
import org.apache.gravitino.exceptions.NoSuchUserException; | ||
import org.apache.gravitino.exceptions.RoleAlreadyExistsException; | ||
import org.apache.gravitino.exceptions.UserAlreadyExistsException; | ||
|
||
/** | ||
* This interface is related to the access control. This interface is mainly used for | ||
* LifecycleHooks. The lifecycleHooks used the InvocationHandler. The InvocationHandler can only | ||
* hook the interfaces. | ||
*/ | ||
public interface AccessControlDispatcher { | ||
/** | ||
* Adds a new User. | ||
* | ||
* @param metalake The Metalake of the User. | ||
* @param user The name of the User. | ||
* @return The added User instance. | ||
* @throws UserAlreadyExistsException If a User with the same name already exists. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If adding the User encounters storage issues. | ||
*/ | ||
User addUser(String metalake, String user) | ||
throws UserAlreadyExistsException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Removes a User. | ||
* | ||
* @param metalake The Metalake of the User. | ||
* @param user The name of the User. | ||
* @return True if the User was successfully removed, false only when there's no such user, | ||
* otherwise it will throw an exception. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If removing the User encounters storage issues. | ||
*/ | ||
boolean removeUser(String metalake, String user) throws NoSuchMetalakeException; | ||
|
||
/** | ||
* Gets a User. | ||
* | ||
* @param metalake The Metalake of the User. | ||
* @param user The name of the User. | ||
* @return The getting User instance. | ||
* @throws NoSuchUserException If the User with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If getting the User encounters storage issues. | ||
*/ | ||
User getUser(String metalake, String user) throws NoSuchUserException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Adds a new Group. | ||
* | ||
* @param metalake The Metalake of the Group. | ||
* @param group The name of the Group. | ||
* @return The Added Group instance. | ||
* @throws GroupAlreadyExistsException If a Group with the same name already exists. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If adding the Group encounters storage issues. | ||
*/ | ||
Group addGroup(String metalake, String group) | ||
throws GroupAlreadyExistsException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Removes a Group. | ||
* | ||
* @param metalake The Metalake of the Group. | ||
* @param group THe name of the Group. | ||
* @return True if the Group was successfully removed, false only when there's no such group, | ||
* otherwise it will throw an exception. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If removing the Group encounters storage issues. | ||
*/ | ||
boolean removeGroup(String metalake, String group) throws NoSuchMetalakeException; | ||
|
||
/** | ||
* Gets a Group. | ||
* | ||
* @param metalake The Metalake of the Group. | ||
* @param group The name of the Group. | ||
* @return The getting Group instance. | ||
* @throws NoSuchGroupException If the Group with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If getting the Group encounters storage issues. | ||
*/ | ||
Group getGroup(String metalake, String group) | ||
throws NoSuchGroupException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Grant roles to a user. | ||
* | ||
* @param metalake The metalake of the User. | ||
* @param user The name of the User. | ||
* @param roles The names of the Role. | ||
* @return The User after granted. | ||
* @throws NoSuchUserException If the User with the given name does not exist. | ||
* @throws NoSuchRoleException If the Role with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If granting roles to a user encounters storage issues. | ||
*/ | ||
User grantRolesToUser(String metalake, List<String> roles, String user) | ||
throws NoSuchUserException, NoSuchRoleException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Grant roles to a group. | ||
* | ||
* @param metalake The metalake of the Group. | ||
* @param group The name of the Group. | ||
* @param roles The names of the Role. | ||
* @return The Group after granted. | ||
* @throws NoSuchGroupException If the Group with the given name does not exist. | ||
* @throws NoSuchRoleException If the Role with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If granting roles to a group encounters storage issues. | ||
*/ | ||
Group grantRolesToGroup(String metalake, List<String> roles, String group) | ||
throws NoSuchGroupException, NoSuchRoleException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Revoke roles from a group. | ||
* | ||
* @param metalake The metalake of the Group. | ||
* @param group The name of the Group. | ||
* @param roles The name of the Role. | ||
* @return The Group after revoked. | ||
* @throws NoSuchGroupException If the Group with the given name does not exist. | ||
* @throws NoSuchRoleException If the Role with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If revoking roles from a group encounters storage issues. | ||
*/ | ||
Group revokeRolesFromGroup(String metalake, List<String> roles, String group) | ||
throws NoSuchGroupException, NoSuchRoleException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Revoke roles from a user. | ||
* | ||
* @param metalake The metalake of the User. | ||
* @param user The name of the User. | ||
* @param roles The name of the Role. | ||
* @return The User after revoked. | ||
* @throws NoSuchUserException If the User with the given name does not exist. | ||
* @throws NoSuchRoleException If the Role with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If revoking roles from a user encounters storage issues. | ||
*/ | ||
User revokeRolesFromUser(String metalake, List<String> roles, String user) | ||
throws NoSuchUserException, NoSuchRoleException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Judges whether the user is the service admin. | ||
* | ||
* @param user the name of the user | ||
* @return True if the user is service admin, otherwise false. | ||
*/ | ||
boolean isServiceAdmin(String user); | ||
|
||
/** | ||
* Creates a new Role. | ||
* | ||
* @param metalake The Metalake of the Role. | ||
* @param role The name of the Role. | ||
* @param properties The properties of the Role. | ||
* @param securableObjects The securable objects of the Role. | ||
* @return The created Role instance. | ||
* @throws RoleAlreadyExistsException If a Role with the same name already exists. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If creating the Role encounters storage issues. | ||
*/ | ||
Role createRole( | ||
String metalake, | ||
String role, | ||
Map<String, String> properties, | ||
List<SecurableObject> securableObjects) | ||
throws RoleAlreadyExistsException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Gets a Role. | ||
* | ||
* @param metalake The Metalake of the Role. | ||
* @param role The name of the Role. | ||
* @return The getting Role instance. | ||
* @throws NoSuchRoleException If the Role with the given name does not exist. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If getting the Role encounters storage issues. | ||
*/ | ||
Role getRole(String metalake, String role) throws NoSuchRoleException, NoSuchMetalakeException; | ||
|
||
/** | ||
* Deletes a Role. | ||
* | ||
* @param metalake The Metalake of the Role. | ||
* @param role The name of the Role. | ||
* @return True if the Role was successfully deleted, false only when there's no such role, | ||
* otherwise it will throw an exception. | ||
* @throws NoSuchMetalakeException If the Metalake with the given name does not exist. | ||
* @throws RuntimeException If deleting the Role encounters storage issues. | ||
*/ | ||
public boolean deleteRole(String metalake, String role) throws NoSuchMetalakeException; | ||
} |
Oops, something went wrong.