Package org.keycloak.services
Class DefaultKeycloakSession
- java.lang.Object
- 
- org.keycloak.services.DefaultKeycloakSession
 
- 
- All Implemented Interfaces:
- AutoCloseable,- KeycloakSession
 
 public class DefaultKeycloakSession extends Object implements KeycloakSession - Author:
- Stian Thorgersen
 
- 
- 
Constructor SummaryConstructors Constructor Description DefaultKeycloakSession(DefaultKeycloakSessionFactory factory)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AuthenticationSessionProviderauthenticationSessions()ClientProviderclientLocalStorage()Deprecated.ClientPolicyManagerclientPolicy()Client Policy ManagerClientProviderclients()Returns a managed provider instance.ClientScopeProviderclientScopeLocalStorage()Deprecated.ClientScopeProviderclientScopes()Returns a managed provider instance.ClientScopeProviderclientScopeStorageManager()Deprecated.ClientProviderclientStorageManager()Deprecated.voidclose()protected RuntimeExceptioncloseTransactionManager()protected DefaultKeycloakContextcreateKeycloakContext(KeycloakSession session)voidenlistForClose(Provider provider)<T extends Provider>
 Set<T>getAllProviders(Class<T> clazz)ObjectgetAttribute(String attribute)<T> TgetAttribute(String attribute, Class<T> clazz)Map<String,Object>getAttributes()<T extends Provider>
 TgetComponentProvider(Class<T> clazz, String componentId)Returns a component provider for a component from the realm that is relevant to this session.<T extends Provider>
 TgetComponentProvider(Class<T> clazz, String componentId, Function<KeycloakSessionFactory,ComponentModel> modelGetter)Returns a component provider for a component from the realm that is relevant to this session.KeycloakContextgetContext()KeycloakSessionFactorygetKeycloakSessionFactory()<T extends Provider>
 TgetProvider(Class<T> clazz)Get dedicated provider instance of provider type clazz that was created for this session.<T extends Provider>
 TgetProvider(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.<T extends Provider>
 TgetProvider(Class<T> clazz, ComponentModel componentModel)Class<? extends Provider>getProviderClass(String providerClassName)KeycloakTransactionManagergetTransactionManager()GroupProvidergroupLocalStorage()Deprecated.GroupProvidergroups()Returns a managed group provider instance.GroupProvidergroupStorageManager()Deprecated.voidinvalidate(InvalidationHandler.InvalidableObjectType type, Object... ids)Invalidates intermediate states of the given objects, both immediately and at the end of this session.booleanisClosed()KeyManagerkeys()Key manager<T extends Provider>
 Set<String>listProviderIds(Class<T> clazz)Get all provider factories that manage provider instances of class.UserLoginFailureProviderloginFailures()Returns a managed provider instance.RealmProviderrealmLocalStorage()Deprecated.RealmProviderrealms()Returns a managed provider instance.ObjectremoveAttribute(String attribute)RoleProviderroleLocalStorage()Deprecated.RoleProviderroles()Returns a managed provider instance.RoleProviderroleStorageManager()Deprecated.UserSessionProvidersessions()Returns a managed provider instance.voidsetAttribute(String name, Object value)ThemeManagertheme()Theme managerTokenManagertokens()Token managerStringtoString()UserProvideruserCache()Deprecated.UserCredentialManageruserCredentialManager()Deprecated.UserProvideruserLocalStorage()Deprecated.UserProviderusers()A cached view of all users in system including users loaded by UserStorageProvidersUserProvideruserStorageManager()Deprecated.VaultTranscribervault()Vault transcriber- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.models.KeycloakSessiongetAttributeOrDefault
 
- 
 
- 
- 
- 
Constructor Detail- 
DefaultKeycloakSessionpublic DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) 
 
- 
 - 
Method Detail- 
getContextpublic KeycloakContext getContext() - Specified by:
- getContextin interface- KeycloakSession
 
 - 
userCache@Deprecated public UserProvider userCache() Deprecated.Description copied from interface:KeycloakSessionThe user cache- Specified by:
- userCachein interface- KeycloakSession
- Returns:
- may be null if cache is disabled
 
 - 
invalidatepublic void invalidate(InvalidationHandler.InvalidableObjectType type, Object... ids) Description copied from interface:KeycloakSessionInvalidates intermediate states of the given objects, both immediately and at the end of this session.- Specified by:
- invalidatein interface- KeycloakSession
- Parameters:
- type- Type of the objects to invalidate
- ids- Parameters used for the invalidation
 
 - 
