Search in sources :

Example 1 with KeycloakDeploymentInfo

use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.

the class FeatureDeployerUtil method createDeploymentInfo.

private static KeycloakDeploymentInfo createDeploymentInfo(Map<ProviderFactory, Spi> factories) {
    KeycloakDeploymentInfo di = KeycloakDeploymentInfo.create();
    for (Map.Entry<ProviderFactory, Spi> factory : factories.entrySet()) {
        ProviderFactory pf = factory.getKey();
        Class<? extends Spi> spiClass = factory.getValue().getClass();
        di.addProvider(spiClass, pf);
    }
    return di;
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) EnvironmentDependentProviderFactory(org.keycloak.provider.EnvironmentDependentProviderFactory) ProviderFactory(org.keycloak.provider.ProviderFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) Spi(org.keycloak.provider.Spi)

Example 2 with KeycloakDeploymentInfo

use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.

the class FeatureDeployerUtil method loadFactories.

private static void loadFactories(ProviderManager pm) {
    KeycloakDeploymentInfo di = KeycloakDeploymentInfo.create().services();
    ClassLoader classLoader = DefaultKeycloakSession.class.getClassLoader();
    DefaultProviderLoader loader = new DefaultProviderLoader(di, classLoader);
    loader.loadSpis().forEach(pm::load);
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) DefaultProviderLoader(org.keycloak.provider.DefaultProviderLoader)

Example 3 with KeycloakDeploymentInfo

use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.

the class FeatureDeployerUtil method deployFactoriesAfterFeatureEnabled.

public static void deployFactoriesAfterFeatureEnabled(Profile.Feature feature) {
    ProviderManager manager = deployersCache.get(feature);
    if (manager == null) {
        // Need to figure which provider factories were enabled after feature was enabled. Create deployer based on it and save it to the cache
        Map<ProviderFactory, Spi> factoriesBeforeEnable = initializer.remove(feature);
        Map<ProviderFactory, Spi> factoriesAfterEnable = loadEnabledEnvironmentFactories();
        Map<ProviderFactory, Spi> factories = getFactoriesDependentOnFeature(factoriesBeforeEnable, factoriesAfterEnable);
        logger.infof("New factories when enabling feature '%s': %s", feature, factories.keySet());
        KeycloakDeploymentInfo di = createDeploymentInfo(factories);
        manager = new ProviderManager(di, FeatureDeployerUtil.class.getClassLoader());
        deployersCache.put(feature, manager);
    }
    ProviderManagerRegistry.SINGLETON.deploy(manager);
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ProviderManager(org.keycloak.provider.ProviderManager) EnvironmentDependentProviderFactory(org.keycloak.provider.EnvironmentDependentProviderFactory) ProviderFactory(org.keycloak.provider.ProviderFactory) Spi(org.keycloak.provider.Spi)

Example 4 with KeycloakDeploymentInfo

use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.

the class KeycloakProviderDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();
    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }
    KeycloakDeploymentInfo info = getKeycloakProviderDeploymentInfo(deploymentUnit);
    if (info.hasServices()) {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final ModuleLoader moduleLoader = Module.getBootModuleLoader();
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI_PRIVATE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAXRS, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, RESTEASY, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JPA, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_MAP, false, false, false, false));
    }
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 5 with KeycloakDeploymentInfo

use of org.keycloak.provider.KeycloakDeploymentInfo in project keycloak by keycloak.

the class KeycloakProviderDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();
    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }
    KeycloakDeploymentInfo info = KeycloakProviderDependencyProcessor.getKeycloakProviderDeploymentInfo(deploymentUnit);
    ScriptProviderDeploymentProcessor.deploy(deploymentUnit, info);
    if (info.isProvider()) {
        logger.infov("Deploying Keycloak provider: {0}", deploymentUnit.getName());
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        ProviderManager pm = new ProviderManager(info, module.getClassLoader());
        ProviderManagerRegistry.SINGLETON.deploy(pm);
        deploymentUnit.putAttachment(ATTACHMENT_KEY, pm);
    }
}
Also used : KeycloakDeploymentInfo(org.keycloak.provider.KeycloakDeploymentInfo) ProviderManager(org.keycloak.provider.ProviderManager) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

KeycloakDeploymentInfo (org.keycloak.provider.KeycloakDeploymentInfo)9 EnvironmentDependentProviderFactory (org.keycloak.provider.EnvironmentDependentProviderFactory)5 ProviderFactory (org.keycloak.provider.ProviderFactory)5 Spi (org.keycloak.provider.Spi)5 ProviderManager (org.keycloak.provider.ProviderManager)4 HashMap (java.util.HashMap)3 IOException (java.io.IOException)2 JdbcDataSourceBuildItem (io.quarkus.agroal.spi.JdbcDataSourceBuildItem)1 DevServicesDatasourceResultBuildItem (io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem)1 IsDevelopment (io.quarkus.deployment.IsDevelopment)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 Consume (io.quarkus.deployment.annotations.Consume)1 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)1 Record (io.quarkus.deployment.annotations.Record)1 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)1 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)1 GeneratedResourceBuildItem (io.quarkus.deployment.builditem.GeneratedResourceBuildItem)1 HotDeploymentWatchedFileBuildItem (io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem)1 IndexDependencyBuildItem (io.quarkus.deployment.builditem.IndexDependencyBuildItem)1