Package ch.tocco.nice2.userbase.api
Interface SessionManager
- All Known Implementing Classes:
SessionManagerImpl
public interface SessionManager
Service that encapsulates operations on the "Session" entity.
All methods throw unchecked exceptions that will contain the original
exception as its cause.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
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.void
deleteAllSessions
(String username, boolean includingCurrent) Deletes all available sessions of specified principal.void
deleteExpiredSessions
(long timeoutMillis) Removes at mostamount
sessions that are older than the specified time out.void
deleteSession
(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.boolean
isSessionActive
(UUID uuid, long timeoutMillis)
-
Field Details
-
SESSION_TIME_OUT_MINUTES
static final int SESSION_TIME_OUT_MINUTES- See Also:
-
SESSION_TIME_OUT_MILLISECONDS
static final int SESSION_TIME_OUT_MILLISECONDS- See Also:
-
-
Method Details
-
deleteExpiredSessions
Removes at mostamount
sessions that are older than the specified time out.- Parameters:
timeoutMillis
- timeout to find sessions older than this- Throws:
SessionDataException
-
getSession
Optional<Session> getSession(UUID uuid, long timeoutMillis, @Nullable @Nullable String userAgent, @Nullable @Nullable ApiKey apiKey) throws SessionDataException 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. Session time is updated automatically.- 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
-
createSession
Session createSession(String username, String ipAddress, @Nullable @Nullable String userAgent) throws SessionDataException Creates a new session for the existing principal.- 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
Session createSession(String username, ApiKey apiKey, String ipAddress, @Nullable @Nullable String userAgent) throws SessionDataException - Throws:
SessionDataException
-
deleteSession
Deletes the session with the specified uuid.- Parameters:
uuid
- the id of the session.
-
deleteAllSessions
Deletes all available sessions of specified principal.- Parameters:
username
- of principalincludingCurrent
- when set to true, also set currently used session which will lead to an invalid current session.
-
isSessionActive
- Returns:
- true if there is an active session with the given uuid
-