Package ch.tocco.nice2.userbase.impl
Class SessionManagerImpl
java.lang.Object
ch.tocco.nice2.userbase.impl.SessionManagerImpl
- All Implemented Interfaces:
SessionManager
-
Field Summary
Fields inherited from interface ch.tocco.nice2.userbase.api.SessionManager
SESSION_TIME_OUT_MILLISECONDS, SESSION_TIME_OUT_MINUTES -
Constructor Summary
ConstructorsConstructorDescriptionSessionManagerImpl(org.slf4j.Logger log, PrincipalService principalService, CommandExecutor executor, QueryBuilderFactory queryBuilderFactory) -
Method Summary
Modifier and TypeMethodDescriptioncreateSession(String username, ApiKey apiKey, String ipAddress, @Nullable String userAgent) createSession(String username, String ipAddress, @Nullable String userAgent) Creates a new session for the existing principal.voiddeleteAllSessions(String username, boolean includingCurrent) Deletes all available sessions of specified principal.voiddeleteExpiredSessions(long timeoutMillis) Removes at mostamountsessions that are older than the specified time out.voiddeleteSession(UUID uuid) Deletes the session with the specified uuid.getSession(UUID uuid, long timeoutMillis, @Nullable String userAgent, @Nullable ApiKey apiKey) Finds the session with the specified uuid, which is not older than the specified timeout (= session.time>=(now-timeout)) and has the same user agent.booleanisSessionActive(UUID uuid, long timeoutMillis)
-
Constructor Details
-
SessionManagerImpl
public SessionManagerImpl(org.slf4j.Logger log, PrincipalService principalService, CommandExecutor executor, QueryBuilderFactory queryBuilderFactory)
-
-
Method Details
-
deleteExpiredSessions
Description copied from interface:SessionManagerRemoves at mostamountsessions that are older than the specified time out.- Specified by:
deleteExpiredSessionsin interfaceSessionManager- Parameters:
timeoutMillis- timeout to find sessions older than this- Throws:
SessionDataException
-
getSession
public Optional<Session> getSession(UUID uuid, long timeoutMillis, @Nullable @Nullable String userAgent, @Nullable @Nullable ApiKey apiKey) throws SessionDataException Description copied from interface:SessionManagerFinds the session with the specified uuid, which is not older than the specified timeout (= session.time>=(now-timeout)) and has the same user agent. Session time is updated automatically.- Specified by:
getSessionin interfaceSessionManager- Parameters:
uuid- the id of the session.timeoutMillis- the timeout interval in milliseconds. Session is only returned if it is not older than the current time minus this timeout.userAgent- the user agent whuch must match.- Returns:
- the session or
Optional.empty(). - Throws:
SessionDataException
-
isSessionActive
- Specified by:
isSessionActivein interfaceSessionManager- Returns:
- true if there is an active session with the given uuid
-
createSession
public Session createSession(String username, String ipAddress, @Nullable @Nullable String userAgent) throws SessionDataException Description copied from interface:SessionManagerCreates a new session for the existing principal.- Specified by:
createSessionin interfaceSessionManager- Parameters:
username- the current user's usernameipAddress- the ip address of the clientuserAgent- the user agent of the client- Returns:
- the created session
- Throws:
SessionDataException
-
createSession
public Session createSession(String username, ApiKey apiKey, String ipAddress, @Nullable @Nullable String userAgent) throws SessionDataException Description copied from interface:SessionManager- Specified by:
createSessionin interfaceSessionManager- Throws:
SessionDataException
-
deleteSession
Description copied from interface:SessionManagerDeletes the session with the specified uuid.- Specified by:
deleteSessionin interfaceSessionManager- Parameters:
uuid- the id of the session.
-
deleteAllSessions
Description copied from interface:SessionManagerDeletes all available sessions of specified principal.- Specified by:
deleteAllSessionsin interfaceSessionManager- Parameters:
username- of principalincludingCurrent- when set to true, also set currently used session which will lead to an invalid current session.
-