org.keycloak.models

## Interface UserSessionProvider

- All Superinterfaces:
    Provider
  All Known Implementing Classes:
    InfinispanUserSessionProvider

      public interface UserSessionProvider
      extends Provider

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `UserLoginFailureModel` | `addUserLoginFailure(RealmModel realm, String userId)`
    `void` | `close()`
    `AuthenticatedClientSessionModel` | `createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession)`
    `AuthenticatedClientSessionModel` | `createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession)` Will automatically attach newly created offline client session to the offlineUserSession
    `UserSessionModel` | `createOfflineUserSession(UserSessionModel userSession)` Newly created userSession won't contain attached AuthenticatedClientSessions
    `UserSessionModel` | `createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId)`
    `UserSessionModel` | `createUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState)`
    `Map<String,Long>` | `getActiveClientSessionStats(RealmModel realm, boolean offline)` Returns a summary of client sessions key is client.getId()
    `long` | `getActiveUserSessions(RealmModel realm, ClientModel client)`
    `AuthenticatedClientSessionModel` | `getClientSession(UserSessionModel userSession, ClientModel client, UUID clientSessionId, boolean offline)`
    `long` | `getOfflineSessionsCount(RealmModel realm, ClientModel client)`
    `UserSessionModel` | `getOfflineUserSession(RealmModel realm, String userSessionId)`
    `UserSessionModel` | `getOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)`
    `default List<UserSessionModel>` | `getOfflineUserSessionByBrokerUserId(RealmModel realm, String brokerUserId)` Deprecated. Use `getOfflineUserSessionByBrokerUserIdStream` instead.
    `Stream<UserSessionModel>` | `getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)` Obtains the offline user sessions associated with the user that matches the specified `brokerUserId`.
    `default List<UserSessionModel>` | `getOfflineUserSessions(RealmModel realm, ClientModel client, int first, int max)` Deprecated. use `getOfflineUserSessionsStream` instead.
    `default List<UserSessionModel>` | `getOfflineUserSessions(RealmModel realm, UserModel user)` Deprecated. Use `getOfflineUserSessionsStream` instead.
    `Stream<UserSessionModel>` | `getOfflineUserSessionsStream(RealmModel realm, ClientModel client, int firstResult, int maxResults)` Obtains the offline user sessions associated with the specified client, starting from the `firstResult` and containing at most `maxResults`.
    `Stream<UserSessionModel>` | `getOfflineUserSessionsStream(RealmModel realm, UserModel user)` Obtains the offline user sessions associated with the specified user.
    `UserLoginFailureModel` | `getUserLoginFailure(RealmModel realm, String userId)`
    `UserSessionModel` | `getUserSession(RealmModel realm, String id)`
    `UserSessionModel` | `getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)`
    `default List<UserSessionModel>` | `getUserSessionByBrokerUserId(RealmModel realm, String brokerUserId)` Deprecated. Use `getUserSessionByBrokerUserIdStream` instead.
    `Stream<UserSessionModel>` | `getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)` Obtains the user sessions associated with the user that matches the specified `brokerUserId`.
    `default List<UserSessionModel>` | `getUserSessions(RealmModel realm, ClientModel client)` Deprecated. Use `getUserSessionsStream` instead.
    `default List<UserSessionModel>` | `getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults)` Deprecated. Use `getUserSessionsStream` instead.
    `default List<UserSessionModel>` | `getUserSessions(RealmModel realm, UserModel user)` Deprecated. Use `getUserSessionsStream` instead.
    `Stream<UserSessionModel>` | `getUserSessionsStream(RealmModel realm, ClientModel client)` Obtains the user sessions associated with the specified client.
    `Stream<UserSessionModel>` | `getUserSessionsStream(RealmModel realm, ClientModel client, int firstResult, int maxResults)` Obtains the user sessions associated with the specified client, starting from the `firstResult` and containing at most `maxResults`.
    `Stream<UserSessionModel>` | `getUserSessionsStream(RealmModel realm, UserModel user)` Obtains the user sessions associated with the specified user.
    `UserSessionModel` | `getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate)` Return userSession of specified ID as long as the predicate passes.
    `void` | `importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline)` Triggered by persister during pre-load.
    `void` | `onClientRemoved(RealmModel realm, ClientModel client)`
    `void` | `onRealmRemoved(RealmModel realm)`
    `void` | `removeAllUserLoginFailures(RealmModel realm)`
    `void` | `removeExpired(RealmModel realm)` Implementation doesn't need to propagate removal of expired userSessions to userSessionPersister.
    `void` | `removeOfflineUserSession(RealmModel realm, UserSessionModel userSession)` Removes the attached clientSessions as well
    `void` | `removeUserLoginFailure(RealmModel realm, String userId)`
    `void` | `removeUserSession(RealmModel realm, UserSessionModel session)` This will remove attached ClientLoginSessionModels too
    `void` | `removeUserSessions(RealmModel realm)`
    `void` | `removeUserSessions(RealmModel realm, UserModel user)`