enlistForClosepublic void enlistForClose(Provider provider) - Specified by:
- enlistForClosein interface- KeycloakSession
 
 - 
getAttributepublic Object getAttribute(String attribute) - Specified by:
- getAttributein interface- KeycloakSession
 
 - 
getAttributepublic <T> T getAttribute(String attribute, Class<T> clazz) - Specified by:
- getAttributein interface- KeycloakSession
 
 - 
removeAttributepublic Object removeAttribute(String attribute) - Specified by:
- removeAttributein interface- KeycloakSession
 
 - 
setAttributepublic void setAttribute(String name, Object value) - Specified by:
- setAttributein interface- KeycloakSession
 
 - 
getAttributespublic Map<String,Object> getAttributes() - Specified by:
- getAttributesin interface- KeycloakSession
 
 - 
getTransactionManagerpublic KeycloakTransactionManager getTransactionManager() - Specified by:
- getTransactionManagerin interface- KeycloakSession
 
 - 
getKeycloakSessionFactorypublic KeycloakSessionFactory getKeycloakSessionFactory() - Specified by:
- getKeycloakSessionFactoryin interface- KeycloakSession
 
 - 
userLocalStorage@Deprecated public UserProvider userLocalStorage() Deprecated.Description copied from interface:KeycloakSessionKeycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
- userLocalStoragein interface- KeycloakSession
 
 - 
realmLocalStorage@Deprecated public RealmProvider realmLocalStorage() Deprecated.- Specified by:
- realmLocalStoragein interface- KeycloakSession
 
 - 
clientLocalStorage@Deprecated public ClientProvider clientLocalStorage() Deprecated.Description copied from interface:KeycloakSessionKeycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
- clientLocalStoragein interface- KeycloakSession
 
 - 
clientScopeLocalStorage@Deprecated public ClientScopeProvider clientScopeLocalStorage() Deprecated.Description copied from interface:KeycloakSessionKeycloak specific local storage for client scopes. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
- clientScopeLocalStoragein interface- KeycloakSession
 
 - 
groupLocalStorage@Deprecated public GroupProvider groupLocalStorage() Deprecated.Description copied from interface:KeycloakSessionKeycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak- Specified by:
- groupLocalStoragein interface- KeycloakSession
 
 - 
clientStorageManager@Deprecated public ClientProvider clientStorageManager() Deprecated.- Specified by:
- clientStorageManagerin interface- KeycloakSession
- Returns:
- ClientStorageManager instance
 
 - 
clientScopeStorageManager@Deprecated public ClientScopeProvider clientScopeStorageManager() Deprecated.- Specified by:
- clientScopeStorageManagerin interface- KeycloakSession
- Returns:
- ClientScopeStorageManager instance
 
 - 
roleLocalStorage@Deprecated public RoleProvider roleLocalStorage() Deprecated.Description copied from interface:KeycloakSessionKeycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak- Specified by:
- roleLocalStoragein interface- KeycloakSession
 
 - 
roleStorageManager@Deprecated public RoleProvider roleStorageManager() Deprecated.- Specified by:
- roleStorageManagerin interface- KeycloakSession
- Returns:
- RoleStorageManager instance
 
 - 
groupStorageManager@Deprecated public GroupProvider groupStorageManager() Deprecated.- Specified by:
- groupStorageManagerin interface- KeycloakSession
- Returns:
- GroupStorageManager instance
 
 - 
userStorageManager@Deprecated public UserProvider userStorageManager() Deprecated.Description copied from interface:KeycloakSessionUn-cached view of all users in system including users loaded by UserStorageProviders- Specified by:
- userStorageManagerin interface- KeycloakSession
- Returns:
 
 - 
userspublic UserProvider users() Description copied from interface:KeycloakSessionA cached view of all users in system including users loaded by UserStorageProviders- Specified by:
- usersin interface- KeycloakSession
- Returns:
- UserProvider instance
 
 - 
userCredentialManager@Deprecated public UserCredentialManager userCredentialManager() Deprecated.Description copied from interface:KeycloakSessionService that allows you to valid and update credentials for a user- Specified by:
- userCredentialManagerin interface- KeycloakSession
- Returns:
 
 - 
getProviderpublic <T extends Provider> T getProvider(Class<T> clazz) Description copied from interface:KeycloakSessionGet 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:
- getProviderin interface- KeycloakSession
- Returns:
 
 - 
