Class UserCacheSession
- java.lang.Object
- 
- org.keycloak.models.cache.infinispan.UserCacheSession
 
- 
- All Implemented Interfaces:
- UserCache,- UserProvider,- Provider,- OnCreateComponent,- OnUpdateComponent,- UserBulkUpdateProvider,- UserLookupProvider,- UserQueryProvider,- UserRegistrationProvider
 
 public class UserCacheSession extends Object implements UserCache, OnCreateComponent, OnUpdateComponent - Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.keycloak.models.cache.UserCacheUserCache.Streams
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected UserCacheManagercacheprotected UserProviderdelegateprotected Set<InvalidationEvent>invalidationEventsprotected Set<String>invalidationsprotected static org.jboss.logging.Loggerloggerprotected Map<String,UserModel>managedUsersprotected Set<String>realmInvalidationsprotected KeycloakSessionsessionprotected booleansetRollbackOnlyprotected longstartupRevisionprotected booleantransactionActive
 - 
Constructor SummaryConstructors Constructor Description UserCacheSession(UserCacheManager cache, KeycloakSession session)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConsent(RealmModel realm, String userId, UserConsentModel consent)Add user consent for the user.voidaddFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink)Adds a federated identity link for the user within the realmUserModeladdUser(RealmModel realm, String username)All storage providers that implement this interface will be looped through.UserModeladdUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions)Adds a new user into the storage.protected UserModelcacheUser(RealmModel realm, UserModel delegate, Long revision)voidclear()Clear cache entirely.voidclose()voidevict(RealmModel realm)Evict users of a specific realmvoidevict(RealmModel realm, UserModel user)Evict user from cache.UserModelfindServiceAccount(ClientModel client)protected voidfullyInvalidateUser(RealmModel realm, UserModel user)UserConsentModelgetConsentByClient(RealmModel realm, String userId, String clientId)Returns UserConsentModel given by a user with the userId for the client with clientInternalIdStream<UserConsentModel>getConsentsStream(RealmModel realm, String userId)Obtains the consents associated with the user identified by the specifieduserId.UserProvidergetDelegate()Stream<FederatedIdentityModel>getFederatedIdentitiesStream(RealmModel realm, UserModel user)Obtains the federated identities of the specified user.FederatedIdentityModelgetFederatedIdentity(RealmModel realm, UserModel user, String socialProvider)Returns details of the association between the user and the socialProvider.Stream<UserModel>getGroupMembersStream(RealmModel realm, GroupModel group)Obtains users that belong to a specific group.Stream<UserModel>getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults)Obtains users that belong to a specific group.intgetNotBeforeOfUser(RealmModel realm, UserModel user)Gets the notBefore value for the given userStream<UserModel>getRoleMembersStream(RealmModel realm, RoleModel role)Obtains users that have the specified role.Stream<UserModel>getRoleMembersStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)Searches for users that have the specified role.UserModelgetServiceAccount(ClientModel client)Return a UserModel representing service account of the clientprotected UserModelgetUserAdapter(RealmModel realm, String userId, Long loaded, UserModel delegate)CredentialValidationOutputgetUserByCredential(RealmModel realm, CredentialInput input)UserModelgetUserByEmail(RealmModel realm, String email)Returns a user with the given email belonging to the realmUserModelgetUserByFederatedIdentity(RealmModel realm, FederatedIdentityModel socialLink)Returns a userModel that corresponds to the given socialLink.UserModelgetUserById(RealmModel realm, String id)Returns a user with the given id belonging to the realmUserModelgetUserByUsername(RealmModel realm, String username)Exact search for a user by its username.intgetUsersCount(RealmModel realm, boolean includeServiceAccount)Returns the number of users.intgetUsersCount(RealmModel realm, String search)Returns the number of users that would be returned by a call tosearchForUserStreamintgetUsersCount(RealmModel realm, String search, Set<String> groupIds)Returns the number of users that would be returned by a call tosearchForUserStreamand are members of at least one of the groups given by thegroupIdsset.intgetUsersCount(RealmModel realm, Map<String,String> params)Returns the number of users that match the given filter parameters.intgetUsersCount(RealmModel realm, Map<String,String> params, Set<String> groupIds)Returns the number of users that match the given filter parameters and is in at least one of the given groups.intgetUsersCount(RealmModel realm, Set<String> groupIds)Returns the number of users that are in at least one of the groups given.voidgrantToAllUsers(RealmModel realm, RoleModel role)Grants the given role to all users from particular realm.voidonCreate(KeycloakSession session, RealmModel realm, ComponentModel model)voidonUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel)voidpreRemove(ClientScopeModel clientScope)Called when a client scope is removed.voidpreRemove(ProtocolMapperModel protocolMapper)Called when a protocolMapper is removedvoidpreRemove(RealmModel realm)Called when a realm is removed.voidpreRemove(RealmModel realm, ComponentModel component)Called when a component is removed.voidpreRemove(RealmModel realm, ClientModel client)Called when a client is removed.voidpreRemove(RealmModel realm, GroupModel group)Called when a group is removed.voidpreRemove(RealmModel realm, IdentityProviderModel provider)Called when an identity provider is removed.voidpreRemove(RealmModel realm, RoleModel role)Called when a role is removed.voidregisterUserInvalidation(RealmModel realm, CachedUser user)booleanremoveFederatedIdentity(RealmModel realm, UserModel user, String socialProvider)Removes federation link between the user and the identity provider given by its idvoidremoveImportedUsers(RealmModel realm, String storageProviderId)Removes any imported users from a specific User Storage Provider.booleanremoveUser(RealmModel realm, UserModel user)Called if user originated from this provider.booleanrevokeConsentForClient(RealmModel realm, String userId, String clientInternalId)Remove a user consent given by the user id and client idprotected voidrunInvalidations()Stream<UserModel>searchForUserByUserAttributeStream(RealmModel realm, String attrName, String attrValue)Searches for users that have a specific attribute with a specific value.Stream<UserModel>searchForUserStream(RealmModel realm, String search)Searches for users whose username, email, first name or last name contain any of the strings insearchseparated by whitespace.Stream<UserModel>searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults)Searches for users whose username, email, first name or last name contain any of the strings insearchseparated by whitespace.Stream<UserModel>searchForUserStream(RealmModel realm, Map<String,String> attributes)Searches for user by parameter.Stream<UserModel>searchForUserStream(RealmModel realm, Map<String,String> attributes, Integer firstResult, Integer maxResults)Searches for user by parameter.voidsetNotBeforeForUser(RealmModel realm, UserModel user, int notBefore)Sets the notBefore value for the given uservoidunlinkUsers(RealmModel realm, String storageProviderId)Set federation link tonullto imported users of a specific User Storage ProvidervoidupdateConsent(RealmModel realm, String userId, UserConsentModel consent)Update client scopes in the stored user consentvoidupdateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel)Update details of association between the federatedUser and the idp given by the federatedIdentityModelprotected UserModelvalidateCache(RealmModel realm, CachedUser cached)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.models.UserProvidergetUsersStream, getUsersStream
 - 
