Search in sources :

Example 1 with TruststoreProviderFactory

use of org.keycloak.truststore.TruststoreProviderFactory in project keycloak by keycloak.

the class NginxProxySslClientCertificateLookup method loadKeycloakTrustStore.

/**
 *  Loading truststore @ first login
 *
 * @param kcsession
 * @return
 */
public boolean loadKeycloakTrustStore(KeycloakSession kcsession) {
    if (!isTruststoreLoaded) {
        log.debug(" Loading Keycloak truststore ...");
        KeycloakSessionFactory factory = kcsession.getKeycloakSessionFactory();
        TruststoreProviderFactory truststoreFactory = (TruststoreProviderFactory) factory.getProviderFactory(TruststoreProvider.class, "file");
        TruststoreProvider provider = truststoreFactory.create(kcsession);
        if (provider != null && provider.getTruststore() != null) {
            truststore = provider.getTruststore();
            trustedRootCerts = new HashSet<>(provider.getRootCertificates().values());
            intermediateCerts = new HashSet<>(provider.getIntermediateCertificates().values());
            log.debug("Keycloak truststore loaded for NGINX x509cert-lookup provider.");
            isTruststoreLoaded = true;
        }
    }
    return isTruststoreLoaded;
}
Also used : TruststoreProviderFactory(org.keycloak.truststore.TruststoreProviderFactory) KeycloakSessionFactory(org.keycloak.models.KeycloakSessionFactory) TruststoreProvider(org.keycloak.truststore.TruststoreProvider)

Aggregations

KeycloakSessionFactory (org.keycloak.models.KeycloakSessionFactory)1 TruststoreProvider (org.keycloak.truststore.TruststoreProvider)1 TruststoreProviderFactory (org.keycloak.truststore.TruststoreProviderFactory)1