Package org.keycloak.storage.jpa
Class JpaUserFederatedStorageProvider
- java.lang.Object
- 
- org.keycloak.storage.jpa.JpaUserFederatedStorageProvider
 
- 
- All Implemented Interfaces:
- UserCredentialStore,- Provider,- UserAttributeFederatedStorage,- UserAttributeFederatedStorage.Streams,- UserBrokerLinkFederatedStorage,- UserBrokerLinkFederatedStorage.Streams,- UserConsentFederatedStorage,- UserConsentFederatedStorage.Streams,- UserFederatedStorageProvider,- UserFederatedStorageProvider.Streams,- UserFederatedUserCredentialStore,- UserFederatedUserCredentialStore.Streams,- UserGroupMembershipFederatedStorage,- UserGroupMembershipFederatedStorage.Streams,- UserNotBeforeFederatedStorage,- UserRequiredActionsFederatedStorage,- UserRequiredActionsFederatedStorage.Streams,- UserRoleMappingsFederatedStorage,- UserRoleMappingsFederatedStorage.Streams
 
 public class JpaUserFederatedStorageProvider extends Object implements UserFederatedStorageProvider.Streams, UserCredentialStore - Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserAttributeFederatedStorageUserAttributeFederatedStorage.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserBrokerLinkFederatedStorageUserBrokerLinkFederatedStorage.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserConsentFederatedStorageUserConsentFederatedStorage.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.credential.UserCredentialStoreUserCredentialStore.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserFederatedStorageProviderUserFederatedStorageProvider.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserFederatedUserCredentialStoreUserFederatedUserCredentialStore.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserGroupMembershipFederatedStorageUserGroupMembershipFederatedStorage.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserRequiredActionsFederatedStorageUserRequiredActionsFederatedStorage.Streams
 - 
Nested classes/interfaces inherited from interface org.keycloak.storage.federated.UserRoleMappingsFederatedStorageUserRoleMappingsFederatedStorage.Streams
 
- 
 - 