Methods inherited from interface org.keycloak.storage.user.UserQueryProvidergetUsersCount, getUsersStream, getUsersStream
 
- 
 
- 
- 
- 
Field Detail- 
loggerprotected static final org.jboss.logging.Logger logger 
 - 
cacheprotected UserCacheManager cache 
 - 
sessionprotected KeycloakSession session 
 - 
delegateprotected UserProvider delegate 
 - 
transactionActiveprotected boolean transactionActive 
 - 
setRollbackOnlyprotected boolean setRollbackOnly 
 - 
startupRevisionprotected final long startupRevision 
 - 
invalidationEventsprotected Set<InvalidationEvent> invalidationEvents 
 
- 
 - 
Constructor Detail- 
UserCacheSessionpublic UserCacheSession(UserCacheManager cache, KeycloakSession session) 
 
- 
 - 
Method Detail- 
clearpublic void clear() Description copied from interface:UserCacheClear cache entirely.
 - 
getDelegatepublic UserProvider getDelegate() 
 - 
registerUserInvalidationpublic void registerUserInvalidation(RealmModel realm, CachedUser user) 
 - 
evictpublic void evict(RealmModel realm, UserModel user) Description copied from interface:UserCacheEvict user from cache.
 - 
evictpublic void evict(RealmModel realm) Description copied from interface:UserCacheEvict users of a specific realm
 - 
runInvalidationsprotected void runInvalidations() 
 - 
getUserByIdpublic UserModel getUserById(RealmModel realm, String id) Description copied from interface:UserLookupProviderReturns a user with the given id belonging to the realm- Specified by:
- getUserByIdin interface- UserLookupProvider
- Parameters:
- realm- the realm model
- id- id of the user
- Returns:
- found user model, or nullif no such user exists
 
 - 
