Class UserPool

java.lang.Object
org.deltava.security.UserPool

public class UserPool extends Object
A singleton class for tracking connected and blocked users.
Since:
1.0
Version:
9.0
Author:
Luke
  • Method Details

    • add

      public static void add(Pilot p, String sessionID, IPBlock addrInfo, String userAgent)
      Adds a person to the user pool. See the notes for remove(Person, String) for an explanation of why we add the session ID.
      Parameters:
      p - the Pilot to add
      sessionID - the session ID
      addrInfo - the user's IP address block
      userAgent - the User-Agent header
      See Also:
    • block

      public static void block(Person p)
      Locks a user out of the application.
      Parameters:
      p - the user to block
      See Also:
    • unblock

      public static void unblock(Person p)
      Unlocks a user from the application.
      Parameters:
      p - the Person to block
    • remove

      public static void remove(Person p, String sessionID)
      Removes a person from the user pool, provided that the supplied Session ID matches. This additional check is performed because this method is usually called from a session lifecycle handler, and a session for a user may timeout after that same user has launched a new session. In such a circumstance, we do not want to remove the user from the pool.
      Parameters:
      p - the Person to remove
      sessionID - the session ID to match
      See Also:
    • contains

      public static boolean contains(int userID)
      Queries whether a particular user is currently logged in.
      Parameters:
      userID - The database ID of the person
      Returns:
      TRUE if the user is logged in, otherwise FALSE
      See Also:
    • isBlocked

      public static boolean isBlocked(Person usr)
      Queries whether a particular user is locked out of the system.
      Parameters:
      usr - the Pilot bean
      Returns:
      TRUE if the user is locked out, otherwise FALSE
      See Also:
    • getPilots

      public static Collection<UserSession> getPilots()
      Returns all logged in Pilots and their browser types.
      Returns:
      a Map of user agents, keyed by Pilot
    • getSize

      public static int getSize()
      Returns the number of logged-in users.
      Returns:
      the number of concurrent users
    • getMaxSize

      public static int getMaxSize()
      Returns the maximum number of concurrent users.
      Returns:
      the maxmimum number of concurrent users
      See Also:
    • getMaxSizeDate

      public static Instant getMaxSizeDate()
      Returns the date when the maximum number of concurrent users occurred.
      Returns:
      the date/time when the maximum user count was reached
      See Also:
    • init

      public static void init(int maxSize, Instant maxSizeDate)
      Initializes the maximum size values.
      Parameters:
      maxSize - the maximum number of users
      maxSizeDate - the date the maximum concurrent users was reached