Interface IAuthorizer
-
- All Superinterfaces:
SnapshotProcessor
- All Known Implementing Classes:
BasicAuthorizer,LocalFileAuthorizer,OpenIdAuthorizer
public interface IAuthorizer extends SnapshotProcessor
This interface provides all authorization-relative operations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancheckUserPrivileges(java.lang.String username, PartialPath path, int privilegeId)Check if the user have the privilege on the seriesPath.voidcreateRole(java.lang.String roleName)Add a role.voidcreateUser(java.lang.String username, java.lang.String password)Create a user with given username and password.voiddeleteRole(java.lang.String roleName)Delete a role.voiddeleteUser(java.lang.String username)Delete a user.java.util.Map<java.lang.String,Role>getAllRoles()get all rolejava.util.Map<java.lang.String,User>getAllUsers()get all userjava.util.Map<java.lang.String,java.lang.Boolean>getAllUserWaterMarkStatus()get all user water mark statusjava.util.Set<java.lang.Integer>getPrivileges(java.lang.String username, PartialPath path)Get the all the privileges of a user on a seriesPath.RolegetRole(java.lang.String roleName)Find a role by its name.UsergetUser(java.lang.String username)Find a user by its name.voidgrantPrivilegeToRole(java.lang.String roleName, PartialPath path, int privilegeId)Add a privilege on a seriesPath to a role.voidgrantPrivilegeToUser(java.lang.String username, PartialPath path, int privilegeId)Grant a privilege on a seriesPath to a user.voidgrantRoleToUser(java.lang.String roleName, java.lang.String username)Add a role to a user.booleanisUserUseWaterMark(java.lang.String userName)Whether data water-mark is enabled for user 'userName'.java.util.List<java.lang.String>listAllRoles()List existing roles in the database.java.util.List<java.lang.String>listAllUsers()List existing users in the database.booleanlogin(java.lang.String username, java.lang.String password)Login for a user.voidreplaceAllRoles(java.util.Map<java.lang.String,Role> roles)clear all old role info, replace the old roles with the new onevoidreplaceAllUsers(java.util.Map<java.lang.String,User> users)clear all old user info, replace the old users with the new onevoidreset()Reset the Authorizer to initiative status.voidrevokePrivilegeFromRole(java.lang.String roleName, PartialPath path, int privilegeId)Remove a privilege on a seriesPath from a role.voidrevokePrivilegeFromUser(java.lang.String username, PartialPath path, int privilegeId)Revoke a privilege on seriesPath from a user.voidrevokeRoleFromUser(java.lang.String roleName, java.lang.String username)Revoke a role from a user.voidsetUserUseWaterMark(java.lang.String userName, boolean useWaterMark)Enable or disable data water-mark for user 'userName'.voidupdateUserPassword(java.lang.String username, java.lang.String newPassword)Modify the password of a user.-
Methods inherited from interface org.apache.iotdb.commons.snapshot.SnapshotProcessor
processLoadSnapshot, processTakeSnapshot
-
-
-
-
Method Detail
-
login
boolean login(java.lang.String username, java.lang.String password) throws AuthExceptionLogin for a user.- Parameters:
username- The username of the user.password- The password of the user.- Returns:
- True if such user exists and the given password is correct, else return false.
- Throws:
AuthException- if exception raised when searching for the user.
-
createUser
void createUser(java.lang.String username, java.lang.String password) throws AuthExceptionCreate a user with given username and password. New users will only be granted no privileges.- Parameters:
username- is not null or emptypassword- is not null or empty- Throws:
AuthException- if the given username or password is illegal or the user already exists.
-
deleteUser
void deleteUser(java.lang.String username) throws AuthExceptionDelete a user.- Parameters:
username- the username of the user.- Throws:
AuthException- When attempting to delete the default administrator or the user does not exists.
-
grantPrivilegeToUser
void grantPrivilegeToUser(java.lang.String username, PartialPath path, int privilegeId) throws AuthExceptionGrant a privilege on a seriesPath to a user.- Parameters:
username- The username of the user to which the privilege should be added.path- The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".privilegeId- An integer that represents a privilege.- Throws:
AuthException- If the user does not exist or the privilege or the seriesPath is illegal or the permission already exists.
-
revokePrivilegeFromUser
void revokePrivilegeFromUser(java.lang.String username, PartialPath path, int privilegeId) throws AuthExceptionRevoke a privilege on seriesPath from a user.- Parameters:
username- The username of the user from which the privilege should be removed.path- The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".privilegeId- An integer that represents a privilege.- Throws:
AuthException- If the user does not exist or the privilege or the seriesPath is illegal or if the permission does not exist.
-
createRole
void createRole(java.lang.String roleName) throws AuthExceptionAdd a role.- Parameters:
roleName- the name of the role to be added.- Throws:
AuthException- if exception raised when adding the role or the role already exists.
-
deleteRole
void deleteRole(java.lang.String roleName) throws AuthExceptionDelete a role.- Parameters:
roleName- the name of the role tobe deleted.- Throws:
AuthException- if exception raised when deleting the role or the role does not exists.
-
grantPrivilegeToRole
void grantPrivilegeToRole(java.lang.String roleName, PartialPath path, int privilegeId) throws AuthExceptionAdd a privilege on a seriesPath to a role.- Parameters:
roleName- The name of the role to which the privilege is added.path- The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".privilegeId- An integer that represents a privilege.- Throws:
AuthException- If the role does not exist or the privilege or the seriesPath is illegal or the privilege already exists.
-
revokePrivilegeFromRole
void revokePrivilegeFromRole(java.lang.String roleName, PartialPath path, int privilegeId) throws AuthExceptionRemove a privilege on a seriesPath from a role.- Parameters:
roleName- The name of the role from which the privilege is removed.path- The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".privilegeId- An integer that represents a privilege.- Throws:
AuthException- If the role does not exist or the privilege or the seriesPath is illegal or the privilege does not exists.
-
grantRoleToUser
void grantRoleToUser(java.lang.String roleName, java.lang.String username) throws AuthExceptionAdd a role to a user.- Parameters:
roleName- The name of the role to be added.username- The name of the user to which the role is added.- Throws:
AuthException- If either the role or the user does not exist or the role already exists.
-
revokeRoleFromUser
void revokeRoleFromUser(java.lang.String roleName, java.lang.String username) throws AuthExceptionRevoke a role from a user.- Parameters:
roleName- The name of the role to be removed.username- The name of the user from which the role is removed.- Throws:
AuthException- If either the role or the user does not exist or the role already exists.
-
getPrivileges
java.util.Set<java.lang.Integer> getPrivileges(java.lang.String username, PartialPath path) throws AuthExceptionGet the all the privileges of a user on a seriesPath.- Parameters:
username- The user whose privileges are to be queried.path- The seriesPath on which the privileges take effect. If the privilege is a seriesPath-free privilege, this should be "root".- Returns:
- A set of integers each present a privilege.
- Throws:
AuthException- if exception raised when finding the privileges.
-
updateUserPassword
void updateUserPassword(java.lang.String username, java.lang.String newPassword) throws AuthExceptionModify the password of a user.- Parameters:
username- The user whose password is to be modified.newPassword- The new password.- Throws:
AuthException- If the user does not exists or the new password is illegal.
-
checkUserPrivileges
boolean checkUserPrivileges(java.lang.String username, PartialPath path, int privilegeId) throws AuthExceptionCheck if the user have the privilege on the seriesPath.- Parameters:
username- The name of the user whose privileges are checked.path- The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".privilegeId- An integer that represents a privilege.- Returns:
- True if the user has such privilege, false if the user does not have such privilege.
- Throws:
AuthException- If the seriesPath or the privilege is illegal.
-
reset
void reset() throws AuthExceptionReset the Authorizer to initiative status.- Throws:
AuthException
-
listAllUsers
java.util.List<java.lang.String> listAllUsers()
List existing users in the database.- Returns:
- A list contains all usernames.
-
listAllRoles
java.util.List<java.lang.String> listAllRoles()
List existing roles in the database.- Returns:
- A list contains all roleNames.
-
getRole
Role getRole(java.lang.String roleName) throws AuthException
Find a role by its name.- Parameters:
roleName- the name of the role.- Returns:
- A role whose name is roleName or null if such role does not exist.
- Throws:
AuthException
-
getUser
User getUser(java.lang.String username) throws AuthException
Find a user by its name.- Parameters:
username- the name of the user.- Returns:
- A user whose name is username or null if such user does not exist.
- Throws:
AuthException
-
isUserUseWaterMark
boolean isUserUseWaterMark(java.lang.String userName) throws AuthExceptionWhether data water-mark is enabled for user 'userName'.- Parameters:
userName- the name of user- Throws:
AuthException- if the user does not exist
-
setUserUseWaterMark
void setUserUseWaterMark(java.lang.String userName, boolean useWaterMark) throws AuthExceptionEnable or disable data water-mark for user 'userName'.- Parameters:
userName- the name of useruseWaterMark- whether to use water-mark or not- Throws:
AuthException- if the user does not exist.
-
getAllUserWaterMarkStatus
java.util.Map<java.lang.String,java.lang.Boolean> getAllUserWaterMarkStatus()
get all user water mark status- Returns:
- key->userName, value->useWaterMark or not
-
getAllUsers
java.util.Map<java.lang.String,User> getAllUsers()
get all user- Returns:
- key-> userName, value->user
-
getAllRoles
java.util.Map<java.lang.String,Role> getAllRoles()
get all role- Returns:
- key->userName, value->role
-
replaceAllUsers
void replaceAllUsers(java.util.Map<java.lang.String,User> users) throws AuthException
clear all old user info, replace the old users with the new one- Parameters:
users- new users info- Throws:
AuthException- IOException
-
replaceAllRoles
void replaceAllRoles(java.util.Map<java.lang.String,Role> roles) throws AuthException
clear all old role info, replace the old roles with the new one- Parameters:
roles- new roles info- Throws:
AuthException- IOException
-
-