Package org.keycloak.models
Interface KeycloakSession
- All Superinterfaces:
- AutoCloseable
- All Known Implementing Classes:
- DefaultKeycloakSession
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
- 
Method SummaryModifier and TypeMethodDescriptionClient Policy Managerclients()Returns a managed provider instance.Returns a managed provider instance.voidclose()voidenlistForClose(Provider provider) getAllProviders(Class<T> clazz) getAttribute(String attribute) <T> TgetAttribute(String attribute, Class<T> clazz) default <T> TgetAttributeOrDefault(String attribute, T defaultValue) <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.<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) Deprecated.Deprecated in favor of {@link #getComponentProvider)getProviderClass(String providerClassName) groups()Returns a managed group provider instance.voidinvalidate(InvalidationHandler.InvalidableObjectType type, Object... params) Invalidates intermediate states of the given objects, both immediately and at the end of this session.keys()Key managerlistProviderIds(Class<T> clazz) Get all provider factories that manage provider instances of class.Returns a managed provider instance.realms()Returns a managed provider instance.removeAttribute(String attribute) roles()Returns a managed provider instance.sessions()Returns a managed provider instance.voidsetAttribute(String name, Object value) theme()Theme managertokens()Token managerusers()A cached view of all users in system including users loaded by UserStorageProvidersvault()Vault transcriber
- 
Method Details- 
getContextKeycloakContext getContext()
- 
getTransactionManagerKeycloakTransactionManager getTransactionManager()
- 
getProviderGet 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:
 
- 
getProviderGet 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:
 
- 
getComponentProviderReturns 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().- Type Parameters:
- T-
- Parameters:
- clazz-
- componentId- Component configuration
- Returns:
- Provider configured according to the , nullif it cannot be instantiated.
- Throws:
- IllegalArgumentException- If the realm is not set in the context.
 
- 
getComponentProvider<T extends Provider> T getComponentProvider(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. The relevant realm must be set prior to calling this method in the context, seeKeycloakContext.getRealm().- Type Parameters:
- T-
- Parameters:
- clazz-
- componentId- Component configuration
- modelGetter- Getter to retrieve componentModel
- Returns:
- Provider configured according to the , nullif it cannot be instantiated.
- Throws:
- IllegalArgumentException- If the realm is not set in the context.
 
- 
getProviderDeprecated.Deprecated in favor of {@link #getComponentProvider)- Type Parameters:
- T-
- Parameters:
- clazz-
- componentModel-
- Returns:
 
- 
listProviderIdsGet all provider factories that manage provider instances of class.- Type Parameters:
- T-
- Parameters:
- clazz-
- Returns:
 
- 
getAllProviders
- 
getProviderClass
- 
getAttribute
- 
getAttribute
- 
getAttributeOrDefault
- 
removeAttribute
- 
setAttribute
- 
getAttributes
- 
invalidateInvalidates intermediate states of the given objects, both immediately and at the end of this session.- Parameters:
- type- Type of the objects to invalidate
- params- Parameters used for the invalidation
 
- 
enlistForClose
- 
getKeycloakSessionFactoryKeycloakSessionFactory getKeycloakSessionFactory()
- 
realmsRealmProvider 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
 
- 
clientsClientProvider 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
 
- 
clientScopesClientScopeProvider clientScopes()Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Returns:
- Currently used ClientScopeProvider instance.
- Throws:
- IllegalStateException- if transaction is not active
 
- 
groupsGroupProvider groups()Returns a managed group provider instance.- Returns:
- Currently used GroupProvider instance.
- Throws:
- IllegalStateException- if transaction is not active
 
- 
rolesRoleProvider 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
 
- 
sessionsUserSessionProvider 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
 
- 
loginFailuresUserLoginFailureProvider loginFailures()Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Returns:
- UserLoginFailureProvider
- Throws:
- IllegalStateException- if transaction is not active
 
- 
authenticationSessionsAuthenticationSessionProvider authenticationSessions()
- 
singleUseObjectsSingleUseObjectProvider singleUseObjects()
- 
closevoid close()- Specified by:
- closein interface- AutoCloseable
 
- 
usersUserProvider users()A cached view of all users in system including users loaded by UserStorageProviders- Returns:
- UserProvider instance
 
- 
keysKeyManager keys()Key manager- Returns:
 
- 
themeThemeManager theme()Theme manager- Returns:
 
- 
tokensTokenManager tokens()Token manager- Returns:
 
- 
vaultVaultTranscriber vault()Vault transcriber
- 
clientPolicyClientPolicyManager clientPolicy()Client Policy Manager
 
-