getUserByUsernamepublic UserModel getUserByUsername(RealmModel realm, String username) Description copied from interface:UserLookupProviderExact search for a user by its username. Returns a user with the given username belonging to the realm- Specified by:
- getUserByUsernamein interface- UserLookupProvider
- Parameters:
- realm- the realm model
- username- (case-sensitivity is controlled by storage)
- Returns:
- found user model, or nullif no such user exists
 
 - 
getUserAdapterprotected UserModel getUserAdapter(RealmModel realm, String userId, Long loaded, UserModel delegate) 
 - 
validateCacheprotected UserModel validateCache(RealmModel realm, CachedUser cached) 
 - 
cacheUserprotected UserModel cacheUser(RealmModel realm, UserModel delegate, Long revision) 
 - 
getUserByEmailpublic UserModel getUserByEmail(RealmModel realm, String email) Description copied from interface:UserLookupProviderReturns a user with the given email belonging to the realm- Specified by:
- getUserByEmailin interface- UserLookupProvider
- Parameters:
- realm- the realm model
- email- email address
- Returns:
- found user model, or nullif no such user exists
 
 - 
closepublic void close() - Specified by:
- closein interface- Provider
- Specified by:
- closein interface- UserProvider
 
 - 
getUserByFederatedIdentitypublic UserModel getUserByFederatedIdentity(RealmModel realm, FederatedIdentityModel socialLink) Description copied from interface:UserProviderReturns a userModel that corresponds to the given socialLink.- Specified by:
- getUserByFederatedIdentityin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- socialLink- the socialLink
- Returns:
- the user corresponding to socialLink and nullif no such user exists
 
 - 
getGroupMembersStreampublic Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults) Description copied from interface:UserQueryProviderObtains users that belong to a specific group.- Specified by:
- getGroupMembersStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- group- a reference to the group.
- firstResult- first result to return. Ignored if negative, zero, or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof users that belong to the group.
 
 - 
getGroupMembersStreampublic Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group) Description copied from interface:UserQueryProviderObtains users that belong to a specific group.- Specified by:
- getGroupMembersStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- group- a reference to the group.
- Returns:
- a non-null Streamof users that belong to the group.
 
 - 
getRoleMembersStreampublic Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Description copied from interface:UserQueryProviderSearches for users that have the specified role.- Specified by:
- getRoleMembersStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- role- a reference to the role.
- firstResult- first result to return. Ignored if negative or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof users that have the specified role.
 
 - 
getRoleMembersStreampublic Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role) Description copied from interface:UserQueryProviderObtains users that have the specified role.- Specified by:
- getRoleMembersStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- role- a reference to the role.
- Returns:
- a non-null Streamof users that have the specified role.
 
 - 
getServiceAccountpublic UserModel getServiceAccount(ClientModel client) Description copied from interface:UserProviderReturn a UserModel representing service account of the client- Specified by:
- getServiceAccountin interface- UserProvider
- Parameters:
- client- the client model
- Returns:
- userModel representing service account of the client
 
 - 
findServiceAccountpublic UserModel findServiceAccount(ClientModel client) 
 - 
getUserByCredentialpublic CredentialValidationOutput getUserByCredential(RealmModel realm, CredentialInput input) - Specified by:
- getUserByCredentialin interface- UserLookupProvider
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, boolean includeServiceAccount) Description copied from interface:UserQueryProviderReturns the number of users.- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- includeServiceAccount- if true, the number of users will also include service accounts. Otherwise, only the number of users.
- Returns:
- the number of users
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, Set<String> groupIds) Description copied from interface:UserQueryProviderReturns the number of users that are in at least one of the groups given.- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- groupIds- set of groups IDs, the returned user needs to belong to at least one of them
- Returns:
- the number of users that are in at least one of the groups
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, String search) Description copied from interface:UserQueryProviderReturns the number of users that would be returned by a call tosearchForUserStream- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- search- case insensitive list of strings separated by whitespaces.
- Returns:
- number of users that match the search
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, String search, Set<String> groupIds) Description copied from interface:UserQueryProviderReturns the number of users that would be returned by a call tosearchForUserStreamand are members of at least one of the groups given by thegroupIdsset.- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- search- case insensitive list of strings separated by whitespaces.
- groupIds- set of groups IDs, the returned user needs to belong to at least one of them
- Returns:
- number of users that match the search and given groups
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, Map<String,String> params) Description copied from interface:UserQueryProviderReturns the number of users that match the given filter parameters.- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- params- filter parameters
- Returns:
- number of users that match the given filters
 
 - 