- - ### Method Detail

    - #### createClientSession

          AuthenticatedClientSessionModel createClientSession(RealmModel realm,
                                                              ClientModel client,
                                                              UserSessionModel userSession)

    - #### getClientSession

          AuthenticatedClientSessionModel getClientSession(UserSessionModel userSession,
                                                           ClientModel client,
                                                           UUID clientSessionId,
                                                           boolean offline)

    - #### createUserSession

          UserSessionModel createUserSession(RealmModel realm,
                                             UserModel user,
                                             String loginUsername,
                                             String ipAddress,
                                             String authMethod,
                                             boolean rememberMe,
                                             String brokerSessionId,
                                             String brokerUserId)

    - #### createUserSession

          UserSessionModel createUserSession(String id,
                                             RealmModel realm,
                                             UserModel user,
                                             String loginUsername,
                                             String ipAddress,
                                             String authMethod,
                                             boolean rememberMe,
                                             String brokerSessionId,
                                             String brokerUserId,
                                             UserSessionModel.SessionPersistenceState persistenceState)

    - #### getUserSession

          UserSessionModel getUserSession(RealmModel realm,
                                          String id)

    - #### getUserSessions

          @Deprecated
          default List<UserSessionModel> getUserSessions(RealmModel realm,
                                                                     UserModel user)

      Deprecated. Use `getUserSessionsStream` instead.

    - #### getUserSessionsStream

          Stream<UserSessionModel> getUserSessionsStream(RealmModel realm,
                                                         UserModel user)

      Obtains the user sessions associated with the specified user.
      Parameters:
        `realm` - a reference to the realm.
        `user` - the user whose sessions are being searched.
      Returns:
        a non-null `Stream` of user sessions.

    - #### getUserSessions

          @Deprecated
          default List<UserSessionModel> getUserSessions(RealmModel realm,
                                                                     ClientModel client)

      Deprecated. Use `getUserSessionsStream` instead.

    - #### getUserSessionsStream

          Stream<UserSessionModel> getUserSessionsStream(RealmModel realm,
                                                         ClientModel client)

      Obtains the user sessions associated with the specified client.
      Parameters:
        `realm` - a reference to the realm.
        `client` - the client whose user sessions are being searched.
      Returns:
        a non-null `Stream` of user sessions.

    - #### getUserSessions

          @Deprecated
          default List<UserSessionModel> getUserSessions(RealmModel realm,
                                                                     ClientModel client,
                                                                     int firstResult,
                                                                     int maxResults)

      Deprecated. Use `getUserSessionsStream` instead.

    - #### getUserSessionsStream

          Stream<UserSessionModel> getUserSessionsStream(RealmModel realm,
                                                         ClientModel client,
                                                         int firstResult,
                                                         int maxResults)

      Obtains the user sessions associated with the specified client, starting from the `firstResult` and containing at most `maxResults`.
      Parameters:
        `realm` - a reference tot he realm.
        `client` - the client whose user sessions are being searched.
        `firstResult` - first result to return. Ignored if negative.
        `maxResults` - maximum number of results to return. Ignored if negative.
      Returns:
        a non-null `Stream` of user sessions.

    - #### getUserSessionByBrokerUserId

          @Deprecated
          default List<UserSessionModel> getUserSessionByBrokerUserId(RealmModel realm,
                                                                                  String brokerUserId)

      Deprecated. Use `getUserSessionByBrokerUserIdStream` instead.

    - #### getUserSessionByBrokerUserIdStream

          Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm,
                                                                      String brokerUserId)

      Obtains the user sessions associated with the user that matches the specified `brokerUserId`.
      Parameters:
        `realm` - a reference to the realm.
        `brokerUserId` - the id of the broker user whose sessions are being searched.
      Returns:
        a non-null `Stream` of user sessions.

    - #### getUserSessionByBrokerSessionId

          UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm,
                                                           String brokerSessionId)

    - #### getUserSessionWithPredicate

          UserSessionModel getUserSessionWithPredicate(RealmModel realm,
                                                       String id,
                                                       boolean offline,
                                                       Predicate<UserSessionModel> predicate)

      Return userSession of specified ID as long as the predicate passes. Otherwise returns `null`. If predicate doesn't pass, implementation can do some best-effort actions to try have predicate passing (eg. download userSession from other DC)

    - #### getActiveUserSessions

          long getActiveUserSessions(RealmModel realm,
                                     ClientModel client)

    - #### getActiveClientSessionStats

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

      Returns a summary of client sessions key is client.getId()
      Parameters:
        `realm` -
        `offline` -
      Returns:

    - #### removeUserSession

          void removeUserSession(RealmModel realm,
                                 UserSessionModel session)

      This will remove attached ClientLoginSessionModels too

    - #### removeUserSessions

          void removeUserSessions(RealmModel realm,
                                  UserModel user)

    - #### removeExpired

          void removeExpired(RealmModel realm)

      Implementation doesn't need to propagate removal of expired userSessions to userSessionPersister. Cleanup on persister will be called separately

    - #### removeUserSessions

          void removeUserSessions(RealmModel realm)

    - #### getUserLoginFailure

          UserLoginFailureModel getUserLoginFailure(RealmModel realm,
                                                    String userId)

    - #### addUserLoginFailure

          UserLoginFailureModel addUserLoginFailure(RealmModel realm,
                                                    String userId)

    - #### removeUserLoginFailure

          void removeUserLoginFailure(RealmModel realm,
                                      String userId)

    - #### removeAllUserLoginFailures

          void removeAllUserLoginFailures(RealmModel realm)

    - #### onRealmRemoved

          void onRealmRemoved(RealmModel realm)

    - #### onClientRemoved

          void onClientRemoved(RealmModel realm,
                               ClientModel client)

    - #### createOfflineUserSession

          UserSessionModel createOfflineUserSession(UserSessionModel userSession)

      Newly created userSession won't contain attached AuthenticatedClientSessions

    - #### getOfflineUserSession

          UserSessionModel getOfflineUserSession(RealmModel realm,
                                                 String userSessionId)

    - #### removeOfflineUserSession

          void removeOfflineUserSession(RealmModel realm,
                                        UserSessionModel userSession)

      Removes the attached clientSessions as well

    - #### createOfflineClientSession

          AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession,
                                                                     UserSessionModel offlineUserSession)

      Will automatically attach newly created offline client session to the offlineUserSession

    - #### getOfflineUserSessions

          @Deprecated
          default List<UserSessionModel> getOfflineUserSessions(RealmModel realm,
                                                                            UserModel user)

      Deprecated. Use `getOfflineUserSessionsStream` instead.

    - #### getOfflineUserSessionsStream

          Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm,
                                                                UserModel user)

      Obtains the offline user sessions associated with the specified user.
      Parameters:
        `realm` - a reference to the realm.
        `user` - the user whose offline sessions are being searched.
      Returns:
        a non-null `Stream` of offline user sessions.

    - #### getOfflineUserSessionByBrokerSessionId

          UserSessionModel getOfflineUserSessionByBrokerSessionId(RealmModel realm,
                                                                  String brokerSessionId)

    - #### getOfflineUserSessionByBrokerUserId

          @Deprecated
          default List<UserSessionModel> getOfflineUserSessionByBrokerUserId(RealmModel realm,
                                                                                         String brokerUserId)

      Deprecated. Use `getOfflineUserSessionByBrokerUserIdStream` instead.

    - #### getOfflineUserSessionByBrokerUserIdStream

          Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm,
                                                                             String brokerUserId)

      Obtains the offline user sessions associated with the user that matches the specified `brokerUserId`.
      Parameters:
        `realm` - a reference to the realm.
        `brokerUserId` - the id of the broker user whose sessions are being searched.
      Returns:
        a non-null `Stream` of offline user sessions.

    - #### getOfflineSessionsCount

          long getOfflineSessionsCount(RealmModel realm,
                                       ClientModel client)

    - #### getOfflineUserSessions

          @Deprecated
          default List<UserSessionModel> getOfflineUserSessions(RealmModel realm,
                                                                            ClientModel client,
                                                                            int first,
                                                                            int max)

      Deprecated. use `getOfflineUserSessionsStream` instead.

    - #### getOfflineUserSessionsStream

          Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm,
                                                                ClientModel client,
                                                                int firstResult,
                                                                int maxResults)

      Obtains the offline user sessions associated with the specified client, starting from the `firstResult` and containing at most `maxResults`.
      Parameters:
        `realm` - a reference tot he realm.
        `client` - the client whose user sessions are being searched.
        `firstResult` - first result to return. Ignored if negative.
        `maxResults` - maximum number of results to return. Ignored if negative.
      Returns:
        a non-null `Stream` of offline user sessions.

    - #### importUserSessions

          void importUserSessions(Collection<UserSessionModel> persistentUserSessions,
                                  boolean offline)

      Triggered by persister during pre-load. It imports authenticatedClientSessions too

    - #### close

          void close()

      Specified by:
        `close` in interface `Provider`

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