Search in sources :

Example 1 with RoleStorageProvider

use of org.keycloak.storage.role.RoleStorageProvider in project keycloak by keycloak.

the class RoleStorageManager method getStorageProviderInstance.

public static RoleStorageProvider getStorageProviderInstance(KeycloakSession session, RoleStorageProviderModel model, RoleStorageProviderFactory factory) {
    RoleStorageProvider instance = (RoleStorageProvider) session.getAttribute(model.getId());
    if (instance != null)
        return instance;
    instance = factory.create(session, model);
    if (instance == null) {
        throw new IllegalStateException("RoleStorageProvideFactory (of type " + factory.getClass().getName() + ") produced a null instance");
    }
    session.enlistForClose(instance);
    session.setAttribute(model.getId(), instance);
    return instance;
}
Also used : RoleStorageProvider(org.keycloak.storage.role.RoleStorageProvider)

Example 2 with RoleStorageProvider

use of org.keycloak.storage.role.RoleStorageProvider in project keycloak by keycloak.

the class RoleStorageManager method getStorageProvider.

public static RoleStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId) {
    ComponentModel model = realm.getComponent(componentId);
    if (model == null)
        return null;
    RoleStorageProviderModel storageModel = new RoleStorageProviderModel(model);
    RoleStorageProviderFactory factory = (RoleStorageProviderFactory) session.getKeycloakSessionFactory().getProviderFactory(RoleStorageProvider.class, model.getProviderId());
    if (factory == null) {
        throw new ModelException("Could not find RoletStorageProviderFactory for: " + model.getProviderId());
    }
    return getStorageProviderInstance(session, storageModel, factory);
}
Also used : RoleStorageProviderFactory(org.keycloak.storage.role.RoleStorageProviderFactory) ModelException(org.keycloak.models.ModelException) ComponentModel(org.keycloak.component.ComponentModel) RoleStorageProvider(org.keycloak.storage.role.RoleStorageProvider) RoleStorageProviderModel(org.keycloak.storage.role.RoleStorageProviderModel)

Aggregations

RoleStorageProvider (org.keycloak.storage.role.RoleStorageProvider)2 ComponentModel (org.keycloak.component.ComponentModel)1 ModelException (org.keycloak.models.ModelException)1 RoleStorageProviderFactory (org.keycloak.storage.role.RoleStorageProviderFactory)1 RoleStorageProviderModel (org.keycloak.storage.role.RoleStorageProviderModel)1