Class UserPermissionProvider
java.lang.Object
de.murmelmeister.murmelapi.user.permission.UserPermissionProvider
- All Implemented Interfaces:
UserPermission
-
Constructor Summary
Constructors -
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.static void
-
Constructor Details
-
UserPermissionProvider
-
-
Method Details
-
setup
-
existsPermission
Description copied from interface:UserPermissionChecks whether a specific permission exists for a given user.- Specified by:
existsPermissionin interfaceUserPermission- 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
Description copied from interface:UserPermissionAdds a specific permission to a user with an optional expiration time.- Specified by:
addPermissionin interfaceUserPermission- 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
Description copied from interface:UserPermissionRemoves a specific permission from a user.- Specified by:
removePermissionin interfaceUserPermission- 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
public void clearPermission(int userId) Description copied from interface:UserPermissionClears all permissions associated with a specific user.- Specified by:
clearPermissionin interfaceUserPermission- Parameters:
userId- The unique identifier of the user whose permissions will be cleared.
-
getPermissions
Description copied from interface:UserPermissionRetrieves a list of permissions associated with a specific user.- Specified by:
getPermissionsin interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the expiration time of a specific permission for a given user.- Specified by:
getExpiredTimein interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the expiration date of a specific permission for a given user. The expiration date is returned as a formatted string representation.- Specified by:
getExpiredDatein interfaceUserPermission- 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
Description copied from interface:UserPermissionSets the expiration time for a specific permission associated with a user. Updates the expiration to the specified time in milliseconds.- Specified by:
setExpiredTimein interfaceUserPermission- 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
Description copied from interface:UserPermissionChecks if a specific permission for a given user has expired.- Specified by:
isExpiredin interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the identifier of the user who created the specified permission for a given user.- Specified by:
getCreatedByin interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the creation timestamp of a specific permission for a given user.- Specified by:
getCreatedAtin interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the identifier of the executor who last modified a specific permission associated with a user.- Specified by:
getModifiedByin interfaceUserPermission- 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
Description copied from interface:UserPermissionRetrieves the timestamp indicating the last modification time of a specific permission associated with a given user.- Specified by:
getModifiedAtin interfaceUserPermission- 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
Description copied from interface:UserPermissionLoads all expired permissions for the specified user and performs operations related to the expired permissions.- Specified by:
loadExpiredin interfaceUserPermission- Parameters:
user- The user whose expired permissions need to be loaded. This is the user object associated with the permissions.
-