Package org.keycloak.models
Interface UserProvider
- All Superinterfaces:
Provider,UserBulkUpdateProvider,UserCountMethodsProvider,UserLookupProvider,UserQueryMethodsProvider,UserQueryProvider,UserRegistrationProvider
- All Known Subinterfaces:
UserCache
- All Known Implementing Classes:
JpaUserProvider,UserCacheSession,UserStorageManager
public interface UserProvider
extends Provider, UserLookupProvider, UserQueryProvider, UserRegistrationProvider, UserBulkUpdateProvider
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsent(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 realmRecord that a verifiable credential was issued to a user.addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) Adds a new user into the storage.addVerifiableCredential(String userId, UserVerifiableCredentialModel credentialModel) Create verifiable credential of specified credential scope for this usergetConsentByClient(RealmModel realm, String userId, String clientInternalId) Returns UserConsentModel given by a user with the userId for the client with clientInternalIdgetConsentsStream(RealmModel realm, String userId) Obtains the consents associated with the user identified by the specifieduserId.getFederatedIdentitiesStream(RealmModel realm, UserModel user) Obtains the federated identities of the specified user.getFederatedIdentity(RealmModel realm, UserModel user, String socialProvider) Returns details of the association between the user and the socialProvider.Get all issued verifiable credentials for a specific user.intgetNotBeforeOfUser(RealmModel realm, UserModel user) Gets the notBefore value for the given usergetServiceAccount(ClientModel client) Return a UserModel representing service account of the clientgetUserByFederatedIdentity(RealmModel realm, FederatedIdentityModel socialLink) Returns a userModel that corresponds to the given socialLink.Default implementation ofSubjectCredentialManagersuitable for most of user providersgetVerifiableCredentialByClientScope(String userId, String clientScopeId) Get a verifiable credential for a user by client scope IDGet a verifiable credential by its IDgetVerifiableCredentialsByUser(String userId) Return all verifiable credentials of specified uservoidpreRemove(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.voidRemove all expired issued verifiable credentials across all realms.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.booleanremoveIssuedVerifiableCredential(String credentialId) Remove an issued verifiable credential by its ID.booleanremoveVerifiableCredential(String userId, String clientScopeId) Remove verifiable credential of specified client scope from this userbooleanrevokeConsentForClient(RealmModel realm, String userId, String clientInternalId) Remove a user consent given by the user id and client idvoidsetNotBeforeForUser(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 federatedIdentityModelupdateVerifiableCredential(String userId, String clientScopeId) Update verifiable credential by refreshing user attributes snapshot and incrementing revisionMethods inherited from interface org.keycloak.storage.user.UserBulkUpdateProvider
grantToAllUsersMethods inherited from interface org.keycloak.storage.user.UserCountMethodsProvider
getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCountMethods inherited from interface org.keycloak.storage.user.UserLookupProvider
getUserByCredential, getUserByEmail, getUserById, getUserByUsernameMethods inherited from interface org.keycloak.storage.user.UserQueryMethodsProvider
getGroupMembersStream, getGroupMembersStream, getGroupMembersStream, getRoleMembersStream, getRoleMembersStream, searchForUserByUserAttributeStream, searchForUserStream, searchForUserStream, searchForUserStream, searchForUserStreamMethods inherited from interface org.keycloak.storage.user.UserRegistrationProvider
addUser, removeUser
-
Method Details
-
setNotBeforeForUser
Sets the notBefore value for the given user- Parameters:
realm- a reference to the realmuser- the user modelnotBefore- new value for notBefore- Throws:
ModelException- when user doesn't exist in the storage
-
getNotBeforeOfUser
Gets the notBefore value for the given user- Parameters:
realm- a reference to the realmuser- the user model- Returns:
- the value of notBefore
- Throws:
ModelException- when user doesn't exist in the storage
-
getServiceAccount
Return a UserModel representing service account of the client- Parameters:
client- the client model- Returns:
- userModel representing service account of the client
- Throws:
IllegalArgumentException- when there are more service accounts associated with the given clientId
-
addUser
UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) Adds a new user into the storage. only used for local storage- Parameters:
realm- the realm that user will be created inid- id of the new user. Should be generated to a random value ifnull.username- usernameaddDefaultRoles- iftrue, the user should join all realm default rolesaddDefaultRequiredActions- iftrue, all default required actions are added to the created user- Returns:
- model of created user
- Throws:
NullPointerException- when username or realm isnullModelDuplicateException- when a user with given id or username already exists
-
removeImportedUsers
Removes any imported users from a specific User Storage Provider.- Parameters:
realm- a reference to the realmstorageProviderId- id of the user storage provider
-
unlinkUsers
Set federation link tonullto imported users of a specific User Storage Provider- Parameters:
realm- a reference to the realmstorageProviderId- id of the storage provider
-
addConsent
Add user consent for the user.- Parameters:
realm- a reference to the realmuserId- id of the userconsent- all details corresponding to the granted consent- Throws:
ModelException- If there is no user with userId
-
getConsentByClient
Returns UserConsentModel given by a user with the userId for the client with clientInternalId- Parameters:
realm- a reference to the realmuserId- id of the userclientInternalId- id of the client- Returns:
- consent given by the user to the client or
nullif no consent or user exists - Throws:
ModelException- when there are more consents fulfilling specified parameters
-
getConsentsStream
Obtains the consents associated with the user identified by the specifieduserId.- Parameters:
realm- a reference to the realm.userId- the user identifier.- Returns:
- a non-null
Streamof consents associated with the user.
-
updateConsent
Update client scopes in the stored user consent- Parameters:
realm- a reference to the realmuserId- id of the userconsent- new details of the user consent- Throws:
ModelException- when consent doesn't exist for the userId
-
revokeConsentForClient
Remove a user consent given by the user id and client id- Parameters:
realm- a reference to the realmuserId- id of the userclientInternalId- 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
-
addVerifiableCredential
UserVerifiableCredentialModel addVerifiableCredential(String userId, UserVerifiableCredentialModel credentialModel) Create verifiable credential of specified credential scope for this user- Parameters:
userId- id of the usercredentialModel- credential model with "clientScopeId" set. The other fields will be generated if not set- Returns:
- credentialModel with all the fields set
-
removeVerifiableCredential
Remove verifiable credential of specified client scope from this user- Parameters:
userId- id if the userclientScopeId- client scope ID to delete- Returns:
- true if credential was successfully removed. False otherwise
-
getVerifiableCredentialsByUser
Return all verifiable credentials of specified user- Parameters:
userId- id if the user- Returns:
- a non-null
Streamof all verifiable credentials of specified user
-
getVerifiableCredentialById
Get a verifiable credential by its ID- Parameters:
id- the verifiable credential ID- Returns:
- the credential model, or null if not found
-
getVerifiableCredentialByClientScope
UserVerifiableCredentialModel getVerifiableCredentialByClientScope(String userId, String clientScopeId) Get a verifiable credential for a user by client scope ID- Parameters:
userId- id of the userclientScopeId- client scope ID- Returns:
- the credential model, or null if not found
-
updateVerifiableCredential
Update verifiable credential by refreshing user attributes snapshot and incrementing revision- Parameters:
userId- id of the userclientScopeId- client scope ID to update- Returns:
- updated credential model
- Throws:
ModelException- if credential doesn't exist
-
addFederatedIdentity
Adds a federated identity link for the user within the realm- Parameters:
realm- a reference to the realmuser- the user modelsocialLink- the federated identity model containing all details of the association between the user and the identity provider
-
removeFederatedIdentity
Removes federation link between the user and the identity provider given by its id- Parameters:
realm- a reference to the realmuser- the user modelsocialProvider- alias of the identity provider, seeIdentityProviderModel.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
-
updateFederatedIdentity
void updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel) Update details of association between the federatedUser and the idp given by the federatedIdentityModel- Parameters:
realm- a reference to the realmfederatedUser- the user modelfederatedIdentityModel- the federated identity model containing all details of the association between the user and the identity provider
-
getFederatedIdentitiesStream
Obtains the federated identities of the specified user.- Parameters:
realm- a reference to the realm.user- the reference to the user.- Returns:
- a non-null
Streamof federated identities associated with the user.
-
getFederatedIdentity
FederatedIdentityModel getFederatedIdentity(RealmModel realm, UserModel user, String socialProvider) Returns details of the association between the user and the socialProvider.- Parameters:
realm- a reference to the realmuser- the user modelsocialProvider- the id of the identity provider- Returns:
- federatedIdentityModel or
nullif no association exists
-
getUserByFederatedIdentity
Returns a userModel that corresponds to the given socialLink.- Parameters:
realm- a reference to the realmsocialLink- the socialLink- Returns:
- the user corresponding to socialLink and
nullif no such user exists - Throws:
IllegalStateException- when there are more users for the given socialLink
-
preRemove
Called when a realm is removed. Should remove all users that belong to the realm.- Parameters:
realm- a reference to the realm
-
preRemove
Called when an identity provider is removed. Should remove all federated identities assigned to users from the provider.- Parameters:
realm- a reference to the realmprovider- provider model
-
preRemove
Called when a role is removed. Should remove the role membership for each user.- Parameters:
realm- a reference to the realmrole- the role model
-
preRemove
Called when a group is removed. Should remove the group membership for each user.- Parameters:
realm- a reference to the realmgroup- the group model
-
preRemove
Called when a client is removed. Should remove all user consents associated with the client- Parameters:
realm- a reference to the realmclient- the client model
-
preRemove
Called when a protocolMapper is removed- Parameters:
protocolMapper- the protocolMapper model
-
preRemove
Called when a client scope is removed. Should remove the clientScope from each user consent- Parameters:
clientScope- the clientScope model
-
preRemove
Called 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
- Parameters:
realm- a reference to the realmcomponent- the component model
-
getUserCredentialManager
Default implementation ofSubjectCredentialManagersuitable for most of user providers- Returns:
- user credential manager
-
addIssuedVerifiableCredential
IssuedVerifiableCredentialModel addIssuedVerifiableCredential(IssuedVerifiableCredentialModel issuedVc) Record that a verifiable credential was issued to a user.- Parameters:
issuedVc- model with userId, clientId, verifiableCredentialId set- Returns:
- issuedVerifiableCredentialModel with all the fields set (including ID)
-
getIssuedVerifiableCredentialsStreamByUser
Get all issued verifiable credentials for a specific user.- Parameters:
userId- user ID- Returns:
- stream of issued verifiable credentials, sorted by issuedAt descending
-
removeIssuedVerifiableCredential
Remove an issued verifiable credential by its ID.- Parameters:
credentialId- the ID of the issued credential to remove- Returns:
trueif the credential was removed,falseif it was not found
-
removeExpiredIssuedVerifiableCredentials
void removeExpiredIssuedVerifiableCredentials()Remove all expired issued verifiable credentials across all realms. This is called periodically by the scheduled cleanup task.
-