org.keycloak.models.sessions.jpa

## Class JpaUserSessionProvider

- java.lang.Object
- - org.keycloak.models.sessions.jpa.JpaUserSessionProvider

- All Implemented Interfaces:
    UserSessionProvider, Provider

      public class JpaUserSessionProvider
      extends Object
      implements UserSessionProvider

  Author:
    Stian Thorgersen

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.persistence.EntityManager` | `em`
    `protected KeycloakSession` | `session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JpaUserSessionProvider(KeycloakSession session, javax.persistence.EntityManager em)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `UsernameLoginFailureModel` | `addUserLoginFailure(RealmModel realm, String username)`
    `void` | `close()`
    `ClientSessionModel` | `createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession, String redirectUri, String state, Set<String> roles)`
    `UserSessionModel` | `createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe)`
    `int` | `getActiveUserSessions(RealmModel realm, ClientModel client)`
    `List<UsernameLoginFailureModel>` | `getAllUserLoginFailures(RealmModel realm)`
    `ClientSessionModel` | `getClientSession(RealmModel realm, String id)`
    `UsernameLoginFailureModel` | `getUserLoginFailure(RealmModel realm, String username)`
    `UserSessionModel` | `getUserSession(RealmModel realm, String id)`
    `List<UserSessionModel>` | `getUserSessions(RealmModel realm, ClientModel client)`
    `List<UserSessionModel>` | `getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults)`
    `List<UserSessionModel>` | `getUserSessions(RealmModel realm, UserModel user)`
    `void` | `onClientRemoved(RealmModel realm, ClientModel client)`
    `void` | `onRealmRemoved(RealmModel realm)`
    `void` | `onUserRemoved(RealmModel realm, UserModel user)`
    `void` | `removeExpiredUserSessions(RealmModel realm)`
    `void` | `removeUserSession(RealmModel realm, UserSessionModel session)`
    `void` | `removeUserSessions(RealmModel realm)`
    `void` | `removeUserSessions(RealmModel realm, UserModel user)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### session

          protected final KeycloakSession session

    - #### em

          protected final javax.persistence.EntityManager em

  - ### Constructor Detail

    - #### JpaUserSessionProvider

          public JpaUserSessionProvider(KeycloakSession session,
                                javax.persistence.EntityManager em)

  - ### Method Detail

    - #### createClientSession

          public ClientSessionModel createClientSession(RealmModel realm,
                                               ClientModel client,
                                               UserSessionModel userSession,
                                               String redirectUri,
                                               String state,
                                               Set<String> roles)

      Specified by:
        `createClientSession` in interface `UserSessionProvider`

    - #### getClientSession

          public ClientSessionModel getClientSession(RealmModel realm,
                                            String id)

      Specified by:
        `getClientSession` in interface `UserSessionProvider`

    - #### getUserLoginFailure

          public UsernameLoginFailureModel getUserLoginFailure(RealmModel realm,
                                                      String username)

      Specified by:
        `getUserLoginFailure` in interface `UserSessionProvider`

    - #### addUserLoginFailure

          public UsernameLoginFailureModel addUserLoginFailure(RealmModel realm,
                                                      String username)

      Specified by:
        `addUserLoginFailure` in interface `UserSessionProvider`

    - #### getAllUserLoginFailures

          public List<UsernameLoginFailureModel> getAllUserLoginFailures(RealmModel realm)

      Specified by:
        `getAllUserLoginFailures` in interface `UserSessionProvider`

    - #### createUserSession

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

      Specified by:
        `createUserSession` in interface `UserSessionProvider`

    - #### getUserSession

          public UserSessionModel getUserSession(RealmModel realm,
                                        String id)

      Specified by:
        `getUserSession` in interface `UserSessionProvider`

    - #### getUserSessions

          public List<UserSessionModel> getUserSessions(RealmModel realm,
                                               UserModel user)

      Specified by:
        `getUserSessions` in interface `UserSessionProvider`

    - #### getUserSessions

          public List<UserSessionModel> getUserSessions(RealmModel realm,
                                               ClientModel client)

      Specified by:
        `getUserSessions` in interface `UserSessionProvider`

    - #### getUserSessions

          public List<UserSessionModel> getUserSessions(RealmModel realm,
                                               ClientModel client,
                                               int firstResult,
                                               int maxResults)

      Specified by:
        `getUserSessions` in interface `UserSessionProvider`

    - #### getActiveUserSessions

          public int getActiveUserSessions(RealmModel realm,
                                  ClientModel client)

      Specified by:
        `getActiveUserSessions` in interface `UserSessionProvider`

    - #### removeUserSession

          public void removeUserSession(RealmModel realm,
                               UserSessionModel session)

      Specified by:
        `removeUserSession` in interface `UserSessionProvider`

    - #### removeUserSessions

          public void removeUserSessions(RealmModel realm,
                                UserModel user)

      Specified by:
        `removeUserSessions` in interface `UserSessionProvider`

    - #### removeExpiredUserSessions

          public void removeExpiredUserSessions(RealmModel realm)

      Specified by:
        `removeExpiredUserSessions` in interface `UserSessionProvider`

    - #### removeUserSessions

          public void removeUserSessions(RealmModel realm)

      Specified by:
        `removeUserSessions` in interface `UserSessionProvider`

    - #### onRealmRemoved

          public void onRealmRemoved(RealmModel realm)

      Specified by:
        `onRealmRemoved` in interface `UserSessionProvider`

    - #### onClientRemoved

          public void onClientRemoved(RealmModel realm,
                             ClientModel client)

      Specified by:
        `onClientRemoved` in interface `UserSessionProvider`

    - #### onUserRemoved

          public void onUserRemoved(RealmModel realm,
                           UserModel user)

      Specified by:
        `onUserRemoved` in interface `UserSessionProvider`

    - #### close

          public void close()

      Specified by:
        `close` in interface `UserSessionProvider`
      Specified by:
        `close` in interface `Provider`

Copyright © 2015. All Rights Reserved.