org.keycloak.models.cache.infinispan

## Class UserCacheSession

- java.lang.Object
- - org.keycloak.models.cache.infinispan.UserCacheSession

- All Implemented Interfaces:
    CacheUserProvider, UserProvider, Provider, UserCredentialValidatorProvider, UserLookupProvider, UserQueryProvider, UserRegistrationProvider

      public class UserCacheSession
      extends Object
      implements CacheUserProvider

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected UserCacheManager` | `cache`
    `protected UserProvider` | `delegate`
    `protected Set<String>` | `invalidations`
    `protected static org.jboss.logging.Logger` | `logger`
    `protected Map<String,UserModel>` | `managedUsers`
    `protected Set<String>` | `realmInvalidations`
    `protected KeycloakSession` | `session`
    `protected boolean` | `setRollbackOnly`
    `protected long` | `startupRevision`
    `protected boolean` | `transactionActive`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UserCacheSession(UserCacheManager cache, KeycloakSession session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConsent(RealmModel realm, UserModel user, UserConsentModel consent)`
    `void` | `addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink)`
    `UserModel` | `addUser(RealmModel realm, String username)`
    `UserModel` | `addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions)` only used for local storage
    `void` | `clear()`
    `void` | `close()`
    `UserConsentModel` | `getConsentByClient(RealmModel realm, UserModel user, String clientId)`
    `String` | `getConsentCacheKey(String userId)`
    `List<UserConsentModel>` | `getConsents(RealmModel realm, UserModel user)`
    `UserProvider` | `getDelegate()`
    `Set<FederatedIdentityModel>` | `getFederatedIdentities(UserModel user, RealmModel realm)`
    `FederatedIdentityModel` | `getFederatedIdentity(UserModel user, String socialProvider, RealmModel realm)`
    `String` | `getFederatedIdentityLinksCacheKey(String userId)`
    `List<UserModel>` | `getGroupMembers(RealmModel realm, GroupModel group)`
    `List<UserModel>` | `getGroupMembers(RealmModel realm, GroupModel group, int firstResult, int maxResults)`
    `UserModel` | `getServiceAccount(ClientModel client)`
    `UserModel` | `getUserByEmail(String email, RealmModel realm)`
    `String` | `getUserByEmailCacheKey(String realmId, String email)`
    `UserModel` | `getUserByFederatedIdentity(FederatedIdentityModel socialLink, RealmModel realm)`
    `String` | `getUserByFederatedIdentityCacheKey(String realmId, FederatedIdentityModel socialLink)`
    `UserModel` | `getUserById(String id, RealmModel realm)`
    `UserModel` | `getUserByUsername(String username, RealmModel realm)`
    `String` | `getUserByUsernameCacheKey(String realmId, String username)`
    `List<UserModel>` | `getUsers(RealmModel realm)`
    `List<UserModel>` | `getUsers(RealmModel realm, boolean includeServiceAccounts)`
    `List<UserModel>` | `getUsers(RealmModel realm, int firstResult, int maxResults)`
    `List<UserModel>` | `getUsers(RealmModel realm, int firstResult, int maxResults, boolean includeServiceAccounts)`
    `int` | `getUsersCount(RealmModel realm)`
    `void` | `grantToAllUsers(RealmModel realm, RoleModel role)`
    `protected void` | `invalidateUser(RealmModel realm, UserModel user)`
    `void` | `preRemove(ProtocolMapperModel protocolMapper)`
    `void` | `preRemove(RealmModel realm)`
    `void` | `preRemove(RealmModel realm, ClientModel client)`
    `void` | `preRemove(RealmModel realm, ComponentModel component)`
    `void` | `preRemove(RealmModel realm, GroupModel group)`
    `void` | `preRemove(RealmModel realm, RoleModel role)`
    `void` | `preRemove(RealmModel realm, UserFederationProviderModel link)`
    `void` | `registerUserInvalidation(RealmModel realm, CachedUser user)`
    `boolean` | `removeFederatedIdentity(RealmModel realm, UserModel user, String socialProvider)`
    `boolean` | `removeUser(RealmModel realm, UserModel user)`
    `boolean` | `revokeConsentForClient(RealmModel realm, UserModel user, String clientInternalId)`
    `protected void` | `runInvalidations()`
    `List<UserModel>` | `searchForUser(Map<String,String> attributes, RealmModel realm)` Search for user by parameter.
    `List<UserModel>` | `searchForUser(Map<String,String> attributes, RealmModel realm, int firstResult, int maxResults)` Search for user by parameter.
    `List<UserModel>` | `searchForUser(String search, RealmModel realm)` Search for users with username, email or first + last name that is like search string.
    `List<UserModel>` | `searchForUser(String search, RealmModel realm, int firstResult, int maxResults)` Search for users with username, email or first + last name that is like search string.
    `List<UserModel>` | `searchForUserByUserAttribute(String attrName, String attrValue, RealmModel realm)`
    `void` | `updateConsent(RealmModel realm, UserModel user, UserConsentModel consent)`
    `void` | `updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel)`
    `CredentialValidationOutput` | `validCredentials(KeycloakSession session, RealmModel realm, UserCredentialModel... input)`
    `boolean` | `validCredentials(KeycloakSession session, RealmModel realm, UserModel user, List<UserCredentialModel> input)`
    `boolean` | `validCredentials(KeycloakSession session, RealmModel realm, UserModel user, UserCredentialModel... input)`

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

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