getUsersCountpublic int getUsersCount(RealmModel realm, Map<String,String> params, Set<String> groupIds) Description copied from interface:UserQueryProviderReturns the number of users that match the given filter parameters and is in at least one of the given groups.- Specified by:
- getUsersCountin interface- UserQueryProvider
- Parameters:
- realm- the realm
- params- filter parameters
- groupIds- set if groups to check for
- Returns:
- number of users that match the given filters and groups
 
 - 
searchForUserStreampublic Stream<UserModel> searchForUserStream(RealmModel realm, String search) Description copied from interface:UserQueryProviderSearches for users whose username, email, first name or last name contain any of the strings insearchseparated by whitespace. 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:
- searchForUserStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- search- case insensitive list of string separated by whitespaces.
- Returns:
- a non-null Streamof users that match the search string.
 
 - 
searchForUserStreampublic Stream<UserModel> searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults) Description copied from interface:UserQueryProviderSearches for users whose username, email, first name or last name contain any of the strings insearchseparated by whitespace. 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:
- searchForUserStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- search- case insensitive list of string separated by whitespaces.
- firstResult- first result to return. Ignored if negative, zero, or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof users that match the search criteria.
 
 - 
searchForUserStreampublic Stream<UserModel> searchForUserStream(RealmModel realm, Map<String,String> attributes) Description copied from interface:UserQueryProviderSearches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). Valid parameters are:- UserModel.FIRST_NAME- first name (case insensitive string)
- UserModel.LAST_NAME- last name (case insensitive string)
- UserModel.EMAIL- email (case insensitive string)
- UserModel.USERNAME- username (case insensitive string)
- UserModel.EMAIL_VERIFIED- search only for users with verified/non-verified email (true/false)
- UserModel.ENABLED- search only for enabled/disabled users (true/false)
- UserModel.IDP_ALIAS- search only for users that have a federated identity from idp with the given alias configured (case sensitive string)
- UserModel.IDP_USER_ID- search for users with federated identity with the given userId (case sensitive string)
 - Specified by:
- searchForUserStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- attributes- a map containing the search parameters.
- Returns:
- a non-null Streamof users that match the search parameters.
 
 - 
searchForUserStreampublic Stream<UserModel> searchForUserStream(RealmModel realm, Map<String,String> attributes, Integer firstResult, Integer maxResults) Description copied from interface:UserQueryProviderSearches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). Valid parameters are:- UserModel.FIRST_NAME- first name (case insensitive string)
- UserModel.LAST_NAME- last name (case insensitive string)
- UserModel.EMAIL- email (case insensitive string)
- UserModel.USERNAME- username (case insensitive string)
- UserModel.EMAIL_VERIFIED- search only for users with verified/non-verified email (true/false)
- UserModel.ENABLED- search only for enabled/disabled users (true/false)
- UserModel.IDP_ALIAS- search only for users that have a federated identity from idp with the given alias configured (case sensitive string)
- UserModel.IDP_USER_ID- search for users with federated identity with the given userId (case sensitive string)
 - Specified by:
- searchForUserStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- attributes- a map containing the search parameters.
- firstResult- first result to return. Ignored if negative, zero, or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof users that match the search criteria.
 
 - 
searchForUserByUserAttributeStreampublic Stream<UserModel> searchForUserByUserAttributeStream(RealmModel realm, String attrName, String attrValue) Description copied from interface:UserQueryProviderSearches for users that have a specific attribute with a specific value.- Specified by:
- searchForUserByUserAttributeStreamin interface- UserQueryProvider
- Parameters:
- realm- a reference to the realm.
- attrName- the attribute name.
- attrValue- the attribute value.
- Returns:
- a non-null Streamof users that match the search criteria.
 
 - 
getFederatedIdentitiesStreampublic Stream<FederatedIdentityModel> getFederatedIdentitiesStream(RealmModel realm, UserModel user) Description copied from interface:UserProviderObtains the federated identities of the specified user.- Specified by:
- getFederatedIdentitiesStreamin interface- UserProvider
- Parameters:
- realm- a reference to the realm.
- user- the reference to the user.
- Returns:
- a non-null Streamof federated identities associated with the user.
 
 - 
