org.keycloak.models.jpa

## Class JpaUserCredentialStore

- java.lang.Object
- - org.keycloak.models.jpa.JpaUserCredentialStore

- All Implemented Interfaces:
    UserCredentialStore, UserCredentialStore.Streams, Provider

      public class JpaUserCredentialStore
      extends Object
      implements UserCredentialStore.Streams

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

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

      `UserCredentialStore.Streams`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.persistence.EntityManager` | `em`
    `protected static org.jboss.logging.Logger` | `logger`
    `static int` | `PRIORITY_DIFFERENCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JpaUserCredentialStore(KeycloakSession session, javax.persistence.EntityManager em)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `CredentialModel` | `createCredential(RealmModel realm, UserModel user, CredentialModel cred)`
    `CredentialModel` | `getStoredCredentialById(RealmModel realm, UserModel user, String id)`
    `CredentialModel` | `getStoredCredentialByNameAndType(RealmModel realm, UserModel user, String name, String type)`
    `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, UserModel user)` Obtains the stored credentials associated with the specified user.
    `boolean` | `moveCredentialTo(RealmModel realm, UserModel user, String id, String newPreviousCredentialId)`
    `boolean` | `removeStoredCredential(RealmModel realm, UserModel user, String id)`
    `void` | `updateCredential(RealmModel realm, UserModel user, CredentialModel cred)`

    - ### 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.UserCredentialStore.Streams

      `getStoredCredentials, getStoredCredentialsByType`

- - ### Field Detail

    - #### PRIORITY_DIFFERENCE

          public static final int PRIORITY_DIFFERENCE

      See Also:
        Constant Field Values

    - #### logger

          protected static final org.jboss.logging.Logger logger

    - #### em

          protected final javax.persistence.EntityManager em

  - ### Constructor Detail

    - #### JpaUserCredentialStore

          public JpaUserCredentialStore(KeycloakSession session,
                                        javax.persistence.EntityManager em)

  - ### Method Detail

    - #### updateCredential

          public void updateCredential(RealmModel realm,
                                       UserModel user,
                                       CredentialModel cred)

      Specified by:
        `updateCredential` in interface `UserCredentialStore`

    - #### createCredential

          public CredentialModel createCredential(RealmModel realm,
                                                  UserModel user,
                                                  CredentialModel cred)

      Specified by:
        `createCredential` in interface `UserCredentialStore`

    - #### removeStoredCredential

          public boolean removeStoredCredential(RealmModel realm,
                                                UserModel user,
                                                String id)

      Specified by:
        `removeStoredCredential` in interface `UserCredentialStore`

    - #### getStoredCredentialById

          public CredentialModel getStoredCredentialById(RealmModel realm,
                                                         UserModel user,
                                                         String id)

      Specified by:
        `getStoredCredentialById` in interface `UserCredentialStore`

    - #### getStoredCredentialsStream

          public Stream<CredentialModel> getStoredCredentialsStream(RealmModel realm,
                                                                    UserModel user)

      Description copied from interface: `UserCredentialStore`
      Obtains the stored credentials associated with the specified user.
      Specified by:
        `getStoredCredentialsStream` in interface `UserCredentialStore`
      Specified by:
        `getStoredCredentialsStream` in interface `UserCredentialStore.Streams`
      Parameters:
        `realm` - a reference to the realm.
        `user` - the user whose credentials are being searched.
      Returns:
        a non-null `Stream` of credentials.

    - #### getStoredCredentialsByTypeStream

          public Stream<CredentialModel> getStoredCredentialsByTypeStream(RealmModel realm,
                                                                          UserModel user,
                                                                          String type)

      Description copied from interface: `UserCredentialStore`
      Obtains the stored credentials associated with the specified user that match the specified type.
      Specified by:
        `getStoredCredentialsByTypeStream` in interface `UserCredentialStore`
      Specified by:
        `getStoredCredentialsByTypeStream` in interface `UserCredentialStore.Streams`
      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 `Stream` of credentials.

    - #### getStoredCredentialByNameAndType

          public CredentialModel getStoredCredentialByNameAndType(RealmModel realm,
                                                                  UserModel user,
                                                                  String name,
                                                                  String type)

      Specified by:
        `getStoredCredentialByNameAndType` in interface `UserCredentialStore`

    - #### close

          public void close()

      Specified by:
        `close` in interface `Provider`

    - #### moveCredentialTo

          public boolean moveCredentialTo(RealmModel realm,
                                          UserModel user,
                                          String id,
                                          String newPreviousCredentialId)

      Specified by:
        `moveCredentialTo` in interface `UserCredentialStore`

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