Package org.keycloak.models.map.common
Class SessionAttributesUtils
- java.lang.Object
- 
- org.keycloak.models.map.common.SessionAttributesUtils
 
- 
 public class SessionAttributesUtils extends Object 
- 
- 
Constructor SummaryConstructors Constructor Description SessionAttributesUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <V extends AbstractEntity & UpdatableEntity,M,T extends MapStorage<V,M>>
 TcreateMapStorageIfAbsent(KeycloakSession session, Class<? extends MapStorageProvider> providerType, Class<M> modelType, int factoryId, Supplier<T> createNew)Used for creating a store instance only once within one KeycloakSession.static <T extends Provider>
 TcreateProviderIfAbsent(KeycloakSession session, int factoryIdentifier, Class<T> providerClass, Function<KeycloakSession,T> createNew)Used for creating a provider instance only once within one KeycloakSession.static intgrabNewFactoryIdentifier()Returns a new unique counter across whole Keycloak instance
 
- 
- 
- 
Method Detail- 
grabNewFactoryIdentifierpublic static int grabNewFactoryIdentifier() Returns a new unique counter across whole Keycloak instance- Returns:
- unique number
 
 - 
createProviderIfAbsentpublic static <T extends Provider> T createProviderIfAbsent(KeycloakSession session, int factoryIdentifier, Class<T> providerClass, Function<KeycloakSession,T> createNew) Used for creating a provider instance only once within one KeycloakSession. Checks whether there already exists a provider withing session attributes for givenproviderClassandfactoryIdentifier. If exists returns existing provider, otherwise creates a new instance usingcreateNewfunction.- Type Parameters:
- T- type of the provider
- Parameters:
- session- current Keycloak session
- factoryIdentifier- unique factory identifier.- grabNewFactoryIdentifier()can be used for obtaining new identifiers.
- providerClass- class of the requested provider
- createNew- function that creates a new instance of the provider
- Returns:
- an instance of the provider either from session attributes or freshly created.
 
 - 
createMapStorageIfAbsentpublic static <V extends AbstractEntity & UpdatableEntity,M,T extends MapStorage<V,M>> T createMapStorageIfAbsent(KeycloakSession session, Class<? extends MapStorageProvider> providerType, Class<M> modelType, int factoryId, Supplier<T> createNew) Used for creating a store instance only once within one KeycloakSession. Checks whether there already is a store within session attributes for givenproviderClass,modelTypeandfactoryIdentifier. If exists returns existing provider, otherwise creates a new instance usingcreateNewsupplier.- Type Parameters:
- V- entity type
- M- model type
- T- store type
- Parameters:
- session- current Keycloak session
- providerType- map storage provider class
- modelType- model class. Can be null if the store is the same for all models.
- factoryId- unique factory identifier.- grabNewFactoryIdentifier()can be used for obtaining new identifiers.
- createNew- supplier that creates a new instance of the store
- Returns:
- an instance of the store either from session attributes or freshly created.
 
 
- 
 
-