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 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

      void deleteExpiredSessions(long timeoutMillis) throws SessionDataException
      Removes at most amount 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 username
      ipAddress - the ip address of the client
      userAgent - 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
      Create a new Session for a given ApiKey.
      Throws:
      SessionDataException
    • deleteSession

      void deleteSession(UUID uuid)
      Deletes the session with the specified uuid.
      Parameters:
      uuid - the id of the session.
    • deleteAllSessions

      void deleteAllSessions(String username, boolean includingCurrent)
      Deletes all available sessions of specified principal.
      Parameters:
      username - of principal
      includingCurrent - when set to true, also set currently used session which will lead to an invalid current session.
    • isSessionActive

      boolean isSessionActive(UUID uuid, long timeoutMillis)
      Returns:
      true if there is an active session with the given uuid