org.keycloak.models.session

## Interface UserSessionPersisterProvider

- All Superinterfaces:
    Provider
  All Known Implementing Classes:
    DisabledUserSessionPersisterProvider, JpaUserSessionPersisterProvider

      public interface UserSessionPersisterProvider
      extends Provider

  Author:
    Marek Posolda

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createClientSession(AuthenticatedClientSessionModel clientSession, boolean offline)`
    `void` | `createUserSession(UserSessionModel userSession, boolean offline)`
    `int` | `getUserSessionsCount(boolean offline)` Retrieves the count of user sessions for all realms.
    `int` | `getUserSessionsCount(RealmModel realm, ClientModel clientModel, boolean offline)` Retrieves the count of user client-sessions for the given client
    `Map<String,Long>` | `getUserSessionsCountsByClients(RealmModel realm, boolean offline)` Returns a `Map` containing the number of user-sessions aggregated by client id for the given realm.
    `UserSessionModel` | `loadUserSession(RealmModel realm, String userSessionId, boolean offline)` Loads the user session with the given userSessionId.
    `default List<UserSessionModel>` | `loadUserSessions(int firstResult, int maxResults, boolean offline, int lastCreatedOn, String lastUserSessionId)` Deprecated. Use `loadUserSessionsStream` instead.
    `Stream<UserSessionModel>` | `loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId)` Called during startup.
    `Stream<UserSessionModel>` | `loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults)` Loads the user sessions for the given `ClientModel` in the given `RealmModel` if present.
    `Stream<UserSessionModel>` | `loadUserSessionsStream(RealmModel realm, UserModel user, boolean offline, Integer firstResult, Integer maxResults)` Loads the user sessions for the given `UserModel` in the given `RealmModel` if present.
    `void` | `onClientRemoved(RealmModel realm, ClientModel client)`
    `void` | `onRealmRemoved(RealmModel realm)`
    `void` | `onUserRemoved(RealmModel realm, UserModel user)`
    `void` | `removeClientSession(String userSessionId, String clientUUID, boolean offline)`
    `void` | `removeExpired(RealmModel realm)`
    `void` | `removeUserSession(String userSessionId, boolean offline)`
    `void` | `updateLastSessionRefreshes(RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline)`

    - ### Methods inherited from interface org.keycloak.provider.Provider

      `close`

- - ### Method Detail

    - #### createUserSession

          void createUserSession(UserSessionModel userSession,
                                 boolean offline)

    - #### createClientSession

          void createClientSession(AuthenticatedClientSessionModel clientSession,
                                   boolean offline)

    - #### removeUserSession

          void removeUserSession(String userSessionId,
                                 boolean offline)

    - #### removeClientSession

          void removeClientSession(String userSessionId,
                                   String clientUUID,
                                   boolean offline)

    - #### onRealmRemoved

          void onRealmRemoved(RealmModel realm)

    - #### onClientRemoved

          void onClientRemoved(RealmModel realm,
                               ClientModel client)

    - #### onUserRemoved

          void onUserRemoved(RealmModel realm,
                             UserModel user)

    - #### updateLastSessionRefreshes

          void updateLastSessionRefreshes(RealmModel realm,
                                          int lastSessionRefresh,
                                          Collection<String> userSessionIds,
                                          boolean offline)

    - #### removeExpired

          void removeExpired(RealmModel realm)

    - #### loadUserSession

          UserSessionModel loadUserSession(RealmModel realm,
                                           String userSessionId,
                                           boolean offline)

      Loads the user session with the given userSessionId.
      Parameters:
        `userSessionId` -
        `offline` -
      Returns:

    - #### loadUserSessionsStream

          Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm,
                                                          UserModel user,
                                                          boolean offline,
                                                          Integer firstResult,
                                                          Integer maxResults)

      Loads the user sessions for the given `UserModel` in the given `RealmModel` if present.
      Parameters:
        `realm` -
        `user` -
        `offline` -
        `firstResult` -
        `maxResults` -
      Returns:

    - #### loadUserSessionsStream

          Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm,
                                                          ClientModel client,
                                                          boolean offline,
                                                          Integer firstResult,
                                                          Integer maxResults)

      Loads the user sessions for the given `ClientModel` in the given `RealmModel` if present.
      Parameters:
        `realm` -
        `client` -
        `offline` -
        `firstResult` -
        `maxResults` -
      Returns:

    - #### loadUserSessions

          @Deprecated
          default List<UserSessionModel> loadUserSessions(int firstResult,
                                                                      int maxResults,
                                                                      boolean offline,
                                                                      int lastCreatedOn,
                                                                      String lastUserSessionId)

      Deprecated. Use `loadUserSessionsStream` instead.
      Called during startup. For each userSession, it loads also clientSessions

    - #### loadUserSessionsStream

          Stream<UserSessionModel> loadUserSessionsStream(Integer firstResult,
                                                          Integer maxResults,
                                                          boolean offline,
                                                          String lastUserSessionId)

      Called during startup. For each userSession, it loads also clientSessions.
      Parameters:
        `firstResult` - `Integer` Index of the first desired user session. Ignored if negative or `null`.
        `maxResults` - `Integer` Maximum number of returned user sessions. Ignored if negative or `null`.
        `offline` - `boolean` Flag to include offline sessions.
        `lastUserSessionId` - `String` Id of the user session. It will return only user sessions with id's lexicographically greater than this. it will compare the id in dictionary order and takes only those created later.
      Returns:
        Stream of `UserSessionModel`. Never returns `null`.

    - #### getUserSessionsCount

          int getUserSessionsCount(boolean offline)

      Retrieves the count of user sessions for all realms.
      Parameters:
        `offline` -
      Returns:

    - #### getUserSessionsCount

          int getUserSessionsCount(RealmModel realm,
                                   ClientModel clientModel,
                                   boolean offline)

      Retrieves the count of user client-sessions for the given client
      Parameters:
        `realm` -
        `clientModel` -
        `offline` -
      Returns:

    - #### getUserSessionsCountsByClients

          Map<String,Long> getUserSessionsCountsByClients(RealmModel realm,
                                                          boolean offline)

      Returns a `Map` containing the number of user-sessions aggregated by client id for the given realm.
      Parameters:
        `realm` -
        `offline` -
      Returns:
        the count `Map` with clientId as key and session count as value

Copyright © 2021 JBoss by Red Hat. All rights reserved.