Package org.keycloak.credential
Class UserCredentialManager
java.lang.Object
org.keycloak.storage.AbstractStorageManager<UserStorageProvider,UserStorageProviderModel>
org.keycloak.credential.UserCredentialManager
- All Implemented Interfaces:
SubjectCredentialManager,UserCredentialManager
- Direct Known Subclasses:
SubjectCredentialManagerCacheAdapter
public class UserCredentialManager
extends AbstractStorageManager<UserStorageProvider,UserStorageProviderModel>
implements UserCredentialManager
Handling credentials for a given user for the store.
- Author:
- Alexander Schwartz
-
Constructor Summary
ConstructorsConstructorDescriptionUserCredentialManager(KeycloakSession session, RealmModel realm, UserModel user) It is not recommended to use this method directly from your user-storage providers! -
Method Summary
Modifier and TypeMethodDescriptionUpdates a credential of the entity with an updatedCredentialModel.voiddisableCredentialType(String credentialType) Disable a credential by type.List the credentials that can be disabled, for example, to show the list to the entity (aka user) or an admin.Returns a stream consisting of the federated credentials.Returns a stream consisting of the first-factor credentials.Read a stored credential.getStoredCredentialByNameAndType(String name, String type) Read stored credentials by type as a stream.Read stored credentials as a stream.booleanisConfiguredFor(String type) Check if the credential type is configured for this entity.booleanisConfiguredLocally(String type) booleanisValid(List<CredentialInput> inputs) Validate a list of credentials.booleanmoveStoredCredentialTo(String id, String newPreviousCredentialId) Re-order the stored credentials.booleanUpdates a credential of the entity with an updatedCredentialModel.booleanupdateCredential(CredentialInput input) Updates a credential of the entity with the inputs provided by the entity.Updates a credential of the entity with the inputs provided by the entity, and returns the credential as written to the Keycloak credential store.voidupdateCredentialLabel(String credentialId, String userLabel) Update the label for a stored credentials chosen by the owner of the entity.voidUpdates a credential of the entity with an updatedCredentialModel.booleanupdateStoredCredential(CredentialModel oldCred, CredentialModel newCred) Replaces a credential of the entity with a new version, but only if the stored credential still has the content of the old version.Methods inherited from class org.keycloak.storage.AbstractStorageManager
consumeEnabledStorageProvidersWithTimeout, flatMapEnabledStorageProvidersWithTimeout, getEnabledStorageProviders, getStorageProviderFactory, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderModel, getStorageProviderModels, getStorageProviderTimeout, mapEnabledStorageProvidersWithTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.SubjectCredentialManager
getCredentials, isValid
-
Constructor Details
-
UserCredentialManager
It is not recommended to use this method directly from your user-storage providers! Please usesession.users().getUserCredentialManager(user)instead.
-
-
Method Details
-
isValid
Description copied from interface:SubjectCredentialManagerValidate a list of credentials.- Specified by:
isValidin interfaceSubjectCredentialManager- Returns:
trueif inputs are valid
-
updateCredential
Description copied from interface:SubjectCredentialManagerUpdates a credential of the entity with the inputs provided by the entity.- Specified by:
updateCredentialin interfaceSubjectCredentialManager- Returns:
trueif credentials have been updated successfully
-
updateCredentialAndGet
Description copied from interface:SubjectCredentialManagerUpdates a credential of the entity with the inputs provided by the entity, and returns the credential as written to the Keycloak credential store.The default implementation performs the update and reports no stored credential. Implementations writing credentials to the Keycloak credential store are expected to override it; leaving the default in place only means callers cannot identify the credential that was written.
- Specified by:
updateCredentialAndGetin interfaceSubjectCredentialManager- Returns:
- the credential written to the Keycloak credential store, or an empty
Optionalwhen nothing has been written there, for example because a user-storage provider handled the update
-
updateStoredCredential
Description copied from interface:SubjectCredentialManagerUpdates a credential of the entity with an updatedCredentialModel. Usually called by aCredentialProvider.- Specified by:
updateStoredCredentialin interfaceSubjectCredentialManager
-
updateStoredCredential
Description copied from interface:SubjectCredentialManagerReplaces a credential of the entity with a new version, but only if the stored credential still has the content of the old version. Use this to update a credential that was read earlier, so that changes made in the meantime are not overwritten.Implementations must make the check and the replacement atomic, for example by locking the stored credential.
- Specified by:
updateStoredCredentialin interfaceSubjectCredentialManager- Parameters:
oldCred- 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
-
createStoredCredential
Description copied from interface:SubjectCredentialManagerUpdates a credential of the entity with an updatedCredentialModel. Usually called by aCredentialProvider.- Specified by:
createStoredCredentialin interfaceSubjectCredentialManager
-
removeStoredCredentialById
Description copied from interface:SubjectCredentialManagerUpdates a credential of the entity with an updatedCredentialModel. Usually called by aCredentialProvider, or from the account management when a user removes, for example, an OTP token.- Specified by:
removeStoredCredentialByIdin interfaceSubjectCredentialManager
-
getStoredCredentialById
Description copied from interface:SubjectCredentialManagerRead a stored credential.- Specified by:
getStoredCredentialByIdin interfaceSubjectCredentialManager
-
getStoredCredentialsStream
Description copied from interface:SubjectCredentialManagerRead stored credentials as a stream.- Specified by:
getStoredCredentialsStreamin interfaceSubjectCredentialManager
-
getFederatedCredentialsStream
Description copied from interface:SubjectCredentialManagerReturns a stream consisting of the federated credentials.- Specified by:
getFederatedCredentialsStreamin interfaceSubjectCredentialManager- Returns:
- a stream consisting of the federated credentials
-
getStoredCredentialsByTypeStream
Description copied from interface:SubjectCredentialManagerRead stored credentials by type as a stream.- Specified by:
getStoredCredentialsByTypeStreamin interfaceSubjectCredentialManager
-
getStoredCredentialByNameAndType
- Specified by:
getStoredCredentialByNameAndTypein interfaceSubjectCredentialManager
-
moveStoredCredentialTo
Description copied from interface:SubjectCredentialManagerRe-order the stored credentials.- Specified by:
moveStoredCredentialToin interfaceSubjectCredentialManager
-
updateCredentialLabel
Description copied from interface:SubjectCredentialManagerUpdate the label for a stored credentials chosen by the owner of the entity.- Specified by:
updateCredentialLabelin interfaceSubjectCredentialManager
-
disableCredentialType
Description copied from interface:SubjectCredentialManagerDisable a credential by type.- Specified by:
disableCredentialTypein interfaceSubjectCredentialManager
-
getDisableableCredentialTypesStream
Description copied from interface:SubjectCredentialManagerList the credentials that can be disabled, for example, to show the list to the entity (aka user) or an admin.- Specified by:
getDisableableCredentialTypesStreamin interfaceSubjectCredentialManager- Returns:
- stream with credential types that can be disabled
-
isConfiguredFor
Description copied from interface:SubjectCredentialManagerCheck if the credential type is configured for this entity.- Specified by:
isConfiguredForin interfaceSubjectCredentialManager- Parameters:
type- credential type to check- Returns:
trueif the credential type has been
-
isConfiguredLocally
- Specified by:
isConfiguredLocallyin interfaceSubjectCredentialManager
-
getConfiguredUserStorageCredentialTypesStream
- Specified by:
getConfiguredUserStorageCredentialTypesStreamin interfaceSubjectCredentialManager
-
createCredentialThroughProvider
- Specified by:
createCredentialThroughProviderin interfaceSubjectCredentialManager
-
getFirstFactorCredentialsStream
Description copied from interface:SubjectCredentialManagerReturns a stream consisting of the first-factor credentials.- Specified by:
getFirstFactorCredentialsStreamin interfaceSubjectCredentialManager- Returns:
- a stream consisting of the first-factor credentials
-