getProviderpublic <T extends Provider> T getProvider(Class<T> clazz, String id) Description copied from interface:KeycloakSessionGet 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:
- getProviderin interface- KeycloakSession
- Returns:
 
 - 
getComponentProviderpublic <T extends Provider> T getComponentProvider(Class<T> clazz, String componentId) Description copied from interface:KeycloakSessionReturns 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, seeKeycloakContext.getRealm().- Specified by:
- getComponentProviderin interface- KeycloakSession
- componentId- Component configuration
- Returns:
- Provider configured according to the {@param componentId}, nullif it cannot be instantiated.
 
 - 
getComponentProviderpublic <T extends Provider> T getComponentProvider(Class<T> clazz, String componentId, Function<KeycloakSessionFactory,ComponentModel> modelGetter) Description copied from interface:KeycloakSessionReturns 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, seeKeycloakContext.getRealm().- Specified by:
- getComponentProviderin interface- KeycloakSession
- componentId- Component configuration
- modelGetter- Getter to retrieve componentModel
- Returns:
- Provider configured according to the {@param componentId}, nullif it cannot be instantiated.
 
 - 
getProviderpublic <T extends Provider> T getProvider(Class<T> clazz, ComponentModel componentModel) - Specified by:
- getProviderin interface- KeycloakSession
- Returns:
 
 - 
listProviderIdspublic <T extends Provider> Set<String> listProviderIds(Class<T> clazz) Description copied from interface:KeycloakSessionGet all provider factories that manage provider instances of class.- Specified by:
- listProviderIdsin interface- KeycloakSession
- Returns:
 
 - 
getAllProviderspublic <T extends Provider> Set<T> getAllProviders(Class<T> clazz) - Specified by:
- getAllProvidersin interface- KeycloakSession
 
 - 
getProviderClasspublic Class<? extends Provider> getProviderClass(String providerClassName) - Specified by:
- getProviderClassin interface- KeycloakSession
 
 - 
realmspublic RealmProvider realms() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- realmsin interface- KeycloakSession
- Returns:
 
 - 
clientspublic ClientProvider clients() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- clientsin interface- KeycloakSession
- Returns:
 
 - 
clientScopespublic ClientScopeProvider clientScopes() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- clientScopesin interface- KeycloakSession
- Returns:
- Currently used ClientScopeProvider instance.
 
 - 
groupspublic GroupProvider groups() Description copied from interface:KeycloakSessionReturns a managed group provider instance.- Specified by:
- groupsin interface- KeycloakSession
- Returns:
- Currently used GroupProvider instance.
 
 - 
rolespublic RoleProvider roles() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- rolesin interface- KeycloakSession
- Returns:
 
 - 
sessionspublic UserSessionProvider sessions() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- sessionsin interface- KeycloakSession
- Returns:
 
 - 
loginFailurespublic UserLoginFailureProvider loginFailures() Description copied from interface:KeycloakSessionReturns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
- loginFailuresin interface- KeycloakSession
- Returns:
- UserLoginFailureProvider
 
 - 
authenticationSessionspublic AuthenticationSessionProvider authenticationSessions() - Specified by:
- authenticationSessionsin interface- KeycloakSession
 
 - 
keyspublic KeyManager keys() Description copied from interface:KeycloakSessionKey manager- Specified by:
- keysin interface- KeycloakSession
- Returns:
 
 - 
themepublic ThemeManager theme() Description copied from interface:KeycloakSessionTheme manager- Specified by:
- themein interface- KeycloakSession
- Returns:
 
 - 
tokenspublic TokenManager tokens() Description copied from interface:KeycloakSessionToken manager- Specified by:
- tokensin interface- KeycloakSession
- Returns:
 
 - 
vaultpublic VaultTranscriber vault() Description copied from interface:KeycloakSessionVault transcriber- Specified by:
- vaultin interface- KeycloakSession
 
 - 
clientPolicypublic ClientPolicyManager clientPolicy() Description copied from interface:KeycloakSessionClient Policy Manager- Specified by:
- clientPolicyin interface- KeycloakSession
 
 - 
closepublic void close() - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- KeycloakSession
 
 - 
closeTransactionManagerprotected RuntimeException closeTransactionManager() 
 - 
createKeycloakContextprotected DefaultKeycloakContext createKeycloakContext(KeycloakSession session) 
 - 
isClosedpublic boolean isClosed() 
 
- 
 
-