Class LoginHistoryProvider

java.lang.Object
de.murmelmeister.murmelapi.logging.LoginHistoryProvider
All Implemented Interfaces:
LoginHistory

public final class LoginHistoryProvider extends Object implements LoginHistory
  • Constructor Details

    • LoginHistoryProvider

      public LoginHistoryProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsLogin

      public boolean existsLogin(UUID loginId)
      Description copied from interface: LoginHistory
      Checks if a login record exists with the specified login ID.
      Specified by:
      existsLogin in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login record to check.
      Returns:
      true if a login record exists with the specified login ID, false otherwise.
    • deleteUserLogin

      public void deleteUserLogin(int userId)
      Description copied from interface: LoginHistory
      Deletes all login entries associated with the specified user ID.
      Specified by:
      deleteUserLogin in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose login history should be deleted.
    • getLogins

      public List<UUID> getLogins(int userId)
      Description copied from interface: LoginHistory
      Retrieves a list of login IDs (UUIDs) associated with a specific user.
      Specified by:
      getLogins in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose login records are being retrieved
      Returns:
      A list of UUIDs representing the login records for the specified user
    • getSortedLogins

      public List<UUID> getSortedLogins(int userId)
      Description copied from interface: LoginHistory
      Retrieves a list of login IDs associated with a specific user, sorted in descending order of login time, with a maximum limit.
      Specified by:
      getSortedLogins in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose sorted login records are to be retrieved
      Returns:
      A list of UUIDs representing the login records, sorted by login time
    • getLastLoginId

      public UUID getLastLoginId(int userId)
      Description copied from interface: LoginHistory
      Retrieves the most recent login ID for a specified user from their login history.
      Specified by:
      getLastLoginId in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose last login ID is to be retrieved.
      Returns:
      The UUID representing the most recent login ID for the specified user, or null if no login history exists for the user.
    • getLastQuit

      public Timestamp getLastQuit(int userId)
      Description copied from interface: LoginHistory
      Retrieves the timestamp of the most recent logout event for the specified user.
      Specified by:
      getLastQuit in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose last quit time is to be retrieved.
      Returns:
      A Timestamp object representing the time of the user's last quit, or null if no quit record exists for the specified user.
    • getUserIdsByIP

      public List<Integer> getUserIdsByIP(String ipAddress)
      Description copied from interface: LoginHistory
      Retrieves a list of user IDs associated with a specified IP address.
      Specified by:
      getUserIdsByIP in interface LoginHistory
      Parameters:
      ipAddress - The IP address for which the associated user IDs are to be retrieved.
      Returns:
      A list of integers representing the user IDs associated with the given IP address.
    • getUserId

      public int getUserId(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the user ID associated with the given login ID.
      Specified by:
      getUserId in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session
      Returns:
      The user ID linked to the specified login ID, or a negative value if not found
    • getIPAddress

      public String getIPAddress(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the IP address associated with a specific login session.
      Specified by:
      getIPAddress in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session
      Returns:
      The IP address as a string, or null if the login session does not exist or has no associated IP address
    • getFirstLoginTimeByUser

      public Timestamp getFirstLoginTimeByUser(int userId, String ipAddress)
      Description copied from interface: LoginHistory
      Retrieves the earliest login time for a specified user associated with a specific IP address.
      Specified by:
      getFirstLoginTimeByUser in interface LoginHistory
      Parameters:
      userId - The ID of the user whose first login time is to be retrieved.
      ipAddress - The IP address associated with the user's login.
      Returns:
      A Timestamp object representing the first login time for the user with the specified IP address, or null if no record is found.
    • getFirstLoginTimeByIP

      public Timestamp getFirstLoginTimeByIP(String ipAddress)
      Description copied from interface: LoginHistory
      Retrieves the first login timestamp associated with a specific IP address.
      Specified by:
      getFirstLoginTimeByIP in interface LoginHistory
      Parameters:
      ipAddress - The IP address for which the first login timestamp is to be retrieved
      Returns:
      The timestamp of the first login associated with the specified IP address, or null if no login records exist for the given IP address
    • getLastLoginTimeByUser

      public Timestamp getLastLoginTimeByUser(int userId, String ipAddress)
      Description copied from interface: LoginHistory
      Retrieves the most recent login time for a user based on their user ID and IP address.
      Specified by:
      getLastLoginTimeByUser in interface LoginHistory
      Parameters:
      userId - The unique identifier of the user whose last login time is to be retrieved.
      ipAddress - The IP address associated with the user's login.
      Returns:
      A Timestamp object representing the time of the user's last login from the specified IP address, or null if no login information is found.
    • getLastLoginTimeByIP

      public Timestamp getLastLoginTimeByIP(String ipAddress)
      Description copied from interface: LoginHistory
      Retrieves the last login time associated with the specified IP address.
      Specified by:
      getLastLoginTimeByIP in interface LoginHistory
      Parameters:
      ipAddress - The IP address for which the last login time is to be retrieved.
      Returns:
      A Timestamp representing the last login time for the specified IP address, or null if no such login record exists.
    • getLoginTime

      public Timestamp getLoginTime(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the login time for a specific login ID.
      Specified by:
      getLoginTime in interface LoginHistory
      Parameters:
      loginId - The unique identifier associated with the login.
      Returns:
      The timestamp indicating the login time, or null if no record is found.
    • getLogoutTime

      public Timestamp getLogoutTime(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the logout time associated with a specific login session.
      Specified by:
      getLogoutTime in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session
      Returns:
      The timestamp when the user logged out, or null if the logout time is not set
    • getLogoutDate

      public String getLogoutDate(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the formatted logout date associated with the given login ID. If no logout time is available, the method will return "never."
      Specified by:
      getLogoutDate in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session.
      Returns:
      A string representing the logout date in a formatted style, or "never" if the logout time is not available.
    • getClientVersion

      public String getClientVersion(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the client version associated with the given login ID.
      Specified by:
      getClientVersion in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session
      Returns:
      The client version string if found, or null if no client version is associated with the given login ID
    • getProtocolVersion

      public String getProtocolVersion(UUID loginId)
      Description copied from interface: LoginHistory
      Retrieves the protocol version associated with a specific login ID.
      Specified by:
      getProtocolVersion in interface LoginHistory
      Parameters:
      loginId - The unique identifier of the login session.
      Returns:
      The protocol version as a string, or null if not found.