Search in sources :

Example 11 with ComponentFactory

use of org.keycloak.component.ComponentFactory in project keycloak by keycloak.

the class ComponentUtil method getComponentFactory.

private static ComponentFactory getComponentFactory(KeycloakSession session, String providerType, String providerId) {
    Class<? extends Provider> provider = session.getProviderClass(providerType);
    if (provider == null) {
        throw new IllegalArgumentException("Invalid provider type '" + providerType + "'");
    }
    ProviderFactory<? extends Provider> f = session.getKeycloakSessionFactory().getProviderFactory(provider, providerId);
    if (f == null) {
        throw new IllegalArgumentException("No such provider '" + providerId + "'");
    }
    ComponentFactory cf = (ComponentFactory) f;
    return cf;
}
Also used : ComponentFactory(org.keycloak.component.ComponentFactory)

Example 12 with ComponentFactory

use of org.keycloak.component.ComponentFactory in project keycloak by keycloak.

the class ComponentUtil method notifyPreRemove.

public static void notifyPreRemove(KeycloakSession session, RealmModel realm, ComponentModel model) {
    try {
        ComponentFactory factory = getComponentFactory(session, model);
        factory.preRemove(session, realm, model);
    } catch (IllegalArgumentException iae) {
        // We allow to remove broken providers without throwing an exception
        logger.warn(iae.getMessage());
    }
}
Also used : ComponentFactory(org.keycloak.component.ComponentFactory)

Aggregations

ComponentFactory (org.keycloak.component.ComponentFactory)12 ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)3 HashMap (java.util.HashMap)2 ComponentTypeRepresentation (org.keycloak.representations.idm.ComponentTypeRepresentation)2 UserStorageSyncManager (org.keycloak.services.managers.UserStorageSyncManager)2 UserStorageProviderFactory (org.keycloak.storage.UserStorageProviderFactory)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 ComponentValidationException (org.keycloak.component.ComponentValidationException)1 SubComponentFactory (org.keycloak.component.SubComponentFactory)1 ModelDuplicateException (org.keycloak.models.ModelDuplicateException)1 MapComponentEntity (org.keycloak.models.map.realm.entity.MapComponentEntity)1 ConfiguredProvider (org.keycloak.provider.ConfiguredProvider)1 ProviderFactory (org.keycloak.provider.ProviderFactory)1 Spi (org.keycloak.provider.Spi)1 ConfigPropertyRepresentation (org.keycloak.representations.idm.ConfigPropertyRepresentation)1 ProviderRepresentation (org.keycloak.representations.info.ProviderRepresentation)1 SpiInfoRepresentation (org.keycloak.representations.info.SpiInfoRepresentation)1 OnCreateComponent (org.keycloak.storage.OnCreateComponent)1 OnUpdateComponent (org.keycloak.storage.OnUpdateComponent)1