Package com.logicaldoc.core.security
Class SessionManager
- All Implemented Interfaces:
- Serializable,- ConcurrentMap<String,,- Session> - Map<String,- Session> 
Repository of all current user sessions.
- Since:
- 4.6
- Author:
- Marco Meschieri - LogicalDOC
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMapConcurrentHashMap.KeySetView<K,V> Nested classes/interfaces inherited from class java.util.AbstractMapAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> 
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddListener(SessionListener listener) buildClient(jakarta.servlet.http.HttpServletRequest request) Create a client identified using a concatenation of Basic authentication credentials and remote IP.intCounts the total number of opened sessionsintcountOpened(long tenantId) Counts the total number of opened sessions per tenantvoiddestroy()booleanstatic final SessionManagerget()getByClientId(String clientId) Gets the session of the given clientgetByDictionaryValue(String key, Object value) Gets the session with the specified dictionary valuestatic StringRetrieves the session ID of the current thread executionjakarta.servlet.http.HttpSessiongetServletSession(String sid) getSession(jakarta.servlet.http.HttpServletRequest request) Gets the Session with the identifier returned bygetSessionId(HttpServletRequest)getSessionId(jakarta.servlet.http.HttpServletRequest request) Gets the Session ID specification from the current request following this lookup strategy: Request parameterPARAM_SIDRequest headerPARAM_SIDRequest attributePARAM_SIDSession attributePARAM_SIDCookieCOOKIE_SIDHeaderX-API-KEYClient ID Spring SecurityContextHolderReturns the list of sessions of the current node ordered by ascending status and creation date.intinthashCode()booleanChecks if a session is valid or not.voidKills an existing sessionnewSession(String apikey, Client client) Creates a new session by authenticating through an API Key and stores it in the pool of opened sessionsnewSession(String apikey, jakarta.servlet.http.HttpServletRequest request) Creates a new session by authenticating through an API Key and stores it in the pool of opened sessionsnewSession(String username, String password, Client client) Creates a new session by authenticating the given user and stores it in the pool of opened sessionsnewSession(String username, String password, jakarta.servlet.http.HttpServletRequest request) Creates a new session by authenticating the given user and stores it in the pool of opened sessionsnewSession(String username, String password, String key, Client client) Creates a new session by authenticating the given user and stores it in the pool of opened sessionsnewSession(String username, String password, String key, jakarta.servlet.http.HttpServletRequest request) Creates a new session by authenticating the given user and stores it in the pool of opened sessionsvoidremoveListener(SessionListener listener) voidremoveSid(jakarta.servlet.http.HttpServletRequest request) Removes the Sid from the http requestvoidRenews an opened sessionvoidsaveSid(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String sid) Saves the session identifier in the request and session attributePARAM_SIDand CookieCOOKIE_SIDMethods inherited from class java.util.concurrent.ConcurrentHashMapclear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, getOrDefault, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
- 
Field Details- 
COOKIE_SID- See Also:
 
- 
PARAM_SID- See Also:
 
- 
HEADER_APIKEY- See Also:
 
 
- 
- 
Constructor Details- 
SessionManagerpublic SessionManager()
 
- 
- 
Method Details- 
get
- 
newSessionpublic Session newSession(String username, String password, String key, jakarta.servlet.http.HttpServletRequest request) throws AuthenticationException Creates a new session by authenticating the given user and stores it in the pool of opened sessions- Parameters:
- username- the username
- password- the passowrd
- key- the secret key
- request- the current request
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
newSessionpublic Session newSession(String username, String password, jakarta.servlet.http.HttpServletRequest request) throws AuthenticationException Creates a new session by authenticating the given user and stores it in the pool of opened sessions- Parameters:
- username- the username
- password- the passowrd
- request- the current request
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
newSessionpublic Session newSession(String username, String password, Client client) throws AuthenticationException Creates a new session by authenticating the given user and stores it in the pool of opened sessions- Parameters:
- username- the username
- password- the passowrd
- client- client informations
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
newSessionpublic Session newSession(String username, String password, String key, Client client) throws AuthenticationException Creates a new session by authenticating the given user and stores it in the pool of opened sessions- Parameters:
- username- the username
- password- the passowrd
- key- the secret key
- client- client informations
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
newSessionCreates a new session by authenticating through an API Key and stores it in the pool of opened sessions- Parameters:
- apikey- the API Key
- client- client informations
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
newSessionpublic Session newSession(String apikey, jakarta.servlet.http.HttpServletRequest request) throws AuthenticationException Creates a new session by authenticating through an API Key and stores it in the pool of opened sessions- Parameters:
- apikey- the API Key
- request- the current request
- Returns:
- the session created after the successful login
- Throws:
- AuthenticationException- raised in case of failed login
 
- 
killKills an existing session- Parameters:
- sid- identifier of the session to kill
 
- 
remove
- 
renewRenews an opened session- Parameters:
- sid- The session to be renewed
 
- 
getStatus
- 
isOpenChecks if a session is valid or not. A valid session is a one that exists and is in state OPEN- Parameters:
- sid- The session identifier
- Returns:
- true only if the session exists and is OPEN
 
- 
get
- 
getByClientIdGets the session of the given client- Parameters:
- clientId- identifier of the client
- Returns:
- the session
 
- 
getByDictionaryValueGets the session with the specified dictionary value- Parameters:
- key- identifier of the value in the dictionary
- value- the value to match
- Returns:
- the session
 
- 
countOpenedpublic int countOpened()Counts the total number of opened sessions- Returns:
- number of opened sessions
 
- 
countOpenedpublic int countOpened(long tenantId) Counts the total number of opened sessions per tenant- Parameters:
- tenantId- identifier of the tenant
- Returns:
- number of opened sessions
 
- 
getSessionsReturns the list of sessions of the current node ordered by ascending status and creation date.- Returns:
- list of sessions
 
- 
getSessionGets the Session with the identifier returned bygetSessionId(HttpServletRequest)- Parameters:
- request- the HTTP request
- Returns:
- the found session, can be null
 
- 
getSessionIdGets the Session ID specification from the current request following this lookup strategy:- Request parameter PARAM_SID
- Request header PARAM_SID
- Request attribute PARAM_SID
- Session attribute PARAM_SID
- Cookie COOKIE_SID
- Header X-API-KEY
- Client ID
- Spring SecurityContextHolder
 - Parameters:
- request- The current request to inspect
- Returns:
- The SID if any
 
- Request parameter 
- 
saveSidpublic void saveSid(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String sid) Saves the session identifier in the request and session attributePARAM_SIDand CookieCOOKIE_SID- Parameters:
- request- the HTTP request
- response- the HTTP response
- sid- identifier of the session
 
- 
removeSidpublic void removeSid(jakarta.servlet.http.HttpServletRequest request) Removes the Sid from the http request- Parameters:
- request- the HTTP request
 
- 
getCurrentSidRetrieves the session ID of the current thread execution- Returns:
- the identifier of the session
 
- 
getServletSession
- 
buildClientCreate a client identified using a concatenation of Basic authentication credentials and remote IP.- Parameters:
- request- The request to process
- Returns:
- The client
 
- 
destroy@PreDestroy public void destroy()
- 
addListener
- 
removeListener
- 
hashCodepublic int hashCode()
- 
equals
 
-