org.keycloak.services

## Class DefaultKeycloakSession

- java.lang.Object
- - org.keycloak.services.DefaultKeycloakSession

- All Implemented Interfaces:
    KeycloakSession, InvalidationHandler

      public class DefaultKeycloakSession
      extends Object
      implements KeycloakSession

  Author:
    Stian Thorgersen

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.keycloak.provider.InvalidationHandler

      `InvalidationHandler.InvalidableObjectType, InvalidationHandler.ObjectType`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultKeycloakSession(DefaultKeycloakSessionFactory factory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AuthenticationSessionProvider` | `authenticationSessions()`
    `ClientProvider` | `clientLocalStorage()` Keycloak specific local storage for clients.
    `ClientPolicyManager` | `clientPolicy()` Client Policy Manager
    `ClientProvider` | `clients()` Returns a managed provider instance.
    `ClientScopeProvider` | `clientScopeLocalStorage()` Keycloak specific local storage for client scopes.
    `ClientScopeProvider` | `clientScopes()` Returns a managed provider instance.
    `ClientScopeProvider` | `clientScopeStorageManager()`
    `ClientProvider` | `clientStorageManager()`
    `void` | `close()`
    `void` | `enlistForClose(Provider provider)`
    `<T extends Provider> Set<T>` | `getAllProviders(Class<T> clazz)`
    `Object` | `getAttribute(String attribute)`
    `<T> T` | `getAttribute(String attribute, Class<T> clazz)`
    `<T extends Provider> T` | `getComponentProvider(Class<T> clazz, String componentId)` Returns a component provider for a component from the realm that is relevant to this session.
    `KeycloakContext` | `getContext()`
    `KeycloakSessionFactory` | `getKeycloakSessionFactory()`
    `<T extends Provider> T` | `getProvider(Class<T> clazz)` Get dedicated provider instance of provider type clazz that was created for this session.
    `<T extends Provider> T` | `getProvider(Class<T> clazz, ComponentModel componentModel)`
    `<T extends Provider> T` | `getProvider(Class<T> clazz, String id)` Get dedicated provider instance for a specific provider factory of id of provider type clazz that was created for this session.
    `Class<? extends Provider>` | `getProviderClass(String providerClassName)`
    `KeycloakTransactionManager` | `getTransactionManager()`
    `GroupProvider` | `groupLocalStorage()` Keycloak specific local storage for groups.
    `GroupProvider` | `groups()` Returns a managed group provider instance.
    `GroupProvider` | `groupStorageManager()`
    `void` | `invalidate(InvalidationHandler.InvalidableObjectType type, Object... ids)` Invalidates intermediate states of the given objects, both immediately and at the end of this session.
    `KeyManager` | `keys()` Key manager
    `<T extends Provider> Set<String>` | `listProviderIds(Class<T> clazz)` Get all provider factories that manage provider instances of class.
    `UserLoginFailureProvider` | `loginFailures()` Returns a managed provider instance.
    `RealmProvider` | `realmLocalStorage()`
    `RealmProvider` | `realms()` Returns a managed provider instance.
    `Object` | `removeAttribute(String attribute)`
    `RoleProvider` | `roleLocalStorage()` Keycloak specific local storage for roles.
    `RoleProvider` | `roles()` Returns a managed provider instance.
    `RoleProvider` | `roleStorageManager()`
    `UserSessionProvider` | `sessions()` Returns a managed provider instance.
    `void` | `setAttribute(String name, Object value)`
    `ThemeManager` | `theme()` Theme manager
    `TokenManager` | `tokens()` Token manager
    `UserCache` | `userCache()` The user cache
    `UserCredentialManager` | `userCredentialManager()` Service that allows you to valid and update credentials for a user
    `UserFederatedStorageProvider` | `userFederatedStorage()` Hybrid storage for UserStorageProviders that can't store a specific piece of keycloak data in their external storage.
    `UserProvider` | `userLocalStorage()` Keycloak specific local storage for users.
    `UserProvider` | `users()` A cached view of all users in system including users loaded by UserStorageProviders
    `UserProvider` | `userStorageManager()` Un-cached view of all users in system including users loaded by UserStorageProviders
    `VaultTranscriber` | `vault()` Vault transcriber

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

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

    - ### Methods inherited from interface org.keycloak.models.KeycloakSession

      `getAttributeOrDefault`

- - ### Constructor Detail

    - #### DefaultKeycloakSession

          public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory)

  - ### Method Detail

    - #### getContext

          public KeycloakContext getContext()

      Specified by:
        `getContext` in interface `KeycloakSession`

    - #### userCache

          public UserCache userCache()

      Description copied from interface: `KeycloakSession`
      The user cache
      Specified by:
        `userCache` in interface `KeycloakSession`
      Returns:
        may be null if cache is disabled

    - #### invalidate

          public void invalidate(InvalidationHandler.InvalidableObjectType type,
                                 Object... ids)

      Description copied from interface: `KeycloakSession`
      Invalidates intermediate states of the given objects, both immediately and at the end of this session.
      Specified by:
        `invalidate` in interface `KeycloakSession`
      Specified by:
        `invalidate` in interface `InvalidationHandler`
      Parameters:
        `type` - Type of the objects to invalidate
        `ids` - Identifiers of the invalidated objects

    - #### enlistForClose

          public void enlistForClose(Provider provider)

      Specified by:
        `enlistForClose` in interface `KeycloakSession`

    - #### getAttribute

          public Object getAttribute(String attribute)

      Specified by:
        `getAttribute` in interface `KeycloakSession`

    - #### getAttribute

          public <T> T getAttribute(String attribute,
                                    Class<T> clazz)

      Specified by:
        `getAttribute` in interface `KeycloakSession`

    - #### removeAttribute

          public Object removeAttribute(String attribute)

      Specified by:
        `removeAttribute` in interface `KeycloakSession`

    - #### setAttribute

          public void setAttribute(String name,
                                   Object value)

      Specified by:
        `setAttribute` in interface `KeycloakSession`

    - #### getTransactionManager

          public KeycloakTransactionManager getTransactionManager()

      Specified by:
        `getTransactionManager` in interface `KeycloakSession`

    - #### getKeycloakSessionFactory

          public KeycloakSessionFactory getKeycloakSessionFactory()

      Specified by:
        `getKeycloakSessionFactory` in interface `KeycloakSession`

    - #### userFederatedStorage

          public UserFederatedStorageProvider userFederatedStorage()

      Description copied from interface: `KeycloakSession`
      Hybrid storage for UserStorageProviders that can't store a specific piece of keycloak data in their external storage. No cache in front.
      Specified by:
        `userFederatedStorage` in interface `KeycloakSession`
      Returns:

    - #### userLocalStorage

          public UserProvider userLocalStorage()

      Description copied from interface: `KeycloakSession`
      Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak
      Specified by:
        `userLocalStorage` in interface `KeycloakSession`
      Returns:

    - #### realmLocalStorage

          public RealmProvider realmLocalStorage()

      Specified by:
        `realmLocalStorage` in interface `KeycloakSession`

    - #### clientLocalStorage

          public ClientProvider clientLocalStorage()

      Description copied from interface: `KeycloakSession`
      Keycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak
      Specified by:
        `clientLocalStorage` in interface `KeycloakSession`
      Returns:

    - #### clientScopeLocalStorage

          public ClientScopeProvider clientScopeLocalStorage()

      Description copied from interface: `KeycloakSession`
      Keycloak specific local storage for client scopes. No cache in front, this api talks directly to database configured for Keycloak
      Specified by:
        `clientScopeLocalStorage` in interface `KeycloakSession`
      Returns:

    - #### groupLocalStorage

          public GroupProvider groupLocalStorage()

      Description copied from interface: `KeycloakSession`
      Keycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak
      Specified by:
        `groupLocalStorage` in interface `KeycloakSession`
      Returns:

    - #### clientStorageManager

          public ClientProvider clientStorageManager()

      Specified by:
        `clientStorageManager` in interface `KeycloakSession`
      Returns:
        ClientStorageManager instance

    - #### clientScopeStorageManager

          public ClientScopeProvider clientScopeStorageManager()

      Specified by:
        `clientScopeStorageManager` in interface `KeycloakSession`
      Returns:
        ClientScopeStorageManager instance

    - #### roleLocalStorage

          public RoleProvider roleLocalStorage()

      Description copied from interface: `KeycloakSession`
      Keycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak
      Specified by:
        `roleLocalStorage` in interface `KeycloakSession`
      Returns:

    - #### roleStorageManager

          public RoleProvider roleStorageManager()

      Specified by:
        `roleStorageManager` in interface `KeycloakSession`
      Returns:
        RoleStorageManager instance

    - #### groupStorageManager

          public GroupProvider groupStorageManager()

      Specified by:
        `groupStorageManager` in interface `KeycloakSession`
      Returns:
        GroupStorageManager instance

    - #### userStorageManager

          public UserProvider userStorageManager()

      Description copied from interface: `KeycloakSession`
      Un-cached view of all users in system including users loaded by UserStorageProviders
      Specified by:
        `userStorageManager` in interface `KeycloakSession`
      Returns:

    - #### users

          public UserProvider users()

      Description copied from interface: `KeycloakSession`
      A cached view of all users in system including users loaded by UserStorageProviders
      Specified by:
        `users` in interface `KeycloakSession`
      Returns:

    - #### userCredentialManager

          public UserCredentialManager userCredentialManager()

      Description copied from interface: `KeycloakSession`
      Service that allows you to valid and update credentials for a user
      Specified by:
        `userCredentialManager` in interface `KeycloakSession`
      Returns:

    - #### getProvider

          public <T extends Provider> T getProvider(Class<T> clazz)

      Description copied from interface: `KeycloakSession`
      Get dedicated provider instance of provider type clazz that was created for this session. If one hasn't been created yet, find the factory and allocate by calling ProviderFactory.create(KeycloakSession). The provider to use is determined by the "provider" config entry in keycloak-server boot configuration. (keycloak-server.json)
      Specified by:
        `getProvider` in interface `KeycloakSession`
      Returns:

    - #### getProvider

          public <T extends Provider> T getProvider(Class<T> clazz,
                                                    String id)

      Description copied from interface: `KeycloakSession`
      Get dedicated provider instance for a specific provider factory of id of provider type clazz that was created for this session. If one hasn't been created yet, find the factory and allocate by calling ProviderFactory.create(KeycloakSession).
      Specified by:
        `getProvider` in interface `KeycloakSession`
      Returns:

    - #### getComponentProvider

          public <T extends Provider> T getComponentProvider(Class<T> clazz,
                                                             String componentId)

      Description copied from interface: `KeycloakSession`
      Returns a component provider for a component from the realm that is relevant to this session. The relevant realm must be set prior to calling this method in the context, see `KeycloakContext.getRealm()`.
      Specified by:
        `getComponentProvider` in interface `KeycloakSession`
        `componentId` - Component configuration
      Returns:
        Provider configured according to the `componentId`, `null` if it cannot be instantiated.

    - #### getProvider

          public <T extends Provider> T getProvider(Class<T> clazz,
                                                    ComponentModel componentModel)

      Specified by:
        `getProvider` in interface `KeycloakSession`
      Returns:

    - #### listProviderIds

          public <T extends Provider> Set<String> listProviderIds(Class<T> clazz)

      Description copied from interface: `KeycloakSession`
      Get all provider factories that manage provider instances of class.
      Specified by:
        `listProviderIds` in interface `KeycloakSession`
      Returns:

    - #### getAllProviders

          public <T extends Provider> Set<T> getAllProviders(Class<T> clazz)

      Specified by:
        `getAllProviders` in interface `KeycloakSession`

    - #### getProviderClass

          public Class<? extends Provider> getProviderClass(String providerClassName)

      Specified by:
        `getProviderClass` in interface `KeycloakSession`

    - #### realms

          public RealmProvider realms()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `realms` in interface `KeycloakSession`
      Returns:

    - #### clients

          public ClientProvider clients()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `clients` in interface `KeycloakSession`
      Returns:

    - #### clientScopes

          public ClientScopeProvider clientScopes()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `clientScopes` in interface `KeycloakSession`
      Returns:
        Currently used ClientScopeProvider instance.

    - #### groups

          public GroupProvider groups()

      Description copied from interface: `KeycloakSession`
      Returns a managed group provider instance.
      Specified by:
        `groups` in interface `KeycloakSession`
      Returns:
        Currently used GroupProvider instance.

    - #### roles

          public RoleProvider roles()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `roles` in interface `KeycloakSession`
      Returns:

    - #### sessions

          public UserSessionProvider sessions()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `sessions` in interface `KeycloakSession`
      Returns:

    - #### loginFailures

          public UserLoginFailureProvider loginFailures()

      Description copied from interface: `KeycloakSession`
      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Specified by:
        `loginFailures` in interface `KeycloakSession`
      Returns:
        `UserLoginFailureProvider`

    - #### authenticationSessions

          public AuthenticationSessionProvider authenticationSessions()

      Specified by:
        `authenticationSessions` in interface `KeycloakSession`

    - #### keys

          public KeyManager keys()

      Description copied from interface: `KeycloakSession`
      Key manager
      Specified by:
        `keys` in interface `KeycloakSession`
      Returns:

    - #### theme

          public ThemeManager theme()

      Description copied from interface: `KeycloakSession`
      Theme manager
      Specified by:
        `theme` in interface `KeycloakSession`
      Returns:

    - #### tokens

          public TokenManager tokens()

      Description copied from interface: `KeycloakSession`
      Token manager
      Specified by:
        `tokens` in interface `KeycloakSession`
      Returns:

    - #### vault

          public VaultTranscriber vault()

      Description copied from interface: `KeycloakSession`
      Vault transcriber
      Specified by:
        `vault` in interface `KeycloakSession`

    - #### clientPolicy

          public ClientPolicyManager clientPolicy()

      Description copied from interface: `KeycloakSession`
      Client Policy Manager
      Specified by:
        `clientPolicy` in interface `KeycloakSession`

    - #### close

          public void close()

      Specified by:
        `close` in interface `KeycloakSession`

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