Constructor SummaryConstructors Constructor Description JpaUserFederatedStorageProvider(KeycloakSession session, javax.persistence.EntityManager em)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConsent(RealmModel realm, String userId, UserConsentModel consent)voidaddFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel link)voidaddRequiredAction(RealmModel realm, String userId, String action)voidclose()CredentialModelcreateCredential(RealmModel realm, String userId, CredentialModel cred)CredentialModelcreateCredential(RealmModel realm, UserModel user, CredentialModel cred)protected voidcreateIndex(RealmModel realm, String userId)We create an entry so that its easy to iterate over all things in the database.voiddeleteRoleMapping(RealmModel realm, String userId, RoleModel role)MultivaluedHashMap<String,String>getAttributes(RealmModel realm, String userId)UserConsentModelgetConsentByClient(RealmModel realm, String userId, String clientInternalId)Stream<UserConsentModel>getConsentsStream(RealmModel realm, String userId)Obtains the consents associated with the federated user identified byuserId.Stream<FederatedIdentityModel>getFederatedIdentitiesStream(String userId, RealmModel realm)Obtains the identities of the federated user identified byuserId.FederatedIdentityModelgetFederatedIdentity(String userId, String socialProvider, RealmModel realm)Stream<GroupModel>getGroupsStream(RealmModel realm, String userId)Obtains the groups associated with the federated user.Stream<String>getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max)Obtains the federated users that are members of the givengroupin the specifiedrealm.intgetNotBeforeOfUser(RealmModel realm, String userId)Stream<String>getRequiredActionsStream(RealmModel realm, String userId)Obtains the names of required actions associated with the federated user identified byuserId.Stream<RoleModel>getRoleMappingsStream(RealmModel realm, String userId)Obtains the roles associated with the federated user identified byuserId.CredentialModelgetStoredCredentialById(RealmModel realm, String userId, String id)CredentialModelgetStoredCredentialById(RealmModel realm, UserModel user, String id)CredentialModelgetStoredCredentialByNameAndType(RealmModel realm, String userId, String name, String type)CredentialModelgetStoredCredentialByNameAndType(RealmModel realm, UserModel user, String name, String type)Stream<CredentialModel>getStoredCredentialsByTypeStream(RealmModel realm, String userId, String type)Obtains the credentials of typetypethat are associated with the federated user identified byuserId.Stream<CredentialModel>getStoredCredentialsByTypeStream(RealmModel realm, UserModel user, String type)Obtains the stored credentials associated with the specified user that match the specified type.Stream<CredentialModel>getStoredCredentialsStream(RealmModel realm, String userId)Obtains the credentials associated with the federated user identified byuserId.Stream<CredentialModel>getStoredCredentialsStream(RealmModel realm, UserModel user)Obtains the stored credentials associated with the specified user.intgetStoredUsersCount(RealmModel realm)Stream<String>getStoredUsersStream(RealmModel realm, Integer first, Integer max)Obtains the ids of all federated users in the realm.StringgetUserByFederatedIdentity(FederatedIdentityModel link, RealmModel realm)Stream<String>getUsersByUserAttributeStream(RealmModel realm, String name, String value)Searches for federated users that have an attribute with the specifiednameandvalue.voidgrantRole(RealmModel realm, String userId, RoleModel role)voidjoinGroup(RealmModel realm, String userId, GroupModel group)voidleaveGroup(RealmModel realm, String userId, GroupModel group)booleanmoveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId)voidpreRemove(ClientScopeModel clientScope)voidpreRemove(ProtocolMapperModel protocolMapper)voidpreRemove(RealmModel realm)voidpreRemove(RealmModel realm, ComponentModel model)voidpreRemove(RealmModel realm, ClientModel client)voidpreRemove(RealmModel realm, GroupModel group)voidpreRemove(RealmModel realm, IdentityProviderModel provider)voidpreRemove(RealmModel realm, RoleModel role)voidpreRemove(RealmModel realm, UserModel user)voidremoveAttribute(RealmModel realm, String userId, String name)booleanremoveFederatedIdentity(RealmModel realm, String userId, String socialProvider)voidremoveRequiredAction(RealmModel realm, String userId, String action)booleanremoveStoredCredential(RealmModel realm, String userId, String id)booleanremoveStoredCredential(RealmModel realm, UserModel user, String id)Removes credential with theidfor theuser.booleanrevokeConsentForClient(RealmModel realm, String userId, String clientInternalId)voidsetAttribute(RealmModel realm, String userId, String name, List<String> values)voidsetNotBeforeForUser(RealmModel realm, String userId, int notBefore)voidsetSingleAttribute(RealmModel realm, String userId, String name, String value)protected CredentialModeltoModel(FederatedUserCredentialEntity entity)voidupdateConsent(RealmModel realm, String userId, UserConsentModel consent)voidupdateCredential(RealmModel realm, String userId, CredentialModel cred)voidupdateCredential(RealmModel realm, UserModel user, CredentialModel cred)voidupdateFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel model)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.storage.federated.UserAttributeFederatedStorage.StreamsgetUsersByUserAttribute
 - 
Methods inherited from interface org.keycloak.storage.federated.UserBrokerLinkFederatedStorage.StreamsgetFederatedIdentities
 - 
Methods inherited from interface org.keycloak.storage.federated.UserConsentFederatedStorage.StreamsgetConsents
 - 
Methods inherited from interface org.keycloak.storage.federated.UserFederatedStorageProvider.StreamsgetStoredUsers
 - 
Methods inherited from interface org.keycloak.storage.federated.UserFederatedUserCredentialStore.StreamsgetStoredCredentials, getStoredCredentialsByType
 - 
Methods inherited from interface org.keycloak.storage.federated.UserGroupMembershipFederatedStorage.StreamsgetGroups, getMembership
 - 
Methods inherited from interface org.keycloak.storage.federated.UserRequiredActionsFederatedStorage.StreamsgetRequiredActions
 - 
Methods inherited from interface org.keycloak.storage.federated.UserRoleMappingsFederatedStorage.StreamsgetRoleMappings
 
- 
 
- 
- 
- 
Constructor Detail- 
JpaUserFederatedStorageProviderpublic JpaUserFederatedStorageProvider(KeycloakSession session, javax.persistence.EntityManager em) 
 
- 
 - 
Method Detail- 
createIndexprotected void createIndex(RealmModel realm, String userId) We create an entry so that its easy to iterate over all things in the database. Specifically useful for export
 - 
setAttributepublic void setAttribute(RealmModel realm, String userId, String name, List<String> values) - Specified by:
- setAttributein interface- UserAttributeFederatedStorage
 
 - 
