Package org.keycloak.models
Interface SubjectCredentialManager
- All Known Subinterfaces:
UserCredentialManager
- All Known Implementing Classes:
SubjectCredentialManagerCacheAdapter,UserCredentialManager
public interface SubjectCredentialManager
Validates and manages the credentials of a known entity (for example, a user).
NOTE: This class might be renamed to
UserCredentialManager in Keycloak 27. Please use the UserCredentialManager
already if you can-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Updates a credential of the entity with an updatedCredentialModel.voiddisableCredentialType(String credentialType) Disable a credential by type.Deprecated.default Stream<CredentialModel>Returns a stream consisting of both local and federated credentials.List the credentials that can be disabled, for example, to show the list to the entity (aka user) or an admin.default Stream<CredentialModel>Returns a stream consisting of the federated credentials.default Stream<CredentialModel>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) Deprecated.booleanisValid(List<CredentialInput> inputs) Validate a list of credentials.default booleanisValid(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.default Optional<CredentialModel>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 credentialLabel) 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.
-
Method Details
-
isValid
Validate a list of credentials.- Returns:
trueif inputs are valid
-
isValid
Validate a list of credentials.- Returns:
trueif inputs are valid
-
updateCredential
Updates a credential of the entity with the inputs provided by the entity.- Returns:
trueif credentials have been updated successfully
-
updateCredentialAndGet
Updates 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.
- 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
Updates a credential of the entity with an updatedCredentialModel. Usually called by aCredentialProvider. -
updateStoredCredential
Replaces 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.
- 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
Updates a credential of the entity with an updatedCredentialModel. Usually called by aCredentialProvider. -
removeStoredCredentialById
Updates 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. -
getStoredCredentialById
Read a stored credential. -
getStoredCredentialsStream
Stream<CredentialModel> getStoredCredentialsStream()Read stored credentials as a stream. -
getFederatedCredentialsStream
Returns a stream consisting of the federated credentials.- Returns:
- a stream consisting of the federated credentials
-
getCredentials
Returns a stream consisting of both local and federated credentials.- Returns:
- a stream of both local and federated credentials
-
getStoredCredentialsByTypeStream
Read stored credentials by type as a stream. -
getStoredCredentialByNameAndType
-
moveStoredCredentialTo
Re-order the stored credentials. -
updateCredentialLabel
Update the label for a stored credentials chosen by the owner of the entity. -
disableCredentialType
Disable a credential by type. -
getDisableableCredentialTypesStream
List the credentials that can be disabled, for example, to show the list to the entity (aka user) or an admin.- Returns:
- stream with credential types that can be disabled
-
getFirstFactorCredentialsStream
Returns a stream consisting of the first-factor credentials.- Returns:
- a stream consisting of the first-factor credentials
-
isConfiguredFor
Check if the credential type is configured for this entity.- Parameters:
type- credential type to check- Returns:
trueif the credential type has been
-
isConfiguredLocally
Deprecated. -
getConfiguredUserStorageCredentialTypesStream
Deprecated. -
createCredentialThroughProvider
Deprecated.
-