All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.oidc.runtime.TenantConfigBean Maven / Gradle / Ivy

Go to download

Secure your applications with OpenID Connect Adapter and IDP such as Keycloak

There is a newer version: 3.17.5
Show newest version
package io.quarkus.oidc.runtime;

import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Function;

import javax.enterprise.context.spi.CreationalContext;

import io.quarkus.arc.BeanDestroyer;
import io.quarkus.oidc.OidcTenantConfig;
import io.smallrye.mutiny.Uni;

public class TenantConfigBean {

    private final Map staticTenantsConfig;
    private final Map dynamicTenantsConfig;
    private final TenantConfigContext defaultTenant;
    private final Function> tenantConfigContextFactory;

    public TenantConfigBean(
            Map staticTenantsConfig,
            Map dynamicTenantsConfig,
            TenantConfigContext defaultTenant,
            Function> tenantConfigContextFactory,
            Executor blockingExecutor) {
        this.staticTenantsConfig = staticTenantsConfig;
        this.dynamicTenantsConfig = dynamicTenantsConfig;
        this.defaultTenant = defaultTenant;
        this.tenantConfigContextFactory = tenantConfigContextFactory;
    }

    public Map getStaticTenantsConfig() {
        return staticTenantsConfig;
    }

    public TenantConfigContext getDefaultTenant() {
        return defaultTenant;
    }

    public Function> getTenantConfigContextFactory() {
        return tenantConfigContextFactory;
    }

    public Map getDynamicTenantsConfig() {
        return dynamicTenantsConfig;
    }

    public static class Destroyer implements BeanDestroyer {

        @Override
        public void destroy(TenantConfigBean instance, CreationalContext creationalContext,
                Map params) {
            if (instance.defaultTenant != null && instance.defaultTenant.provider != null) {
                instance.defaultTenant.provider.close();
            }
            for (var i : instance.staticTenantsConfig.values()) {
                if (i.provider != null) {
                    i.provider.close();
                }
            }
            for (var i : instance.dynamicTenantsConfig.values()) {
                if (i.provider != null) {
                    i.provider.close();
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy