Interface UserPermission
- All Known Implementing Classes:
UserPermissionProvider
User permission interface to manage user permissions.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPermission(int executorId, int userId, String permission, long time) Adds a specific permission to a user with an optional expiration time.voidclearPermission(int userId) Clears all permissions associated with a specific user.booleanexistsPermission(int userId, String permission) Checks whether a specific permission exists for a given user.getCreatedAt(int userId, String permission) Retrieves the creation timestamp of a specific permission for a given user.intgetCreatedBy(int userId, String permission) Retrieves the identifier of the user who created the specified permission for a given user.getExpiredDate(int userId, String permission) Retrieves the expiration date of a specific permission for a given user.longgetExpiredTime(int userId, String permission) Retrieves the expiration time of a specific permission for a given user.getModifiedAt(int userId, String permission) Retrieves the timestamp indicating the last modification time of a specific permission associated with a given user.intgetModifiedBy(int userId, String permission) Retrieves the identifier of the executor who last modified a specific permission associated with a user.getPermissions(int userId) Retrieves a list of permissions associated with a specific user.booleanChecks if a specific permission for a given user has expired.voidloadExpired(User user) Loads all expired permissions for the specified user and performs operations related to the expired permissions.voidremovePermission(int userId, String permission) Removes a specific permission from a user.setExpiredTime(int executorId, int userId, String permission, long time) Sets the expiration time for a specific permission associated with a user.
-
Method Details
-
existsPermission
Checks whether a specific permission exists for a given user.- Parameters:
userId- The unique identifier of the user.permission- The permission to check for the user.- Returns:
trueif the permission exists for the user, otherwisefalse.
-
addPermission
Adds a specific permission to a user with an optional expiration time.- Parameters:
executorId- The unique identifier for the log entry of the operation.userId- The unique identifier of the user to whom the permission will be added.permission- The permission string to be added to the user.time- The expiration time for the permission in milliseconds. Use -1 for no expiration.
-
removePermission
Removes a specific permission from a user.- Parameters:
userId- The unique identifier of the user from whom the permission will be removed.permission- The permission string to be removed from the user.
-
clearPermission
void clearPermission(int userId) Clears all permissions associated with a specific user.- Parameters:
userId- The unique identifier of the user whose permissions will be cleared.
-
getPermissions
Retrieves a list of permissions associated with a specific user.- Parameters:
userId- The unique identifier of the user whose permissions are being retrieved.- Returns:
- A list of permission strings associated with the specified user.
-
getExpiredTime
Retrieves the expiration time of a specific permission for a given user.- Parameters:
userId- The unique identifier of the user.permission- The permission for which the expiration time is being retrieved.- Returns:
- The expiration time in milliseconds since the epoch for the specified permission and user. Returns -1 if the permission has no expiration time.
-
getExpiredDate
Retrieves the expiration date of a specific permission for a given user. The expiration date is returned as a formatted string representation.- Parameters:
userId- The unique identifier of the user.permission- The permission for which the expiration date is being retrieved.- Returns:
- A string representation of the expiration date for the specified user and permission. Returns an empty string if the permission has no expiration date.
-
setExpiredTime
Sets the expiration time for a specific permission associated with a user. Updates the expiration to the specified time in milliseconds.- Parameters:
executorId- The unique identifier for the log entry of the operation.userId- The unique identifier of the user.permission- The permission for which the expiration time will be set.time- The expiration time in milliseconds since the epoch. Use -1 for no expiration.- Returns:
- A string indicating the status of the operation, such as success or an error message.
-
isExpired
Checks if a specific permission for a given user has expired.- Parameters:
userId- The unique identifier of the user.permission- The permission whose expiration status is being checked.- Returns:
trueif the permission has expired, otherwisefalse.
-
getCreatedBy
Retrieves the identifier of the user who created the specified permission for a given user.- Parameters:
userId- The unique identifier of the user for whom the permission was created.permission- The permission whose creator's identifier is to be retrieved.- Returns:
- The unique identifier of the user who created the specified permission.
-
getCreatedAt
Retrieves the creation timestamp of a specific permission for a given user.- Parameters:
userId- The unique identifier of the user.permission- The permission for which the creation timestamp is being retrieved.- Returns:
- The timestamp indicating when the specified permission was created for the user.
-
getModifiedBy
Retrieves the identifier of the executor who last modified a specific permission associated with a user.- Parameters:
userId- The unique identifier of the user whose permission modification details are being retrieved.permission- The permission for which the modification details are being retrieved.- Returns:
- The unique identifier of the executor who last modified the specified permission for the given user.
-
getModifiedAt
Retrieves the timestamp indicating the last modification time of a specific permission associated with a given user.- Parameters:
userId- The unique identifier of the user whose permission modification timestamp is needed.permission- The permission for which the last modification time will be retrieved.- Returns:
- The timestamp representing the last modification time of the specified permission
for the given user. Returns
nullif no modification timestamp is found.
-
loadExpired
Loads all expired permissions for the specified user and performs operations related to the expired permissions.- Parameters:
user- The user whose expired permissions need to be loaded. This is the user object associated with the permissions.
-