getFederatedIdentitypublic FederatedIdentityModel getFederatedIdentity(RealmModel realm, UserModel user, String socialProvider) Description copied from interface:UserProviderReturns details of the association between the user and the socialProvider.- Specified by:
- getFederatedIdentityin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- user- the user model
- socialProvider- the id of the identity provider
- Returns:
- federatedIdentityModel or nullif no association exists
 
 - 
updateConsentpublic void updateConsent(RealmModel realm, String userId, UserConsentModel consent) Description copied from interface:UserProviderUpdate client scopes in the stored user consent- Specified by:
- updateConsentin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- userId- id of the user
- consent- new details of the user consent
 
 - 
revokeConsentForClientpublic boolean revokeConsentForClient(RealmModel realm, String userId, String clientInternalId) Description copied from interface:UserProviderRemove a user consent given by the user id and client id- Specified by:
- revokeConsentForClientin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- userId- id of the user
- clientInternalId- id of the client
- Returns:
- trueif the consent was removed,- falseotherwise TODO: Make this method return Boolean so that store can return "I don't know" answer, this can be used for example in async stores
 
 - 
addConsentpublic void addConsent(RealmModel realm, String userId, UserConsentModel consent) Description copied from interface:UserProviderAdd user consent for the user.- Specified by:
- addConsentin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- userId- id of the user
- consent- all details corresponding to the granted consent
 
 - 
getConsentByClientpublic UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientId) Description copied from interface:UserProviderReturns UserConsentModel given by a user with the userId for the client with clientInternalId- Specified by:
- getConsentByClientin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- userId- id of the user
- clientId- id of the client
- Returns:
- consent given by the user to the client or nullif no consent or user exists
 
 - 
getConsentsStreampublic Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId) Description copied from interface:UserProviderObtains the consents associated with the user identified by the specifieduserId.- Specified by:
- getConsentsStreamin interface- UserProvider
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof consents associated with the user.
 
 - 
setNotBeforeForUserpublic void setNotBeforeForUser(RealmModel realm, UserModel user, int notBefore) Description copied from interface:UserProviderSets the notBefore value for the given user- Specified by:
- setNotBeforeForUserin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- user- the user model
- notBefore- new value for notBefore
 
 - 
getNotBeforeOfUserpublic int getNotBeforeOfUser(RealmModel realm, UserModel user) Description copied from interface:UserProviderGets the notBefore value for the given user- Specified by:
- getNotBeforeOfUserin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- user- the user model
- Returns:
- the value of notBefore
 
 - 
addUserpublic UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) Description copied from interface:UserProviderAdds a new user into the storage. only used for local storage- Specified by:
- addUserin interface- UserProvider
- Parameters:
- realm- the realm that user will be created in
- id- id of the new user. Should be generated to a random value if- null.
- username- username
- addDefaultRoles- if- true, the user should join all realm default roles
- addDefaultRequiredActions- if- true, all default required actions are added to the created user
- Returns:
- model of created user
 
 - 
addUserpublic UserModel addUser(RealmModel realm, String username) Description copied from interface:UserRegistrationProviderAll storage providers that implement this interface will be looped through. If this method returns null, then the next storage provider's addUser() method will be called. If no storage providers handle the add, then the user will be created in local storage. Returning null is useful when you want optional support for adding users. For example, our LDAP provider can enable and disable the ability to add users.- Specified by:
- addUserin interface- UserRegistrationProvider
- Parameters:
- realm- a reference to the realm
- username- a username the created user will be assigned
- Returns:
- a model of created user
 
 - 
fullyInvalidateUserprotected void fullyInvalidateUser(RealmModel realm, UserModel user) 
 - 
removeUserpublic boolean removeUser(RealmModel realm, UserModel user) Description copied from interface:UserRegistrationProviderCalled if user originated from this provider. If a local user is linked to this provider, this method will be called before local storage's removeUser() method is invoked. If you are using an import strategy, and this is a local user linked to this provider, this method will be called before local storage's removeUser() method is invoked. Also, you DO NOT need to remove the imported user. The runtime will handle this for you.- Specified by:
- removeUserin interface- UserRegistrationProvider
- Parameters:
- realm- a reference to the realm
- user- a reference to the user that is removed
- Returns:
- true if the user was removed, false otherwise
 
 - 
