org.keycloak.credential

## Class PasswordCredentialProvider

- java.lang.Object
- - org.keycloak.credential.PasswordCredentialProvider

- All Implemented Interfaces:
    CredentialInputUpdater, CredentialInputUpdater.Streams, CredentialInputValidator, CredentialProvider<PasswordCredentialModel>, OnUserCache, Provider

      public class PasswordCredentialProvider
      extends Object
      implements CredentialProvider<PasswordCredentialModel>, CredentialInputUpdater.Streams, CredentialInputValidator, OnUserCache

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.keycloak.credential.CredentialInputUpdater

      `CredentialInputUpdater.Streams`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PASSWORD_CACHE_KEY`
    `protected KeycloakSession` | `session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PasswordCredentialProvider(KeycloakSession session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CredentialModel` | `createCredential(RealmModel realm, UserModel user, PasswordCredentialModel credentialModel)`
    `boolean` | `createCredential(RealmModel realm, UserModel user, String password)`
    `boolean` | `deleteCredential(RealmModel realm, UserModel user, String credentialId)`
    `void` | `disableCredentialType(RealmModel realm, UserModel user, String credentialType)`
    `PasswordCredentialModel` | `getCredentialFromModel(CredentialModel model)`
    `protected UserCredentialStore` | `getCredentialStore()`
    `CredentialTypeMetadata` | `getCredentialTypeMetadata(CredentialTypeMetadataContext metadataContext)`
    `Stream<String>` | `getDisableableCredentialTypesStream(RealmModel realm, UserModel user)` Obtains the set of credential types that can be disabled via `disableCredentialType`.
    `protected PasswordHashProvider` | `getHashProvider(PasswordPolicy policy)`
    `PasswordCredentialModel` | `getPassword(RealmModel realm, UserModel user)`
    `String` | `getType()`
    `boolean` | `isConfiguredFor(RealmModel realm, UserModel user, String credentialType)`
    `boolean` | `isValid(RealmModel realm, UserModel user, CredentialInput input)` Tests whether a credential is valid
    `void` | `onCache(RealmModel realm, CachedUserModel user, UserModel delegate)`
    `boolean` | `supportsCredentialType(String credentialType)`
    `boolean` | `updateCredential(RealmModel realm, UserModel user, CredentialInput input)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.credential.CredentialProvider

      `close, getDefaultCredential`

    - ### Methods inherited from interface org.keycloak.credential.CredentialInputUpdater.Streams

      `getDisableableCredentialTypes`

- - ### Field Detail

    - #### PASSWORD_CACHE_KEY

          public static final String PASSWORD_CACHE_KEY

    - #### session

          protected final KeycloakSession session

  - ### Constructor Detail

    - #### PasswordCredentialProvider

          public PasswordCredentialProvider(KeycloakSession session)

  - ### Method Detail

    - #### getCredentialStore

          protected UserCredentialStore getCredentialStore()

    - #### getPassword

          public PasswordCredentialModel getPassword(RealmModel realm,
                                                     UserModel user)

    - #### createCredential

          public boolean createCredential(RealmModel realm,
                                          UserModel user,
                                          String password)

    - #### createCredential

          public CredentialModel createCredential(RealmModel realm,
                                                  UserModel user,
                                                  PasswordCredentialModel credentialModel)

      Specified by:
        `createCredential` in interface `CredentialProvider<PasswordCredentialModel>`

    - #### deleteCredential

          public boolean deleteCredential(RealmModel realm,
                                          UserModel user,
                                          String credentialId)

      Specified by:
        `deleteCredential` in interface `CredentialProvider<PasswordCredentialModel>`

    - #### getCredentialFromModel

          public PasswordCredentialModel getCredentialFromModel(CredentialModel model)

      Specified by:
        `getCredentialFromModel` in interface `CredentialProvider<PasswordCredentialModel>`

    - #### getHashProvider

          protected PasswordHashProvider getHashProvider(PasswordPolicy policy)

    - #### supportsCredentialType

          public boolean supportsCredentialType(String credentialType)

      Specified by:
        `supportsCredentialType` in interface `CredentialInputUpdater`
      Specified by:
        `supportsCredentialType` in interface `CredentialInputValidator`

    - #### updateCredential

          public boolean updateCredential(RealmModel realm,
                                          UserModel user,
                                          CredentialInput input)

      Specified by:
        `updateCredential` in interface `CredentialInputUpdater`

    - #### disableCredentialType

          public void disableCredentialType(RealmModel realm,
                                            UserModel user,
                                            String credentialType)

      Specified by:
        `disableCredentialType` in interface `CredentialInputUpdater`

    - #### getDisableableCredentialTypesStream

          public Stream<String> getDisableableCredentialTypesStream(RealmModel realm,
                                                                    UserModel user)

      Description copied from interface: `CredentialInputUpdater`
      Obtains the set of credential types that can be disabled via `disableCredentialType`.
      Specified by:
        `getDisableableCredentialTypesStream` in interface `CredentialInputUpdater`
      Specified by:
        `getDisableableCredentialTypesStream` in interface `CredentialInputUpdater.Streams`
      Parameters:
        `realm` - a reference to the realm.
        `user` - the user whose credentials are being searched.
      Returns:
        a non-null `Stream` of credential types.

    - #### isConfiguredFor

          public boolean isConfiguredFor(RealmModel realm,
                                         UserModel user,
                                         String credentialType)

      Specified by:
        `isConfiguredFor` in interface `CredentialInputValidator`

    - #### isValid

          public boolean isValid(RealmModel realm,
                                 UserModel user,
                                 CredentialInput input)

      Description copied from interface: `CredentialInputValidator`
      Tests whether a credential is valid
      Specified by:
        `isValid` in interface `CredentialInputValidator`
      Parameters:
        `realm` - The realm in which to which the credential belongs to
        `user` - The user for which to test the credential
        `input` - the credential details to verify
      Returns:
        true if the passed secret is correct

    - #### onCache

          public void onCache(RealmModel realm,
                              CachedUserModel user,
                              UserModel delegate)

      Specified by:
        `onCache` in interface `OnUserCache`

    - #### getType

          public String getType()

      Specified by:
        `getType` in interface `CredentialProvider<PasswordCredentialModel>`

    - #### getCredentialTypeMetadata

          public CredentialTypeMetadata getCredentialTypeMetadata(CredentialTypeMetadataContext metadataContext)

      Specified by:
        `getCredentialTypeMetadata` in interface `CredentialProvider<PasswordCredentialModel>`

Copyright © 2021 JBoss by Red Hat. All rights reserved.