Class UserPool
java.lang.Object
org.deltava.security.UserPool
A singleton class for tracking connected and blocked users.
- Since:
- 1.0
- Version:
- 9.0
- Author:
- Luke
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds a person to the user pool.static void
Locks a user out of the application.static boolean
contains
(int userID) Queries whether a particular user is currently logged in.static int
Returns the maximum number of concurrent users.static Instant
Returns the date when the maximum number of concurrent users occurred.static Collection
<UserSession> Returns all logged in Pilots and their browser types.static int
getSize()
Returns the number of logged-in users.static void
Initializes the maximum size values.static boolean
Queries whether a particular user is locked out of the system.static void
Removes a person from the user pool, provided that the supplied Session ID matches.static void
Unlocks a user from the application.
-
Method Details
-
add
Adds a person to the user pool. See the notes forremove(Person, String)
for an explanation of why we add the session ID.- Parameters:
p
- the Pilot to addsessionID
- the session IDaddrInfo
- the user's IP address blockuserAgent
- the User-Agent header- See Also:
-
block
Locks a user out of the application.- Parameters:
p
- the user to block- See Also:
-
unblock
Unlocks a user from the application.- Parameters:
p
- the Person to block
-
remove
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 removesessionID
- 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
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
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
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
Initializes the maximum size values.- Parameters:
maxSize
- the maximum number of usersmaxSizeDate
- the date the maximum concurrent users was reached
-