Package org.keycloak.models
Interface KeycloakSession
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultKeycloakSession
,ImportKeycloakSession
public interface KeycloakSession extends AutoCloseable
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description AuthenticationSessionProvider
authenticationSessions()
ClientProvider
clientLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method.ClientPolicyManager
clientPolicy()
Client Policy ManagerClientProvider
clients()
Returns a managed provider instance.ClientScopeProvider
clientScopeLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method.ClientScopeProvider
clientScopes()
Returns a managed provider instance.ClientScopeProvider
clientScopeStorageManager()
Deprecated.UseclientScopes()
insteadClientProvider
clientStorageManager()
Deprecated.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)
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.KeycloakContext
getContext()
KeycloakSessionFactory
getKeycloakSessionFactory()
<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)Class<? extends Provider>
getProviderClass(String providerClassName)
KeycloakTransactionManager
getTransactionManager()
GroupProvider
groupLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method.GroupProvider
groups()
Returns a managed group provider instance.GroupProvider
groupStorageManager()
Deprecated.void
invalidate(InvalidationHandler.InvalidableObjectType type, Object... params)
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()
Deprecated.RealmProvider
realms()
Returns a managed provider instance.Object
removeAttribute(String attribute)
RoleProvider
roleLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method.RoleProvider
roles()
Returns a managed provider instance.RoleProvider
roleStorageManager()
Deprecated.UserSessionProvider
sessions()
Returns a managed provider instance.void
setAttribute(String name, Object value)
ThemeManager
theme()
Theme managerTokenManager
tokens()
Token managerUserProvider
userCache()
Deprecated.The access to the UserCache interface is no longer possible here, and this method is about to be removed.UserCredentialManager
userCredentialManager()
Deprecated.UseUserModel.credentialManager()
instead.UserProvider
userLocalStorage()
Deprecated.UserProvider
users()
A cached view of all users in system including users loaded by UserStorageProvidersUserProvider
userStorageManager()
Deprecated.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:
-
getComponentProvider
<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. 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 {@param componentId},
null
if 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 configurationmodelGetter
- Getter to retrieve componentModel- Returns:
- Provider configured according to the {@param componentId},
null
if it cannot be instantiated. - Throws:
IllegalArgumentException
- If the realm is not set in the context.
-
getProvider
<T extends Provider> T getProvider(Class<T> clazz, ComponentModel componentModel)
Deprecated.Deprecated in favor of {@link #getComponentProvider)- Type Parameters:
T
-- Parameters:
clazz
-componentModel
-- Returns:
-
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:
-
getAttributeOrDefault
default <T> T getAttributeOrDefault(String attribute, T defaultValue)
-
invalidate
void invalidate(InvalidationHandler.InvalidableObjectType type, Object... params)
Invalidates intermediate states of the given objects, both immediately and at the end of this session.- Parameters:
type
- Type of the objects to invalidateparams
- Parameters used for the invalidation
-
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
-
clientScopes
ClientScopeProvider 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
-
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
-
loginFailures
UserLoginFailureProvider 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
-
authenticationSessions
AuthenticationSessionProvider authenticationSessions()
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
userCache
@Deprecated UserProvider userCache()
Deprecated.The access to the UserCache interface is no longer possible here, and this method is about to be removed. Adjust your code according to the Keycloak 19 Upgrading Guide.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:
- UserProvider instance
-
clientStorageManager
@Deprecated ClientProvider clientStorageManager()
Deprecated.- Returns:
- ClientStorageManager instance
-
clientScopeStorageManager
@Deprecated ClientScopeProvider clientScopeStorageManager()
Deprecated.UseclientScopes()
instead- Returns:
- ClientScopeStorageManager instance
-
roleStorageManager
@Deprecated RoleProvider roleStorageManager()
Deprecated.- Returns:
- RoleStorageManager instance
-
groupStorageManager
@Deprecated GroupProvider groupStorageManager()
Deprecated.- Returns:
- GroupStorageManager instance
-
userStorageManager
@Deprecated UserProvider userStorageManager()
Deprecated.Un-cached view of all users in system including users loaded by UserStorageProviders- Returns:
-
userCredentialManager
@Deprecated UserCredentialManager userCredentialManager()
Deprecated.UseUserModel.credentialManager()
instead.Service that allows you to valid and update credentials for a user- Returns:
-
userLocalStorage
@Deprecated UserProvider userLocalStorage()
Deprecated.Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak
-
realmLocalStorage
@Deprecated RealmProvider realmLocalStorage()
Deprecated.
-
clientLocalStorage
@Deprecated ClientProvider clientLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.Keycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak
-
clientScopeLocalStorage
@Deprecated ClientScopeProvider clientScopeLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.Keycloak specific local storage for client scopes. No cache in front, this api talks directly to database configured for Keycloak
-
groupLocalStorage
@Deprecated GroupProvider groupLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.Keycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak
-
roleLocalStorage
@Deprecated RoleProvider roleLocalStorage()
Deprecated.Access to the legacy store is no longer possible via this method. Adjust your code according to the Keycloak 19 Upgrading Guide.Keycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak
-
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
-
-