Package org.keycloak.models.jpa
Class JpaUserCredentialStore
java.lang.Object
org.keycloak.models.jpa.JpaUserCredentialStore
- All Implemented Interfaces:
UserCredentialStore,Provider
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final jakarta.persistence.EntityManagerprotected static final org.jboss.logging.Loggerstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionJpaUserCredentialStore(KeycloakSession session, jakarta.persistence.EntityManager em) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createCredential(RealmModel realm, UserModel user, CredentialModel cred) getStoredCredentialById(RealmModel realm, UserModel user, String id) getStoredCredentialByNameAndType(RealmModel realm, UserModel user, String name, String type) getStoredCredentialsByTypeStream(RealmModel realm, UserModel user, String type) Obtains the stored credentials associated with the specified user that match the specified type.getStoredCredentialsStream(RealmModel realm, UserModel user) Obtains the stored credentials associated with the specified user.booleanmoveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId) booleanremoveStoredCredential(RealmModel realm, UserModel user, String id) Removes credential with theidfor theuser.voidupdateCredential(RealmModel realm, UserModel user, CredentialModel cred) booleanupdateCredential(RealmModel realm, UserModel user, CredentialModel oldCred, CredentialModel newCred) Replaces a stored credential with a new version, but only if it still has the content of the old version.
-
Field Details
-
PRIORITY_DIFFERENCE
public static final int PRIORITY_DIFFERENCE- See Also:
-
logger
protected static final org.jboss.logging.Logger logger -
em
protected final jakarta.persistence.EntityManager em
-
-
Constructor Details
-
JpaUserCredentialStore
-
-
Method Details
-
updateCredential
- Specified by:
updateCredentialin interfaceUserCredentialStore
-
updateCredential
public boolean updateCredential(RealmModel realm, UserModel user, CredentialModel oldCred, CredentialModel newCred) Description copied from interface:UserCredentialStoreReplaces a stored credential with a new version, but only if it still has the content of the old version.Implementations must make the check and the replacement atomic, for example by locking the stored credential.
- Specified by:
updateCredentialin interfaceUserCredentialStore- Parameters:
realm- the realmuser- the useroldCred- the credential as it was read, identified by its idnewCred- the credential to store instead- Returns:
trueif the credential was replaced,falseif it was changed or removed in the meantime
-
createCredential
- Specified by:
createCredentialin interfaceUserCredentialStore
-
removeStoredCredential
Description copied from interface:UserCredentialStoreRemoves credential with theidfor theuser.- Specified by:
removeStoredCredentialin interfaceUserCredentialStore- Parameters:
realm- realm.user- userid- 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
-
getStoredCredentialById
- Specified by:
getStoredCredentialByIdin interfaceUserCredentialStore
-
getStoredCredentialsStream
Description copied from interface:UserCredentialStoreObtains the stored credentials associated with the specified user.- Specified by:
getStoredCredentialsStreamin interfaceUserCredentialStore- Parameters:
realm- a reference to the realm.user- the user whose credentials are being searched.- Returns:
- a non-null
Streamof credentials.
-
getStoredCredentialsByTypeStream
public 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 interfaceUserCredentialStore- 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.
-
getStoredCredentialByNameAndType
public CredentialModel getStoredCredentialByNameAndType(RealmModel realm, UserModel user, String name, String type) - Specified by:
getStoredCredentialByNameAndTypein interfaceUserCredentialStore
-
close
public void close() -
moveCredentialTo
public boolean moveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId) - Specified by:
moveCredentialToin interfaceUserCredentialStore
-