org.keycloak.models

## Interface UserProvider

- All Superinterfaces:
    Provider, UserBulkUpdateProvider, UserLookupProvider, UserQueryProvider, UserRegistrationProvider
  All Known Subinterfaces:
    UserCache, UserCache.Streams, UserProvider.Streams
  All Known Implementing Classes:
    JpaUserProvider, MapUserProvider, UserCacheSession, UserStorageManager

      public interface UserProvider
      extends Provider, UserLookupProvider, UserQueryProvider, UserRegistrationProvider, UserBulkUpdateProvider

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `UserProvider.Streams`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConsent(RealmModel realm, String userId, UserConsentModel consent)`
    `void` | `addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink)`
    `UserModel` | `addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions)` only used for local storage
    `void` | `close()`
    `UserConsentModel` | `getConsentByClient(RealmModel realm, String userId, String clientInternalId)`
    `List<UserConsentModel>` | `getConsents(RealmModel realm, String userId)` Deprecated. Use `getConsentsStream` instead.
    `default Stream<UserConsentModel>` | `getConsentsStream(RealmModel realm, String userId)` Obtains the consents associated with the user identified by the specified `userId`.
    `Set<FederatedIdentityModel>` | `getFederatedIdentities(UserModel user, RealmModel realm)` Deprecated. Use `getFederatedIdentitiesStream` instead.
    `default Stream<FederatedIdentityModel>` | `getFederatedIdentitiesStream(UserModel user, RealmModel realm)` Obtains the federated identities of the specified user.
    `FederatedIdentityModel` | `getFederatedIdentity(UserModel user, String socialProvider, RealmModel realm)`
    `int` | `getNotBeforeOfUser(RealmModel realm, UserModel user)`
    `UserModel` | `getServiceAccount(ClientModel client)`
    `UserModel` | `getUserByFederatedIdentity(FederatedIdentityModel socialLink, RealmModel realm)`
    `List<UserModel>` | `getUsers(RealmModel realm, boolean includeServiceAccounts)` Deprecated. Use `getUsersStream` instead.
    `List<UserModel>` | `getUsers(RealmModel realm, int firstResult, int maxResults, boolean includeServiceAccounts)` Deprecated. Use `getUsersStream` instead.
    `default Stream<UserModel>` | `getUsersStream(RealmModel realm, boolean includeServiceAccounts)` Obtains the users associated with the specified realm.
    `default Stream<UserModel>` | `getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults, boolean includeServiceAccounts)` Obtains the users associated with the specified realm.
    `void` | `preRemove(ClientScopeModel clientScope)`
    `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, IdentityProviderModel provider)`
    `void` | `preRemove(RealmModel realm, RoleModel role)`
    `boolean` | `removeFederatedIdentity(RealmModel realm, UserModel user, String socialProvider)`
    `void` | `removeImportedUsers(RealmModel realm, String storageProviderId)` Removes any imported users from a specific User Storage Provider.
    `boolean` | `revokeConsentForClient(RealmModel realm, String userId, String clientInternalId)`
    `void` | `setNotBeforeForUser(RealmModel realm, UserModel user, int notBefore)`
    `void` | `unlinkUsers(RealmModel realm, String storageProviderId)` Set federation link to null to imported users of a specific User Storage Provider
    `void` | `updateConsent(RealmModel realm, String userId, UserConsentModel consent)`
    `void` | `updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel)`

    - ### Methods inherited from interface org.keycloak.storage.user.UserLookupProvider

      `getUserByEmail, getUserById, getUserByUsername`

    - ### Methods inherited from interface org.keycloak.storage.user.UserQueryProvider

      `countUsersInGroups, getGroupMembers, getGroupMembers, getGroupMembersStream, getGroupMembersStream, getRoleMembers, getRoleMembers, getRoleMembersStream, getRoleMembersStream, getUsers, getUsers, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersStream, getUsersStream, searchForUser, searchForUser, searchForUser, searchForUser, searchForUserByUserAttribute, searchForUserByUserAttributeStream, searchForUserStream, searchForUserStream, searchForUserStream, searchForUserStream`

    - ### Methods inherited from interface org.keycloak.storage.user.UserRegistrationProvider

      `addUser, removeUser`

    - ### Methods inherited from interface org.keycloak.storage.user.UserBulkUpdateProvider

      `grantToAllUsers`

- - ### Method Detail

    - #### addFederatedIdentity

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

    - #### removeFederatedIdentity

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

    - #### preRemove

          void preRemove(RealmModel realm,
                         IdentityProviderModel provider)

    - #### updateFederatedIdentity

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

    - #### getFederatedIdentities

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

      Deprecated. Use `getFederatedIdentitiesStream` instead.

    - #### getFederatedIdentitiesStream

          default Stream<FederatedIdentityModel> getFederatedIdentitiesStream(UserModel user,
                                                                              RealmModel realm)

      Obtains the federated identities of the specified user.
      Parameters:
        `user` - a reference to the user.
        `realm` - a reference to the realm.
      Returns:
        a non-null `Stream` of federated identities associated with the user.

    - #### getFederatedIdentity

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

    - #### getUserByFederatedIdentity

          UserModel getUserByFederatedIdentity(FederatedIdentityModel socialLink,
                                               RealmModel realm)

    - #### addConsent

          void addConsent(RealmModel realm,
                          String userId,
                          UserConsentModel consent)

    - #### getConsentByClient

          UserConsentModel getConsentByClient(RealmModel realm,
                                              String userId,
                                              String clientInternalId)

    - #### getConsents

          @Deprecated
          List<UserConsentModel> getConsents(RealmModel realm,
                                                         String userId)

      Deprecated. Use `getConsentsStream` instead.

    - #### getConsentsStream

          default Stream<UserConsentModel> getConsentsStream(RealmModel realm,
                                                             String userId)

      Obtains the consents associated with the user identified by the specified `userId`.
      Parameters:
        `realm` - a reference to the realm.
        `userId` - the user identifier.
      Returns:
        a non-null `Stream` of consents associated with the user.

    - #### updateConsent

          void updateConsent(RealmModel realm,
                             String userId,
                             UserConsentModel consent)

      Parameters:
        `realm` -
        `userId` -
        `consent` -
      Throws:
        `ModelException` - when consent doesn't exist for the userId

    - #### revokeConsentForClient

          boolean revokeConsentForClient(RealmModel realm,
                                         String userId,
                                         String clientInternalId)

    - #### setNotBeforeForUser

          void setNotBeforeForUser(RealmModel realm,
                                   UserModel user,
                                   int notBefore)

    - #### getNotBeforeOfUser

          int getNotBeforeOfUser(RealmModel realm,
                                 UserModel user)

    - #### getServiceAccount

          UserModel getServiceAccount(ClientModel client)

      Parameters:
        `client` -
      Returns:
      Throws:
        `IllegalArgumentException` - when there are more service accounts associated with the given clientId

    - #### getUsers

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

      Deprecated. Use `getUsersStream` instead.

    - #### getUsersStream

          default Stream<UserModel> getUsersStream(RealmModel realm,
                                                   boolean includeServiceAccounts)

      Obtains the users associated with the specified realm.
      Parameters:
        `realm` - a reference to the realm being used for the search.
        `includeServiceAccounts` - `true` if service accounts should be included in the result; `false` otherwise.
      Returns:
        a non-null `Stream` of users associated withe the realm.

    - #### getUsers

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

      Deprecated. Use `getUsersStream` instead.

    - #### getUsersStream

          default Stream<UserModel> getUsersStream(RealmModel realm,
                                                   Integer firstResult,
                                                   Integer maxResults,
                                                   boolean includeServiceAccounts)

      Obtains the users associated with the specified realm.
      Parameters:
        `realm` - a reference to the realm being used for the search.
        `firstResult` - first result to return. Ignored if negative.
        `maxResults` - maximum number of results to return. Ignored if negative.
        `includeServiceAccounts` - `true` if service accounts should be included in the result; `false` otherwise.
      Returns:
        a non-null `Stream` of users associated withe the realm.

    - #### addUser

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

      only used for local storage
      Parameters:
        `realm` -
        `id` -
        `username` -
        `addDefaultRoles` -
        `addDefaultRequiredActions` -
      Returns:

    - #### preRemove

          void preRemove(RealmModel realm)

    - #### removeImportedUsers

          void removeImportedUsers(RealmModel realm,
                                   String storageProviderId)

      Removes any imported users from a specific User Storage Provider.
      Parameters:
        `realm` -
        `storageProviderId` -

    - #### unlinkUsers

          void unlinkUsers(RealmModel realm,
                           String storageProviderId)

      Set federation link to null to imported users of a specific User Storage Provider
      Parameters:
        `realm` -
        `storageProviderId` -

    - #### preRemove

          void preRemove(RealmModel realm,
                         RoleModel role)

    - #### preRemove

          void preRemove(RealmModel realm,
                         GroupModel group)

    - #### preRemove

          void preRemove(RealmModel realm,
                         ClientModel client)

    - #### preRemove

          void preRemove(ProtocolMapperModel protocolMapper)

    - #### preRemove

          void preRemove(ClientScopeModel clientScope)

    - #### close

          void close()

      Specified by:
        `close` in interface `Provider`

    - #### preRemove

          void preRemove(RealmModel realm,
                         ComponentModel component)

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