- - ### Field Detail

    - #### logger

          protected static final org.jboss.logging.Logger logger

    - #### cache

          protected UserCacheManager cache

    - #### session

          protected KeycloakSession session

    - #### delegate

          protected UserProvider delegate

    - #### transactionActive

          protected boolean transactionActive

    - #### setRollbackOnly

          protected boolean setRollbackOnly

    - #### startupRevision

          protected final long startupRevision

    - #### invalidations

          protected Set<String> invalidations

    - #### realmInvalidations

          protected Set<String> realmInvalidations

    - #### managedUsers

          protected Map<String,UserModel> managedUsers

  - ### Constructor Detail

    - #### UserCacheSession

          public UserCacheSession(UserCacheManager cache,
                                  KeycloakSession session)

  - ### Method Detail

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `CacheUserProvider`

    - #### getDelegate

          public UserProvider getDelegate()

      Specified by:
        `getDelegate` in interface `CacheUserProvider`

    - #### registerUserInvalidation

          public void registerUserInvalidation(RealmModel realm,
                                               CachedUser user)

    - #### runInvalidations

          protected void runInvalidations()

    - #### getUserById

          public UserModel getUserById(String id,
                                       RealmModel realm)

      Specified by:
        `getUserById` in interface `UserLookupProvider`

    - #### getUserByUsernameCacheKey

          public String getUserByUsernameCacheKey(String realmId,
                                                  String username)

    - #### getUserByEmailCacheKey

          public String getUserByEmailCacheKey(String realmId,
                                               String email)

    - #### getUserByFederatedIdentityCacheKey

          public String getUserByFederatedIdentityCacheKey(String realmId,
                                                           FederatedIdentityModel socialLink)

    - #### getFederatedIdentityLinksCacheKey

          public String getFederatedIdentityLinksCacheKey(String userId)

    - #### getUserByUsername

          public UserModel getUserByUsername(String username,
                                             RealmModel realm)

      Specified by:
        `getUserByUsername` in interface `UserLookupProvider`

    - #### getUserByEmail

          public UserModel getUserByEmail(String email,
                                          RealmModel realm)

      Specified by:
        `getUserByEmail` in interface `UserLookupProvider`

    - #### close

          public void close()

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

    - #### getUserByFederatedIdentity

          public UserModel getUserByFederatedIdentity(FederatedIdentityModel socialLink,
                                                      RealmModel realm)

      Specified by:
        `getUserByFederatedIdentity` in interface `UserProvider`

    - #### getGroupMembers

          public List<UserModel> getGroupMembers(RealmModel realm,
                                                 GroupModel group,
                                                 int firstResult,
                                                 int maxResults)

      Specified by:
        `getGroupMembers` in interface `UserQueryProvider`

    - #### getGroupMembers

          public List<UserModel> getGroupMembers(RealmModel realm,
                                                 GroupModel group)

      Specified by:
        `getGroupMembers` in interface `UserQueryProvider`

    - #### getServiceAccount

          public UserModel getServiceAccount(ClientModel client)

      Specified by:
        `getServiceAccount` in interface `UserProvider`

    - #### getUsers

          public List<UserModel> getUsers(RealmModel realm,
                                          boolean includeServiceAccounts)

      Specified by:
        `getUsers` in interface `UserProvider`

    - #### getUsersCount

          public int getUsersCount(RealmModel realm)

      Specified by:
        `getUsersCount` in interface `UserQueryProvider`

    - #### getUsers

          public List<UserModel> getUsers(RealmModel realm,
                                          int firstResult,
                                          int maxResults,
                                          boolean includeServiceAccounts)

      Specified by:
        `getUsers` in interface `UserProvider`

    - #### getUsers

          public List<UserModel> getUsers(RealmModel realm)

      Specified by:
        `getUsers` in interface `UserQueryProvider`

    - #### getUsers

          public List<UserModel> getUsers(RealmModel realm,
                                          int firstResult,
                                          int maxResults)

      Specified by:
        `getUsers` in interface `UserQueryProvider`

    - #### searchForUser

          public List<UserModel> searchForUser(String search,
                                               RealmModel realm)

      Description copied from interface: `UserQueryProvider`
      Search for users with username, email or first + last name that is like search string. If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE. This method is used by the admin console search box
      Specified by:
        `searchForUser` in interface `UserQueryProvider`
      Returns:

    - #### searchForUser

          public List<UserModel> searchForUser(String search,
                                               RealmModel realm,
                                               int firstResult,
                                               int maxResults)

      Description copied from interface: `UserQueryProvider`
      Search for users with username, email or first + last name that is like search string. If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE. This method is used by the admin console search box
      Specified by:
        `searchForUser` in interface `UserQueryProvider`
      Returns:

    - #### searchForUser

          public List<UserModel> searchForUser(Map<String,String> attributes,
                                               RealmModel realm)

      Description copied from interface: `UserQueryProvider`
      Search for user by parameter. Valid parameters are: "first" - first name "last" - last name "email" - email "username" - username If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE. This method is used by the REST API when querying users.
      Specified by:
        `searchForUser` in interface `UserQueryProvider`
      Returns:

    - #### searchForUser

          public List<UserModel> searchForUser(Map<String,String> attributes,
                                               RealmModel realm,
                                               int firstResult,
                                               int maxResults)

      Description copied from interface: `UserQueryProvider`
      Search for user by parameter. Valid parameters are: "first" - first name "last" - last name "email" - email "username" - username If possible, implementations should treat the parameter values as patterns i.e. in RDMBS terms use LIKE. This method is used by the REST API when querying users.
      Specified by:
        `searchForUser` in interface `UserQueryProvider`
      Returns:

    - #### searchForUserByUserAttribute

          public List<UserModel> searchForUserByUserAttribute(String attrName,
                                                              String attrValue,
                                                              RealmModel realm)

      Specified by:
        `searchForUserByUserAttribute` in interface `UserQueryProvider`

    - #### getFederatedIdentities

          public Set<FederatedIdentityModel> getFederatedIdentities(UserModel user,
                                                                    RealmModel realm)

      Specified by:
        `getFederatedIdentities` in interface `UserProvider`

    - #### getFederatedIdentity

          public FederatedIdentityModel getFederatedIdentity(UserModel user,
                                                             String socialProvider,
                                                             RealmModel realm)

      Specified by:
        `getFederatedIdentity` in interface `UserProvider`

    - #### updateConsent

          public void updateConsent(RealmModel realm,
                                    UserModel user,
                                    UserConsentModel consent)

      Specified by:
        `updateConsent` in interface `UserProvider`

    - #### revokeConsentForClient

          public boolean revokeConsentForClient(RealmModel realm,
                                                UserModel user,
                                                String clientInternalId)

      Specified by:
        `revokeConsentForClient` in interface `UserProvider`

    - #### getConsentCacheKey

          public String getConsentCacheKey(String userId)

    - #### addConsent

          public void addConsent(RealmModel realm,
                                 UserModel user,
                                 UserConsentModel consent)

      Specified by:
        `addConsent` in interface `UserProvider`

    - #### getConsentByClient

          public UserConsentModel getConsentByClient(RealmModel realm,
                                                     UserModel user,
                                                     String clientId)

      Specified by:
        `getConsentByClient` in interface `UserProvider`

    - #### getConsents

          public List<UserConsentModel> getConsents(RealmModel realm,
                                                    UserModel user)

      Specified by:
        `getConsents` in interface `UserProvider`

    - #### addUser

          public UserModel addUser(RealmModel realm,
                                   String id,
                                   String username,
                                   boolean addDefaultRoles,
                                   boolean addDefaultRequiredActions)

      Description copied from interface: `UserProvider`
      only used for local storage
      Specified by:
        `addUser` in interface `UserProvider`
      Returns:

    - #### addUser

          public UserModel addUser(RealmModel realm,
                                   String username)

      Specified by:
        `addUser` in interface `UserRegistrationProvider`

    - #### invalidateUser

          protected void invalidateUser(RealmModel realm,
                                        UserModel user)

    - #### removeUser

          public boolean removeUser(RealmModel realm,
                                    UserModel user)

      Specified by:
        `removeUser` in interface `UserRegistrationProvider`

    - #### addFederatedIdentity

          public void addFederatedIdentity(RealmModel realm,
                                           UserModel user,
                                           FederatedIdentityModel socialLink)

      Specified by:
        `addFederatedIdentity` in interface `UserProvider`

    - #### updateFederatedIdentity

          public void updateFederatedIdentity(RealmModel realm,
                                              UserModel federatedUser,
                                              FederatedIdentityModel federatedIdentityModel)

      Specified by:
        `updateFederatedIdentity` in interface `UserProvider`

    - #### removeFederatedIdentity

          public boolean removeFederatedIdentity(RealmModel realm,
                                                 UserModel user,
                                                 String socialProvider)

      Specified by:
        `removeFederatedIdentity` in interface `UserProvider`

    - #### validCredentials

          public boolean validCredentials(KeycloakSession session,
                                          RealmModel realm,
                                          UserModel user,
                                          List<UserCredentialModel> input)

      Specified by:
        `validCredentials` in interface `UserCredentialValidatorProvider`

    - #### validCredentials

          public boolean validCredentials(KeycloakSession session,
                                          RealmModel realm,
                                          UserModel user,
                                          UserCredentialModel... input)

      Specified by:
        `validCredentials` in interface `UserProvider`

    - #### validCredentials

          public CredentialValidationOutput validCredentials(KeycloakSession session,
                                                             RealmModel realm,
                                                             UserCredentialModel... input)

      Specified by:
        `validCredentials` in interface `UserProvider`

    - #### grantToAllUsers

          public void grantToAllUsers(RealmModel realm,
                                      RoleModel role)

      Specified by:
        `grantToAllUsers` in interface `UserRegistrationProvider`

    - #### preRemove

          public void preRemove(RealmModel realm)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(RealmModel realm,
                                RoleModel role)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(RealmModel realm,
                                GroupModel group)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(RealmModel realm,
                                UserFederationProviderModel link)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(RealmModel realm,
                                ClientModel client)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(ProtocolMapperModel protocolMapper)

      Specified by:
        `preRemove` in interface `UserProvider`

    - #### preRemove

          public void preRemove(RealmModel realm,
                                ComponentModel component)

      Specified by:
        `preRemove` in interface `UserProvider`

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