Package org.keycloak.storage
Class AbstractStorageManager<ProviderType extends Provider,StorageProviderModelType extends CacheableStorageProviderModel>
- java.lang.Object
- 
- org.keycloak.storage.AbstractStorageManager<ProviderType,StorageProviderModelType>
 
- 
- Type Parameters:
- ProviderType- This type will be used for looking for factories that produce instances of desired providers
- StorageProviderModelType- Type of model used for creating provider, it needs to extend CacheableStorageProviderModel as it has- isEnabled()method and also extend PrioritizedComponentModel which is required for sorting providers based on its priorities
 - Direct Known Subclasses:
- ClientScopeStorageManager,- GroupStorageManager,- LegacyUserCredentialManager,- UserStorageManager
 
 public abstract class AbstractStorageManager<ProviderType extends Provider,StorageProviderModelType extends CacheableStorageProviderModel> extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description protected KeycloakSessionsession
 - 
Constructor SummaryConstructors Constructor Description AbstractStorageManager(KeycloakSession session, Class<? extends ProviderFactory> factoryTypeClass, Class<ProviderType> providerTypeClass, Function<ComponentModel,StorageProviderModelType> toStorageProviderModelTypeFunction, String configScope)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> voidconsumeEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Consumer<T> consumer)Gets all enabled StorageProviders that implements the capabilityInterface and call applyFunction on each !! Each StorageProvider has a limited time for consuming !!protected <R,T>
 Stream<R>flatMapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,? extends Stream<R>> applyFunction)Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of them and then join the results together.protected <T> Stream<T>getEnabledStorageProviders(RealmModel realm, Class<T> capabilityInterface)Returns stream of all storageProviders within the realm that implements the capabilityInterface.protected <T extends ProviderType>
 ComponentFactory<T,ProviderType>getStorageProviderFactory(String providerId)Returns a factory with the providerId, which produce instances of type CreatedProviderTypeprotected <T> TgetStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface)protected <T> TgetStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface, boolean includeDisabled)Returns an instance of provider with the providerId within the realm or null if storage provider with providerId doesn't implement capabilityInterface.protected <T> TgetStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface)Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.protected <T> TgetStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface, boolean includeDisabled)Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.protected StorageProviderModelTypegetStorageProviderModel(RealmModel realm, String providerId)Returns an instance of StorageProvider model corresponding realm and providerIdstatic Stream<ComponentModel>getStorageProviderModels(RealmModel realm, Class<? extends Provider> storageType)Stream of ComponentModels of storageType.protected LonggetStorageProviderTimeout()protected <R,T>
 Stream<R>mapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,R> applyFunction)Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of them and returns the stream.
 
- 
- 
- 
Field Detail- 
sessionprotected final KeycloakSession session 
 
- 
 - 
Constructor Detail- 
AbstractStorageManagerpublic AbstractStorageManager(KeycloakSession session, Class<? extends ProviderFactory> factoryTypeClass, Class<ProviderType> providerTypeClass, Function<ComponentModel,StorageProviderModelType> toStorageProviderModelTypeFunction, String configScope) 
 
- 
 - 
Method Detail- 
getStorageProviderTimeoutprotected Long getStorageProviderTimeout() 
 - 
getStorageProviderFactoryprotected <T extends ProviderType> ComponentFactory<T,ProviderType> getStorageProviderFactory(String providerId) Returns a factory with the providerId, which produce instances of type CreatedProviderType- Parameters:
- providerId- id of factory that produce desired instances
- Returns:
- A factory that implements ComponentFactory<CreatedProviderType, ProviderType>
 
 - 
getEnabledStorageProvidersprotected <T> Stream<T> getEnabledStorageProviders(RealmModel realm, Class<T> capabilityInterface) Returns stream of all storageProviders within the realm that implements the capabilityInterface.- Parameters:
- realm- realm
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- Returns:
- enabled storage providers for realm and @{code getProviderTypeClass()}
 
 - 
flatMapEnabledStorageProvidersWithTimeoutprotected <R,T> Stream<R> flatMapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,? extends Stream<R>> applyFunction) Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of them and then join the results together. !! Each StorageProvider has a limited time to respond, if it fails to do it, empty stream is returned !!- Type Parameters:
- R- result of applyFunction
- Parameters:
- realm- realm
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- applyFunction- function that is applied on StorageProviders
- Returns:
- a stream with all results from all StorageProviders
 
 - 
mapEnabledStorageProvidersWithTimeoutprotected <R,T> Stream<R> mapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,R> applyFunction) Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of them and returns the stream. !! Each StorageProvider has a limited time to respond, if it fails to do it, null is returned !!- Type Parameters:
- R- Result of applyFunction
- Parameters:
- realm- realm
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- applyFunction- function that is applied on StorageProviders
- Returns:
- First result from StorageProviders
 
 - 
consumeEnabledStorageProvidersWithTimeoutprotected <T> void consumeEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Consumer<T> consumer) Gets all enabled StorageProviders that implements the capabilityInterface and call applyFunction on each !! Each StorageProvider has a limited time for consuming !!- Parameters:
- realm- realm
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- consumer- function that is applied on StorageProviders
 
 - 
getStorageProviderInstanceprotected <T> T getStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface) 
 - 
getStorageProviderInstanceprotected <T> T getStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface, boolean includeDisabled) Returns an instance of provider with the providerId within the realm or null if storage provider with providerId doesn't implement capabilityInterface.- Parameters:
- realm- realm
- providerId- id of ComponentModel within database/storage
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- Returns:
- an instance of type CreatedProviderType or null if storage provider with providerId doesn't implement capabilityInterface
 
 - 
getStorageProviderModelprotected StorageProviderModelType getStorageProviderModel(RealmModel realm, String providerId) Returns an instance of StorageProvider model corresponding realm and providerId- Parameters:
- realm- Realm.
- providerId- Id of desired provider.
- Returns:
- An instance of type StorageProviderModelType
 
 - 
getStorageProviderInstanceprotected <T> T getStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface) Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.- Type Parameters:
- T- Required capability interface type
- Parameters:
- model- StorageProviderModel obtained from database/storage
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- Returns:
- an instance of type T or null if storage provider based on the model doesn't exist or doesn't implement the capabilityInterface.
 
 - 
getStorageProviderInstanceprotected <T> T getStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface, boolean includeDisabled) Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.- Parameters:
- model- StorageProviderModel obtained from database/storage
- capabilityInterface- class of desired capabilityInterface. For example,- GroupLookupProvideror- UserQueryProvider
- includeDisabled- If set to true, the method will return also disabled providers.
- Returns:
- an instance of type T or null if storage provider based on the model doesn't exist or doesn't implement the capabilityInterface.
 
 - 
getStorageProviderModelspublic static Stream<ComponentModel> getStorageProviderModels(RealmModel realm, Class<? extends Provider> storageType) Stream of ComponentModels of storageType.- Parameters:
- realm- Realm.
- storageType- Type.
- Returns:
- Stream of ComponentModels
 
 
- 
 
-