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 AuthenticationSessionProvider
authenticationSessions()
ClientProvider
clientLocalStorage()
Deprecated.ClientPolicyManager
clientPolicy()
Client Policy ManagerClientProvider
clients()
Returns a managed provider instance.ClientScopeProvider
clientScopeLocalStorage()
Deprecated.ClientScopeProvider
clientScopes()
Returns a managed provider instance.ClientScopeProvider
clientScopeStorageManager()
Deprecated.ClientProvider
clientStorageManager()
Deprecated.void
close()
protected RuntimeException
closeTransactionManager()
protected DefaultKeycloakContext
createKeycloakContext(KeycloakSession session)
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)
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)
Class<? extends Provider>
getProviderClass(String providerClassName)
KeycloakTransactionManager
getTransactionManager()
GroupProvider
groupLocalStorage()
Deprecated.GroupProvider
groups()
Returns a managed group provider instance.GroupProvider
groupStorageManager()
Deprecated.void
invalidate(InvalidationHandler.InvalidableObjectType type, Object... ids)
Invalidates intermediate states of the given objects, both immediately and at the end of this session.boolean
isClosed()
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.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 managerString
toString()
UserProvider
userCache()
Deprecated.UserCredentialManager
userCredentialManager()
Deprecated.UserProvider
userLocalStorage()
Deprecated.UserProvider
users()
A cached view of all users in system including users loaded by UserStorageProvidersUserProvider
userStorageManager()
Deprecated.VaultTranscriber
vault()
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:
getContext
in interfaceKeycloakSession
-
userCache
@Deprecated public UserProvider userCache()
Deprecated.Description copied from interface:KeycloakSession
The user cache- Specified by:
userCache
in interfaceKeycloakSession
- Returns:
- may be null if cache is disabled
-
invalidate
public void invalidate(InvalidationHandler.InvalidableObjectType type, Object... ids)
Description copied from interface:KeycloakSession
Invalidates intermediate states of the given objects, both immediately and at the end of this session.- Specified by:
invalidate
in interfaceKeycloakSession
- Parameters:
type
- Type of the objects to invalidateids
- Parameters used for the invalidation
-
enlistForClose
public void enlistForClose(Provider provider)
- Specified by:
enlistForClose
in interfaceKeycloakSession
-
getAttribute
public Object getAttribute(String attribute)
- Specified by:
getAttribute
in interfaceKeycloakSession
-
getAttribute
public <T> T getAttribute(String attribute, Class<T> clazz)
- Specified by:
getAttribute
in interfaceKeycloakSession
-
removeAttribute
public Object removeAttribute(String attribute)
- Specified by:
removeAttribute
in interfaceKeycloakSession
-
setAttribute
public void setAttribute(String name, Object value)
- Specified by:
setAttribute
in interfaceKeycloakSession
-
getAttributes
public Map<String,Object> getAttributes()
- Specified by:
getAttributes
in interfaceKeycloakSession
-
getTransactionManager
public KeycloakTransactionManager getTransactionManager()
- Specified by:
getTransactionManager
in interfaceKeycloakSession
-
getKeycloakSessionFactory
public KeycloakSessionFactory getKeycloakSessionFactory()
- Specified by:
getKeycloakSessionFactory
in interfaceKeycloakSession
-
userLocalStorage
@Deprecated public UserProvider userLocalStorage()
Deprecated.Description copied from interface:KeycloakSession
Keycloak specific local storage for users. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
userLocalStorage
in interfaceKeycloakSession
-
realmLocalStorage
@Deprecated public RealmProvider realmLocalStorage()
Deprecated.- Specified by:
realmLocalStorage
in interfaceKeycloakSession
-
clientLocalStorage
@Deprecated public ClientProvider clientLocalStorage()
Deprecated.Description copied from interface:KeycloakSession
Keycloak specific local storage for clients. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
clientLocalStorage
in interfaceKeycloakSession
-
clientScopeLocalStorage
@Deprecated public ClientScopeProvider clientScopeLocalStorage()
Deprecated.Description copied from interface:KeycloakSession
Keycloak specific local storage for client scopes. No cache in front, this api talks directly to database configured for Keycloak- Specified by:
clientScopeLocalStorage
in interfaceKeycloakSession
-
groupLocalStorage
@Deprecated public GroupProvider groupLocalStorage()
Deprecated.Description copied from interface:KeycloakSession
Keycloak specific local storage for groups. No cache in front, this api talks directly to storage configured for Keycloak- Specified by:
groupLocalStorage
in interfaceKeycloakSession
-
clientStorageManager
@Deprecated public ClientProvider clientStorageManager()
Deprecated.- Specified by:
clientStorageManager
in interfaceKeycloakSession
- Returns:
- ClientStorageManager instance
-
clientScopeStorageManager
@Deprecated public ClientScopeProvider clientScopeStorageManager()
Deprecated.- Specified by:
clientScopeStorageManager
in interfaceKeycloakSession
- Returns:
- ClientScopeStorageManager instance
-
roleLocalStorage
@Deprecated public RoleProvider roleLocalStorage()
Deprecated.Description copied from interface:KeycloakSession
Keycloak specific local storage for roles. No cache in front, this api talks directly to storage configured for Keycloak- Specified by:
roleLocalStorage
in interfaceKeycloakSession
-
roleStorageManager
@Deprecated public RoleProvider roleStorageManager()
Deprecated.- Specified by:
roleStorageManager
in interfaceKeycloakSession
- Returns:
- RoleStorageManager instance
-
groupStorageManager
@Deprecated public GroupProvider groupStorageManager()
Deprecated.- Specified by:
groupStorageManager
in interfaceKeycloakSession
- Returns:
- GroupStorageManager instance
-
userStorageManager
@Deprecated public UserProvider userStorageManager()
Deprecated.Description copied from interface:KeycloakSession
Un-cached view of all users in system including users loaded by UserStorageProviders- Specified by:
userStorageManager
in interfaceKeycloakSession
- Returns:
-
users
public UserProvider users()
Description copied from interface:KeycloakSession
A cached view of all users in system including users loaded by UserStorageProviders- Specified by:
users
in interfaceKeycloakSession
- Returns:
- UserProvider instance
-
userCredentialManager
@Deprecated public UserCredentialManager userCredentialManager()
Deprecated.Description copied from interface:KeycloakSession
Service that allows you to valid and update credentials for a user- Specified by:
userCredentialManager
in interfaceKeycloakSession
- Returns:
-
getProvider
public <T extends Provider> T getProvider(Class<T> clazz)
Description copied from interface:KeycloakSession
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)- Specified by:
getProvider
in interfaceKeycloakSession
- Returns:
-
getProvider
public <T extends Provider> T getProvider(Class<T> clazz, String id)
Description copied from interface:KeycloakSession
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).- Specified by:
getProvider
in interfaceKeycloakSession
- Returns:
-
getComponentProvider
public <T extends Provider> T getComponentProvider(Class<T> clazz, String componentId)
Description copied from interface:KeycloakSession
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()
.- Specified by:
getComponentProvider
in interfaceKeycloakSession
componentId
- Component configuration- Returns:
- Provider configured according to the {@param componentId},
null
if it cannot be instantiated.
-
getComponentProvider
public <T extends Provider> T getComponentProvider(Class<T> clazz, String componentId, Function<KeycloakSessionFactory,ComponentModel> modelGetter)
Description copied from interface:KeycloakSession
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()
.- Specified by:
getComponentProvider
in interfaceKeycloakSession
componentId
- Component configurationmodelGetter
- Getter to retrieve componentModel- Returns:
- Provider configured according to the {@param componentId},
null
if it cannot be instantiated.
-
getProvider
public <T extends Provider> T getProvider(Class<T> clazz, ComponentModel componentModel)
- Specified by:
getProvider
in interfaceKeycloakSession
- Returns:
-
listProviderIds
public <T extends Provider> Set<String> listProviderIds(Class<T> clazz)
Description copied from interface:KeycloakSession
Get all provider factories that manage provider instances of class.- Specified by:
listProviderIds
in interfaceKeycloakSession
- Returns:
-
getAllProviders
public <T extends Provider> Set<T> getAllProviders(Class<T> clazz)
- Specified by:
getAllProviders
in interfaceKeycloakSession
-
getProviderClass
public Class<? extends Provider> getProviderClass(String providerClassName)
- Specified by:
getProviderClass
in interfaceKeycloakSession
-
realms
public RealmProvider realms()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
realms
in interfaceKeycloakSession
- Returns:
-
clients
public ClientProvider clients()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
clients
in interfaceKeycloakSession
- Returns:
-
clientScopes
public ClientScopeProvider clientScopes()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
clientScopes
in interfaceKeycloakSession
- Returns:
- Currently used ClientScopeProvider instance.
-
groups
public GroupProvider groups()
Description copied from interface:KeycloakSession
Returns a managed group provider instance.- Specified by:
groups
in interfaceKeycloakSession
- Returns:
- Currently used GroupProvider instance.
-
roles
public RoleProvider roles()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
roles
in interfaceKeycloakSession
- Returns:
-
sessions
public UserSessionProvider sessions()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
sessions
in interfaceKeycloakSession
- Returns:
-
loginFailures
public UserLoginFailureProvider loginFailures()
Description copied from interface:KeycloakSession
Returns a managed provider instance. Will start a provider transaction. This transaction is managed by the KeycloakSession transaction.- Specified by:
loginFailures
in interfaceKeycloakSession
- Returns:
UserLoginFailureProvider
-
authenticationSessions
public AuthenticationSessionProvider authenticationSessions()
- Specified by:
authenticationSessions
in interfaceKeycloakSession
-
keys
public KeyManager keys()
Description copied from interface:KeycloakSession
Key manager- Specified by:
keys
in interfaceKeycloakSession
- Returns:
-
theme
public ThemeManager theme()
Description copied from interface:KeycloakSession
Theme manager- Specified by:
theme
in interfaceKeycloakSession
- Returns:
-
tokens
public TokenManager tokens()
Description copied from interface:KeycloakSession
Token manager- Specified by:
tokens
in interfaceKeycloakSession
- Returns:
-
vault
public VaultTranscriber vault()
Description copied from interface:KeycloakSession
Vault transcriber- Specified by:
vault
in interfaceKeycloakSession
-
clientPolicy
public ClientPolicyManager clientPolicy()
Description copied from interface:KeycloakSession
Client Policy Manager- Specified by:
clientPolicy
in interfaceKeycloakSession
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceKeycloakSession
-
closeTransactionManager
protected RuntimeException closeTransactionManager()
-
createKeycloakContext
protected DefaultKeycloakContext createKeycloakContext(KeycloakSession session)
-
isClosed
public boolean isClosed()
-
-