setSingleAttributepublic void setSingleAttribute(RealmModel realm, String userId, String name, String value) - Specified by:
- setSingleAttributein interface- UserAttributeFederatedStorage
 
 - 
removeAttributepublic void removeAttribute(RealmModel realm, String userId, String name) - Specified by:
- removeAttributein interface- UserAttributeFederatedStorage
 
 - 
getAttributespublic MultivaluedHashMap<String,String> getAttributes(RealmModel realm, String userId) - Specified by:
- getAttributesin interface- UserAttributeFederatedStorage
 
 - 
getUsersByUserAttributeStreampublic Stream<String> getUsersByUserAttributeStream(RealmModel realm, String name, String value) Description copied from interface:UserAttributeFederatedStorageSearches for federated users that have an attribute with the specifiednameandvalue.- Specified by:
- getUsersByUserAttributeStreamin interface- UserAttributeFederatedStorage
- Specified by:
- getUsersByUserAttributeStreamin interface- UserAttributeFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- name- the attribute name.
- value- the attribute value.
- Returns:
- a non-null Streamof users that match the search criteria.
 
 - 
getUserByFederatedIdentitypublic String getUserByFederatedIdentity(FederatedIdentityModel link, RealmModel realm) - Specified by:
- getUserByFederatedIdentityin interface- UserBrokerLinkFederatedStorage
 
 - 
addFederatedIdentitypublic void addFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel link) - Specified by:
- addFederatedIdentityin interface- UserBrokerLinkFederatedStorage
 
 - 
removeFederatedIdentitypublic boolean removeFederatedIdentity(RealmModel realm, String userId, String socialProvider) - Specified by:
- removeFederatedIdentityin interface- UserBrokerLinkFederatedStorage
 
 - 
preRemovepublic void preRemove(RealmModel realm, IdentityProviderModel provider) - Specified by:
- preRemovein interface- UserBrokerLinkFederatedStorage
 
 - 
updateFederatedIdentitypublic void updateFederatedIdentity(RealmModel realm, String userId, FederatedIdentityModel model) - Specified by:
- updateFederatedIdentityin interface- UserBrokerLinkFederatedStorage
 
 - 
getFederatedIdentitiesStreampublic Stream<FederatedIdentityModel> getFederatedIdentitiesStream(String userId, RealmModel realm) Description copied from interface:UserBrokerLinkFederatedStorageObtains the identities of the federated user identified byuserId.- Specified by:
- getFederatedIdentitiesStreamin interface- UserBrokerLinkFederatedStorage
- Specified by:
- getFederatedIdentitiesStreamin interface- UserBrokerLinkFederatedStorage.Streams
- Parameters:
- userId- the user identifier.
- realm- a reference to the realm.
- Returns:
- a non-null Streamof federated identities associated with the user.
 
 - 
getFederatedIdentitypublic FederatedIdentityModel getFederatedIdentity(String userId, String socialProvider, RealmModel realm) - Specified by:
- getFederatedIdentityin interface- UserBrokerLinkFederatedStorage
 
 - 
addConsentpublic void addConsent(RealmModel realm, String userId, UserConsentModel consent) - Specified by:
- addConsentin interface- UserConsentFederatedStorage
 
 - 
getConsentByClientpublic UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientInternalId) - Specified by:
- getConsentByClientin interface- UserConsentFederatedStorage
 
 - 
getConsentsStreampublic Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId) Description copied from interface:UserConsentFederatedStorageObtains the consents associated with the federated user identified byuserId.- Specified by:
- getConsentsStreamin interface- UserConsentFederatedStorage
- Specified by:
- getConsentsStreamin interface- UserConsentFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof consents associated with the user.
 
 - 
updateConsentpublic void updateConsent(RealmModel realm, String userId, UserConsentModel consent) - Specified by:
- updateConsentin interface- UserConsentFederatedStorage
 
 - 
revokeConsentForClientpublic boolean revokeConsentForClient(RealmModel realm, String userId, String clientInternalId) - Specified by:
- revokeConsentForClientin interface- UserConsentFederatedStorage
 
 - 
setNotBeforeForUserpublic void setNotBeforeForUser(RealmModel realm, String userId, int notBefore) - Specified by:
- setNotBeforeForUserin interface- UserNotBeforeFederatedStorage
 
 - 
