Interface IUserManager
-
- All Superinterfaces:
SnapshotProcessor
- All Known Implementing Classes:
BasicUserManager,LocalFileUserManager
public interface IUserManager extends SnapshotProcessor
This interface provides accesses to users.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancreateUser(java.lang.String username, java.lang.String password)Create a user with given username and password.booleandeleteUser(java.lang.String username)Delete a user.UsergetUser(java.lang.String username)Get a user object.booleangrantPrivilegeToUser(java.lang.String username, PartialPath path, int privilegeId)Grant a privilege on a seriesPath to a user.booleangrantRoleToUser(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>listAllUsers()List all users in the database.voidreplaceAllUsers(java.util.Map<java.lang.String,User> users)clear all old users info, replace the old users with the new one.voidreset()Re-initialize this object.booleanrevokePrivilegeFromUser(java.lang.String username, PartialPath path, int privilegeId)Revoke a privilege on seriesPath from a user.booleanrevokeRoleFromUser(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'.booleanupdateUserPassword(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
-
getUser
User getUser(java.lang.String username) throws AuthException
Get a user object.- Parameters:
username- The name of the user.- Returns:
- A user object whose name is username or null if such user does not exist.
- Throws:
AuthException- if an exception is raised when interacting with the lower storage.
-
createUser
boolean 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- Returns:
- True if the user is successfully created, false when the user already exists.
- Throws:
AuthException- if the given username or password is illegal.
-
deleteUser
boolean deleteUser(java.lang.String username) throws AuthExceptionDelete a user.- Parameters:
username- the username of the user.- Returns:
- True if the user is successfully deleted, false if the user does not exists.
- Throws:
AuthException- .
-
grantPrivilegeToUser
boolean 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.- Returns:
- True if the permission is successfully added, false if the permission already exists.
- Throws:
AuthException- If the user does not exist or the privilege or the seriesPath is illegal.
-
revokePrivilegeFromUser
boolean 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.- Returns:
- True if the permission is successfully revoked, false if the permission does not exists.
- Throws:
AuthException- If the user does not exist or the privilege or the seriesPath is illegal.
-
updateUserPassword
boolean 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.- Returns:
- True if the password is successfully modified, false if the new password is illegal.
- Throws:
AuthException- If the user does not exists.
-
grantRoleToUser
boolean 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.- Returns:
- True if the role is successfully added, false if the role already exists.
- Throws:
AuthException- If the user does not exist.
-
revokeRoleFromUser
boolean 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.- Returns:
- True if the role is successfully removed, false if the role does not exist.
- Throws:
AuthException- If the user does not exist.
-
reset
void reset() throws AuthExceptionRe-initialize this object.- Throws:
AuthException
-
listAllUsers
java.util.List<java.lang.String> listAllUsers()
List all users in the database.- Returns:
- A list that contains all users'name.
-
isUserUseWaterMark
boolean isUserUseWaterMark(java.lang.String userName) throws AuthExceptionWhether data water-mark is enabled for user 'userName'.- Parameters:
userName-- Returns:
- 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-useWaterMark-- Throws:
AuthException- if the user does not exist.
-
replaceAllUsers
void replaceAllUsers(java.util.Map<java.lang.String,User> users) throws AuthException
clear all old users info, replace the old users with the new one. The caller should guarantee that no other methods of this interface are invoked concurrently when this method is called.- Parameters:
users- new users info- Throws:
AuthException
-
-