Class UserPermissionProvider

java.lang.Object
de.murmelmeister.murmelapi.user.permission.UserPermissionProvider
All Implemented Interfaces:
UserPermission

public final class UserPermissionProvider extends Object implements UserPermission
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPermission(int executorId, int userId, String permission, long time)
    Adds a specific permission to a user with an optional expiration time.
    void
    clearPermission(int userId)
    Clears all permissions associated with a specific user.
    boolean
    existsPermission(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.
    int
    getCreatedBy(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.
    long
    getExpiredTime(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.
    int
    getModifiedBy(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.
    boolean
    isExpired(int userId, String permission)
    Checks if a specific permission for a given user has expired.
    void
    Loads all expired permissions for the specified user and performs operations related to the expired permissions.
    void
    removePermission(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
    setup(Database database)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UserPermissionProvider

      public UserPermissionProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsPermission

      public boolean existsPermission(int userId, String permission)
      Description copied from interface: UserPermission
      Checks whether a specific permission exists for a given user.
      Specified by:
      existsPermission in interface UserPermission
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission to check for the user.
      Returns:
      true if the permission exists for the user, otherwise false.
    • addPermission

      public void addPermission(int executorId, int userId, String permission, long time)
      Description copied from interface: UserPermission
      Adds a specific permission to a user with an optional expiration time.
      Specified by:
      addPermission in interface UserPermission
      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

      public void removePermission(int userId, String permission)
      Description copied from interface: UserPermission
      Removes a specific permission from a user.
      Specified by:
      removePermission in interface UserPermission
      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: UserPermission
      Clears all permissions associated with a specific user.
      Specified by:
      clearPermission in interface UserPermission
      Parameters:
      userId - The unique identifier of the user whose permissions will be cleared.
    • getPermissions

      public List<String> getPermissions(int userId)
      Description copied from interface: UserPermission
      Retrieves a list of permissions associated with a specific user.
      Specified by:
      getPermissions in interface UserPermission
      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

      public long getExpiredTime(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the expiration time of a specific permission for a given user.
      Specified by:
      getExpiredTime in interface UserPermission
      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

      public String getExpiredDate(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the expiration date of a specific permission for a given user. The expiration date is returned as a formatted string representation.
      Specified by:
      getExpiredDate in interface UserPermission
      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

      public String setExpiredTime(int executorId, int userId, String permission, long time)
      Description copied from interface: UserPermission
      Sets the expiration time for a specific permission associated with a user. Updates the expiration to the specified time in milliseconds.
      Specified by:
      setExpiredTime in interface UserPermission
      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

      public boolean isExpired(int userId, String permission)
      Description copied from interface: UserPermission
      Checks if a specific permission for a given user has expired.
      Specified by:
      isExpired in interface UserPermission
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission whose expiration status is being checked.
      Returns:
      true if the permission has expired, otherwise false.
    • getCreatedBy

      public int getCreatedBy(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the identifier of the user who created the specified permission for a given user.
      Specified by:
      getCreatedBy in interface UserPermission
      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

      public Timestamp getCreatedAt(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the creation timestamp of a specific permission for a given user.
      Specified by:
      getCreatedAt in interface UserPermission
      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

      public int getModifiedBy(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the identifier of the executor who last modified a specific permission associated with a user.
      Specified by:
      getModifiedBy in interface UserPermission
      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

      public Timestamp getModifiedAt(int userId, String permission)
      Description copied from interface: UserPermission
      Retrieves the timestamp indicating the last modification time of a specific permission associated with a given user.
      Specified by:
      getModifiedAt in interface UserPermission
      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 null if no modification timestamp is found.
    • loadExpired

      public void loadExpired(User user)
      Description copied from interface: UserPermission
      Loads all expired permissions for the specified user and performs operations related to the expired permissions.
      Specified by:
      loadExpired in interface UserPermission
      Parameters:
      user - The user whose expired permissions need to be loaded. This is the user object associated with the permissions.