getNotBeforeOfUserpublic int getNotBeforeOfUser(RealmModel realm, String userId) - Specified by:
- getNotBeforeOfUserin interface- UserNotBeforeFederatedStorage
 
 - 
getGroupsStreampublic Stream<GroupModel> getGroupsStream(RealmModel realm, String userId) Description copied from interface:UserGroupMembershipFederatedStorageObtains the groups associated with the federated user.- Specified by:
- getGroupsStreamin interface- UserGroupMembershipFederatedStorage
- Specified by:
- getGroupsStreamin interface- UserGroupMembershipFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof groups.
 
 - 
joinGrouppublic void joinGroup(RealmModel realm, String userId, GroupModel group) - Specified by:
- joinGroupin interface- UserGroupMembershipFederatedStorage
 
 - 
leaveGrouppublic void leaveGroup(RealmModel realm, String userId, GroupModel group) - Specified by:
- leaveGroupin interface- UserGroupMembershipFederatedStorage
 
 - 
getMembershipStreampublic Stream<String> getMembershipStream(RealmModel realm, GroupModel group, Integer firstResult, Integer max) Description copied from interface:UserGroupMembershipFederatedStorageObtains the federated users that are members of the givengroupin the specifiedrealm.- Specified by:
- getMembershipStreamin interface- UserGroupMembershipFederatedStorage
- Specified by:
- getMembershipStreamin interface- UserGroupMembershipFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- group- a reference to the group whose federated members are being searched.
- firstResult- first result to return. Ignored if negative or- null.
- max- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof federated user ids that are members of the group in the realm.
 
 - 
getRequiredActionsStreampublic Stream<String> getRequiredActionsStream(RealmModel realm, String userId) Description copied from interface:UserRequiredActionsFederatedStorageObtains the names of required actions associated with the federated user identified byuserId.- Specified by:
- getRequiredActionsStreamin interface- UserRequiredActionsFederatedStorage
- Specified by:
- getRequiredActionsStreamin interface- UserRequiredActionsFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof required action names.
 
 - 
addRequiredActionpublic void addRequiredAction(RealmModel realm, String userId, String action) - Specified by:
- addRequiredActionin interface- UserRequiredActionsFederatedStorage
 
 - 
removeRequiredActionpublic void removeRequiredAction(RealmModel realm, String userId, String action) - Specified by:
- removeRequiredActionin interface- UserRequiredActionsFederatedStorage
 
 - 
grantRolepublic void grantRole(RealmModel realm, String userId, RoleModel role) - Specified by:
- grantRolein interface- UserRoleMappingsFederatedStorage
 
 - 
getRoleMappingsStreampublic Stream<RoleModel> getRoleMappingsStream(RealmModel realm, String userId) Description copied from interface:UserRoleMappingsFederatedStorageObtains the roles associated with the federated user identified byuserId.- Specified by:
- getRoleMappingsStreamin interface- UserRoleMappingsFederatedStorage
- Specified by:
- getRoleMappingsStreamin interface- UserRoleMappingsFederatedStorage.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof roles.
 
 - 
deleteRoleMappingpublic void deleteRoleMapping(RealmModel realm, String userId, RoleModel role) - Specified by:
- deleteRoleMappingin interface- UserRoleMappingsFederatedStorage
 
 - 
updateCredentialpublic void updateCredential(RealmModel realm, String userId, CredentialModel cred) - Specified by:
- updateCredentialin interface- UserFederatedUserCredentialStore
 
 - 
createCredentialpublic CredentialModel createCredential(RealmModel realm, String userId, CredentialModel cred) - Specified by:
- createCredentialin interface- UserFederatedUserCredentialStore
 
 - 
removeStoredCredentialpublic boolean removeStoredCredential(RealmModel realm, String userId, String id) - Specified by:
- removeStoredCredentialin interface- UserFederatedUserCredentialStore
 
 - 
getStoredCredentialByIdpublic CredentialModel getStoredCredentialById(RealmModel realm, String userId, String id) - Specified by:
- getStoredCredentialByIdin interface- UserFederatedUserCredentialStore
 
 - 
toModelprotected CredentialModel toModel(FederatedUserCredentialEntity entity) 
 - 