addFederatedIdentitypublic void addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink) Description copied from interface:UserProviderAdds a federated identity link for the user within the realm- Specified by:
- addFederatedIdentityin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- user- the user model
- socialLink- the federated identity model containing all details of the association between the user and the identity provider
 
 - 
updateFederatedIdentitypublic void updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel) Description copied from interface:UserProviderUpdate details of association between the federatedUser and the idp given by the federatedIdentityModel- Specified by:
- updateFederatedIdentityin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- federatedUser- the user model
- federatedIdentityModel- the federated identity model containing all details of the association between the user and the identity provider
 
 - 
removeFederatedIdentitypublic boolean removeFederatedIdentity(RealmModel realm, UserModel user, String socialProvider) Description copied from interface:UserProviderRemoves federation link between the user and the identity provider given by its id- Specified by:
- removeFederatedIdentityin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- user- the user model
- socialProvider- alias of the identity provider, see- IdentityProviderModel.getAlias()
- Returns:
- trueif the association was removed,- falseotherwise TODO: Make this method return Boolean so that store can return "I don't know" answer, this can be used for example in async stores
 
 - 
preRemovepublic void preRemove(RealmModel realm, IdentityProviderModel provider) Description copied from interface:UserProviderCalled when an identity provider is removed. Should remove all federated identities assigned to users from the provider.- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
- provider- provider model
 
 - 
grantToAllUserspublic void grantToAllUsers(RealmModel realm, RoleModel role) Description copied from interface:UserBulkUpdateProviderGrants the given role to all users from particular realm. The role has to belong to the realm.- Specified by:
- grantToAllUsersin interface- UserBulkUpdateProvider
- Parameters:
- realm- Realm
- role- Role to be granted
 
 - 
preRemovepublic void preRemove(RealmModel realm) Description copied from interface:UserProviderCalled when a realm is removed. Should remove all users that belong to the realm.- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
 
 - 
preRemovepublic void preRemove(RealmModel realm, RoleModel role) Description copied from interface:UserProviderCalled when a role is removed. Should remove the role membership for each user.- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
- role- the role model
 
 - 
preRemovepublic void preRemove(RealmModel realm, GroupModel group) Description copied from interface:UserProviderCalled when a group is removed. Should remove the group membership for each user.- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
- group- the group model
 
 - 
preRemovepublic void preRemove(RealmModel realm, ClientModel client) Description copied from interface:UserProviderCalled when a client is removed. Should remove all user consents associated with the client- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
- client- the client model
 
 - 
preRemovepublic void preRemove(ProtocolMapperModel protocolMapper) Description copied from interface:UserProviderCalled when a protocolMapper is removed- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- protocolMapper- the protocolMapper model
 
 - 
preRemovepublic void preRemove(ClientScopeModel clientScope) Description copied from interface:UserProviderCalled when a client scope is removed. Should remove the clientScope from each user consent- Specified by:
- preRemovein interface- UserProvider
- Parameters:
- clientScope- the clientScope model
 
 - 
preRemovepublic void preRemove(RealmModel realm, ComponentModel component) Description copied from interface:UserProviderCalled when a component is removed. Should remove all data in UserStorage associated with removed component. For example,- if component corresponds to UserStorageProvider all imported users from the provider should be removed,
- if component corresponds to ClientStorageProvider all consents granted for clients imported from the provider should be removed
 - Specified by:
- preRemovein interface- UserProvider
- Parameters:
- realm- a reference to the realm
- component- the component model
 
 - 
removeImportedUserspublic void removeImportedUsers(RealmModel realm, String storageProviderId) Description copied from interface:UserProviderRemoves any imported users from a specific User Storage Provider.- Specified by:
- removeImportedUsersin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- storageProviderId- id of the user storage provider
 
 - 
unlinkUserspublic void unlinkUsers(RealmModel realm, String storageProviderId) Description copied from interface:UserProviderSet federation link tonullto imported users of a specific User Storage Provider- Specified by:
- unlinkUsersin interface- UserProvider
- Parameters:
- realm- a reference to the realm
- storageProviderId- id of the storage provider
 
 - 
onUpdatepublic void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) - Specified by:
- onUpdatein interface- OnUpdateComponent
 
 - 
onCreatepublic void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) - Specified by:
- onCreatein interface- OnCreateComponent
 
 
- 
 
-