Search in sources :

Example 1 with ClientStorageProvider

use of org.keycloak.storage.client.ClientStorageProvider in project keycloak by keycloak.

the class ClientStorageManager method getStorageProvider.

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

Example 2 with ClientStorageProvider

use of org.keycloak.storage.client.ClientStorageProvider in project keycloak by keycloak.

the class ClientStorageManager method getStorageProviderInstance.

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

Aggregations

ClientStorageProvider (org.keycloak.storage.client.ClientStorageProvider)2 ComponentModel (org.keycloak.component.ComponentModel)1 ModelException (org.keycloak.models.ModelException)1 ClientStorageProviderFactory (org.keycloak.storage.client.ClientStorageProviderFactory)1 ClientStorageProviderModel (org.keycloak.storage.client.ClientStorageProviderModel)1