getStoredCredentialsStreampublic Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm, String userId) Description copied from interface:UserFederatedUserCredentialStoreObtains the credentials associated with the federated user identified byuserId.- Specified by:
- getStoredCredentialsStreamin interface- UserFederatedUserCredentialStore
- Specified by:
- getStoredCredentialsStreamin interface- UserFederatedUserCredentialStore.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- Returns:
- a non-null Streamof credentials.
 
 - 
getStoredCredentialsByTypeStreampublic Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm, String userId, String type) Description copied from interface:UserFederatedUserCredentialStoreObtains the credentials of typetypethat are associated with the federated user identified byuserId.- Specified by:
- getStoredCredentialsByTypeStreamin interface- UserFederatedUserCredentialStore
- Specified by:
- getStoredCredentialsByTypeStreamin interface- UserFederatedUserCredentialStore.Streams
- Parameters:
- realm- a reference to the realm.
- userId- the user identifier.
- type- the credential type.
- Returns:
- a non-null Streamof credentials.
 
 - 
getStoredCredentialByNameAndTypepublic CredentialModel getStoredCredentialByNameAndType(RealmModel realm, String userId, String name, String type) - Specified by:
- getStoredCredentialByNameAndTypein interface- UserFederatedUserCredentialStore
 
 - 
getStoredUsersStreampublic Stream<String> getStoredUsersStream(RealmModel realm, Integer first, Integer max) Description copied from interface:UserFederatedStorageProviderObtains the ids of all federated users in the realm.- Specified by:
- getStoredUsersStreamin interface- UserFederatedStorageProvider
- Specified by:
- getStoredUsersStreamin interface- UserFederatedStorageProvider.Streams
- Parameters:
- realm- a reference to the realm.
- first- first result to return. Ignored if negative or- null.
- max- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof federated user ids.
 
 - 
updateCredentialpublic void updateCredential(RealmModel realm, UserModel user, CredentialModel cred) - Specified by:
- updateCredentialin interface- UserCredentialStore
 
 - 
createCredentialpublic CredentialModel createCredential(RealmModel realm, UserModel user, CredentialModel cred) - Specified by:
- createCredentialin interface- UserCredentialStore
 
 - 
removeStoredCredentialpublic boolean removeStoredCredential(RealmModel realm, UserModel user, String id) Description copied from interface:UserCredentialStoreRemoves credential with theidfor theuser.- Specified by:
- removeStoredCredentialin interface- UserCredentialStore
- Parameters:
- realm- realm.
- user- user
- id- id
- Returns:
- trueif the credential 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
 
 - 
getStoredCredentialByIdpublic CredentialModel getStoredCredentialById(RealmModel realm, UserModel user, String id) - Specified by:
- getStoredCredentialByIdin interface- UserCredentialStore
 
 - 
getStoredCredentialsStreampublic Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm, UserModel user) Description copied from interface:UserCredentialStoreObtains the stored credentials associated with the specified user.- Specified by:
- getStoredCredentialsStreamin interface- UserCredentialStore
- Parameters:
- realm- a reference to the realm.
- user- the user whose credentials are being searched.
- Returns:
- a non-null Streamof credentials.
 
 - 
getStoredCredentialsByTypeStreampublic Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm, UserModel user, String type) Description copied from interface:UserCredentialStoreObtains the stored credentials associated with the specified user that match the specified type.- Specified by:
- getStoredCredentialsByTypeStreamin interface- UserCredentialStore
- Parameters:
- realm- a reference to the realm.
- user- the user whose credentials are being searched.
- type- the type of credentials being searched.
- Returns:
- a non-null Streamof credentials.
 
 - 
getStoredCredentialByNameAndTypepublic CredentialModel getStoredCredentialByNameAndType(RealmModel realm, UserModel user, String name, String type) - Specified by:
- getStoredCredentialByNameAndTypein interface- UserCredentialStore
 
 - 
moveCredentialTopublic boolean moveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId) - Specified by:
- moveCredentialToin interface- UserCredentialStore
 
 - 
getStoredUsersCountpublic int getStoredUsersCount(RealmModel realm) - Specified by:
- getStoredUsersCountin interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm, RoleModel role) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm, GroupModel group) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm, ClientModel client) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(ProtocolMapperModel protocolMapper) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(ClientScopeModel clientScope) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm, UserModel user) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 - 
preRemovepublic void preRemove(RealmModel realm, ComponentModel model) - Specified by:
- preRemovein interface- UserFederatedStorageProvider
 
 
- 
 
-