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 Summary
Constructors Constructor Description DefaultKeycloakSession(DefaultKeycloakSessionFactory factory)
-
Method Summary
All 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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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:
getContextin interfaceKeycloakSession
-
userCache
@Deprecated public UserProvider userCache()
Deprecated.Description copied from interface:KeycloakSessionThe user cache- Specified by:
userCachein interfaceKeycloakSession- Returns:
- may be null if cache is disabled
-
invalidate
public 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 interfaceKeycloakSession- Parameters:
type- Type of the objects to invalidateids- Parameters used for the invalidation
-
enlistForClose
public void enlistForClose(Provider provider)
- Specified by:
enlistForClosein interfaceKeycloakSession
-
getAttribute
public Object getAttribute(String attribute)
- Specified by:
getAttributein interfaceKeycloakSession
-
getAttribute
public <T> T getAttribute(String attribute, Class<T> clazz)
- Specified by:
getAttributein interfaceKeycloakSession
-
removeAttribute
public Object removeAttribute(String attribute)
- Specified by:
removeAttributein interfaceKeycloakSession
-
setAttribute
public void setAttribute(String name, Object value)
- Specified by:
setAttributein interfaceKeycloakSession
-
getAttributes
public Map<String,Object> getAttributes()
- Specified by:
getAttributesin interfaceKeycloakSession
-
getTransactionManager
public KeycloakTransactionManager getTransactionManager()
- Specified by:
getTransactionManagerin interfaceKeycloakSession
-
getKeycloakSessionFactory
public KeycloakSessionFactory getKeycloakSessionFactory()
- Specified by:
getKeycloakSessionFactoryin interfaceKeycloakSession
-
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 interfaceKeycloakSession
-
realmLocalStorage
@Deprecated public RealmProvider realmLocalStorage()
Deprecated.- Specified by:
realmLocalStoragein interfaceKeycloakSession
-
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 interfaceKeycloakSession
-
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 interfaceKeycloakSession
-
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 interfaceKeycloakSession
-
clientStorageManager
@Deprecated public ClientProvider clientStorageManager()
Deprecated.- Specified by:
clientStorageManagerin interfaceKeycloakSession- Returns:
- ClientStorageManager instance
-
clientScopeStorageManager
@Deprecated public ClientScopeProvider clientScopeStorageManager()
Deprecated.- Specified by:
clientScopeStorageManagerin interfaceKeycloakSession- 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 interfaceKeycloakSession
-
roleStorageManager
@Deprecated public RoleProvider roleStorageManager()
Deprecated.- Specified by:
roleStorageManagerin interfaceKeycloakSession- Returns:
- RoleStorageManager instance
-
groupStorageManager
@Deprecated public GroupProvider groupStorageManager()
Deprecated.- Specified by:
groupStorageManagerin interfaceKeycloakSession- 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 interfaceKeycloakSession- Returns:
-
users
public UserProvider users()
Description copied from interface:KeycloakSessionA cached view of all users in system including users loaded by UserStorageProviders- Specified by:
usersin interfaceKeycloakSession- 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 interfaceKeycloakSession- Returns:
-
getProvider
public <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 interfaceKeycloakSession- Returns:
-
getProvider
public <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 interfaceKeycloakSession- Returns:
-
getComponentProvider
public <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 interfaceKeycloakSessioncomponentId- Component configuration- Returns:
- Provider configured according to the {@param componentId},
nullif it cannot be instantiated.
-
getComponentProvider
public <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 interfaceKeycloakSessioncomponentId- Component configurationmodelGetter- Getter to retrieve componentModel- Returns:
- Provider configured according to the {@param componentId},
nullif it cannot be instantiated.
-
getProvider
public <T extends Provider> T getProvider(Class<T> clazz, ComponentModel componentModel)
- Specified by:
getProviderin interfaceKeycloakSession- Returns:
-
listProviderIds
public <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 interfaceKeycloakSession- Returns:
-
getAllProviders
public <T extends Provider> Set<T> getAllProviders(Class<T> clazz)
- Specified by:
getAllProvidersin interfaceKeycloakSession
-
getProviderClass
public Class<? extends Provider> getProviderClass(String providerClassName)
- Specified by:
getProviderClassin interfaceKeycloakSession
-
realms
public 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 interfaceKeycloakSession- Returns:
-
clients
public 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 interfaceKeycloakSession- Returns:
-
clientScopes
public 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 interfaceKeycloakSession- Returns:
- Currently used ClientScopeProvider instance.
-
groups
public GroupProvider groups()
Description copied from interface:KeycloakSessionReturns a managed group provider instance.- Specified by:
groupsin interfaceKeycloakSession- Returns:
- Currently used GroupProvider instance.
-
roles
public 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 interfaceKeycloakSession- Returns:
-
sessions
public 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 interfaceKeycloakSession- Returns:
-
loginFailures
public 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 interfaceKeycloakSession- Returns:
UserLoginFailureProvider
-
authenticationSessions
public AuthenticationSessionProvider authenticationSessions()
- Specified by:
authenticationSessionsin interfaceKeycloakSession
-
keys
public KeyManager keys()
Description copied from interface:KeycloakSessionKey manager- Specified by:
keysin interfaceKeycloakSession- Returns:
-
theme
public ThemeManager theme()
Description copied from interface:KeycloakSessionTheme manager- Specified by:
themein interfaceKeycloakSession- Returns:
-
tokens
public TokenManager tokens()
Description copied from interface:KeycloakSessionToken manager- Specified by:
tokensin interfaceKeycloakSession- Returns:
-
vault
public VaultTranscriber vault()
Description copied from interface:KeycloakSessionVault transcriber- Specified by:
vaultin interfaceKeycloakSession
-
clientPolicy
public ClientPolicyManager clientPolicy()
Description copied from interface:KeycloakSessionClient Policy Manager- Specified by:
clientPolicyin interfaceKeycloakSession
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceKeycloakSession
-
closeTransactionManager
protected RuntimeException closeTransactionManager()
-
createKeycloakContext
protected DefaultKeycloakContext createKeycloakContext(KeycloakSession session)
-
isClosed
public boolean isClosed()
-
-