org.keycloak.models

## Interface KeycloakSession

- All Known Implementing Classes:
    DefaultKeycloakSession

      public interface KeycloakSession

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default 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.
    `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)`
    `default <T> T` | `getAttributeOrDefault(String attribute, T defaultValue)`
    `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()`
    `KeyManager` | `keys()` Key manager
    `<T extends Provider> Set<String>` | `listProviderIds(Class<T> clazz)` Get all provider factories that manage provider instances of class.
    `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

- - ### Method Detail

    - #### getContext

          KeycloakContext getContext()

    - #### getTransactionManager

          KeycloakTransactionManager getTransactionManager()

    - #### getProvider

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

      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)
      Type Parameters:
        `T` -
      Parameters:
        `clazz` -
      Returns:

    - #### getProvider

          <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. If one hasn't been created yet, find the factory and allocate by calling ProviderFactory.create(KeycloakSession).
      Type Parameters:
        `T` -
      Parameters:
        `clazz` -
        `id` -
      Returns:

    - #### getProvider

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

    - #### listProviderIds

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

      Get all provider factories that manage provider instances of class.
      Type Parameters:
        `T` -
      Parameters:
        `clazz` -
      Returns:

    - #### getAllProviders

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

    - #### getProviderClass

          Class<? extends Provider> getProviderClass(String providerClassName)

    - #### getAttribute

          Object getAttribute(String attribute)

    - #### getAttribute

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

    - #### getAttributeOrDefault

          default <T> T getAttributeOrDefault(String attribute,
                                              T defaultValue)

    - #### removeAttribute

          Object removeAttribute(String attribute)

    - #### setAttribute

          void setAttribute(String name,
                            Object value)

    - #### enlistForClose

          void enlistForClose(Provider provider)

    - #### getKeycloakSessionFactory

          KeycloakSessionFactory getKeycloakSessionFactory()

    - #### realms

          RealmProvider realms()

      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Returns:
      Throws:
        `IllegalStateException` - if transaction is not active

    - #### clients

          ClientProvider clients()

      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Returns:
      Throws:
        `IllegalStateException` - if transaction is not active

    - #### groups

          GroupProvider groups()

      Returns a managed group provider instance.
      Returns:
        Currently used GroupProvider instance.
      Throws:
        `IllegalStateException` - if transaction is not active

    - #### roles

          RoleProvider roles()

      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Returns:
      Throws:
        `IllegalStateException` - if transaction is not active

    - #### sessions

          UserSessionProvider sessions()

      Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.
      Returns:
      Throws:
        `IllegalStateException` - if transaction is not active

    - #### authenticationSessions

          AuthenticationSessionProvider authenticationSessions()

    - #### close

          void close()

    - #### userCache

          UserCache userCache()

      The user cache
      Returns:
        may be null if cache is disabled

    - #### users

          UserProvider users()

      A cached view of all users in system including users loaded by UserStorageProviders
      Returns:

    - #### clientStorageManager

          ClientProvider clientStorageManager()

    - #### roleStorageManager

          RoleProvider roleStorageManager()

      Returns:
        RoleStorageManager instance

    - #### groupStorageManager

          GroupProvider groupStorageManager()

      Returns:
        GroupStorageManager instance

    - #### userStorageManager

          UserProvider userStorageManager()

      Un-cached view of all users in system including users loaded by UserStorageProviders
      Returns:

    - #### userCredentialManager

          UserCredentialManager userCredentialManager()

      Service that allows you to valid and update credentials for a user
      Returns:

    - #### userLocalStorage

          UserProvider userLocalStorage()

      Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak
      Returns:

    - #### realmLocalStorage

          RealmProvider realmLocalStorage()

    - #### clientLocalStorage

          ClientProvider clientLocalStorage()

      Keycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak
      Returns:

    - #### groupLocalStorage

          GroupProvider groupLocalStorage()

      Keycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak
      Returns:

    - #### roleLocalStorage

          RoleProvider roleLocalStorage()

      Keycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak
      Returns:

    - #### userFederatedStorage

          UserFederatedStorageProvider userFederatedStorage()

      Hybrid storage for UserStorageProviders that can't store a specific piece of keycloak data in their external storage. No cache in front.
      Returns:

    - #### keys

          KeyManager keys()

      Key manager
      Returns:

    - #### theme

          ThemeManager theme()

      Theme manager
      Returns:

    - #### tokens

          TokenManager tokens()

      Token manager
      Returns:

    - #### vault

          VaultTranscriber vault()

      Vault transcriber

    - #### clientPolicy

          ClientPolicyManager clientPolicy()

      Client Policy Manager

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