org.keycloak.provider.Provider Java Examples

The following examples show how to use org.keycloak.provider.Provider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultKeycloakSession.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public <T extends Provider> T getProvider(Class<T> clazz, ComponentModel componentModel) {
    String modelId = componentModel.getId();

    Object found = getAttribute(modelId);
    if (found != null) {
        return clazz.cast(found);
    }

    ProviderFactory<T> providerFactory = factory.getProviderFactory(clazz, componentModel.getProviderId());
    if (providerFactory == null) {
        return null;
    }

    @SuppressWarnings("unchecked")
    ComponentFactory<T, T> componentFactory = (ComponentFactory<T, T>) providerFactory;
    T provider = componentFactory.create(this, componentModel);
    enlistForClose(provider);
    setAttribute(modelId, provider);

    return provider;
}
 
Example #2
Source File: DefaultKeycloakSession.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Provider> T getProvider(Class<T> clazz) {
    Integer hash = clazz.hashCode();
    T provider = (T) providers.get(hash);
    // KEYCLOAK-11890 - Avoid using HashMap.computeIfAbsent() to implement logic in outer if() block below,
    // since per JDK-8071667 the remapping function should not modify the map during computation. While
    // allowed on JDK 1.8, attempt of such a modification throws ConcurrentModificationException with JDK 9+
    if (provider == null) {
        ProviderFactory<T> providerFactory = factory.getProviderFactory(clazz);
        if (providerFactory != null) {
            provider = providerFactory.create(DefaultKeycloakSession.this);
            providers.put(hash, provider);
        }
    }
    return provider;
}
 
Example #3
Source File: DefaultKeycloakSession.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Provider> T getProvider(Class<T> clazz, String id) {
    Integer hash = clazz.hashCode() + id.hashCode();
    T provider = (T) providers.get(hash);
    // KEYCLOAK-11890 - Avoid using HashMap.computeIfAbsent() to implement logic in outer if() block below,
    // since per JDK-8071667 the remapping function should not modify the map during computation. While
    // allowed on JDK 1.8, attempt of such a modification throws ConcurrentModificationException with JDK 9+
    if (provider == null) {
        ProviderFactory<T> providerFactory = factory.getProviderFactory(clazz, id);
        if (providerFactory != null) {
            provider = providerFactory.create(DefaultKeycloakSession.this);
            providers.put(hash, provider);
        }
    }
    return provider;
}
 
Example #4
Source File: DefaultKeycloakSessionFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected Map<Class<? extends Provider>, Map<String, ProviderFactory>> getFactoriesCopy() {
    Map<Class<? extends Provider>, Map<String, ProviderFactory>> copy = new HashMap<>();
    for (Map.Entry<Class<? extends Provider>, Map<String, ProviderFactory>> entry : factoriesMap.entrySet()) {
        Map<String, ProviderFactory> valCopy = new HashMap<>();
        valCopy.putAll(entry.getValue());
        copy.put(entry.getKey(), valCopy);
    }
    return copy;

}
 
Example #5
Source File: ComponentUtil.java    From keycloak with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: DefaultKeycloakSessionFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
Class<? extends Provider> getProviderClass(String providerClassName) {
    for (Class<? extends Provider> clazz : factoriesMap.keySet()) {
        if (clazz.getName().equals(providerClassName)) {
            return clazz;
        }
    }
    return null;
}
 
Example #7
Source File: LiquibaseConnectionSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return LiquibaseConnectionProvider.class;
}
 
Example #8
Source File: ClientRegistrationSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ClientRegistrationProvider.class;
}
 
Example #9
Source File: OIDCExtSPI.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return OIDCExtProvider.class;
}
 
Example #10
Source File: JpaEntitySpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
	return JpaEntityProvider.class;
}
 
Example #11
Source File: TestSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return TestProvider.class;
}
 
Example #12
Source File: LocaleUpdaterSPI.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return LocaleUpdaterProvider.class;
}
 
Example #13
Source File: ThemeResourceSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ThemeResourceProvider.class;
}
 
Example #14
Source File: BruteForceProtectorSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return BruteForceProtector.class;
}
 
Example #15
Source File: LocaleSelectorSPI.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return LocaleSelectorProvider.class;
}
 
Example #16
Source File: ExampleSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ExampleService.class;
}
 
Example #17
Source File: EventStoreSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return EventStoreProvider.class;
}
 
Example #18
Source File: X509ClientCertificateLookupSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return X509ClientCertificateLookup.class;
}
 
Example #19
Source File: ClusterSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ClusterProvider.class;
}
 
Example #20
Source File: SecurityHeadersSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return SecurityHeadersProvider.class;
}
 
Example #21
Source File: ClientSignatureVerifierSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ClientSignatureVerifierProvider.class;
}
 
Example #22
Source File: ContentEncryptionSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return ContentEncryptionProvider.class;
}
 
Example #23
Source File: HashSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return HashProvider.class;
}
 
Example #24
Source File: SignatureSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return SignatureProvider.class;
}
 
Example #25
Source File: SamlAuthenticationPreprocessorSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return SamlAuthenticationPreprocessor.class;
}
 
Example #26
Source File: DefaultKeycloakSession.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass(String providerClassName) {
    return factory.getProviderClass(providerClassName);
}
 
Example #27
Source File: StoreFactorySpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return StoreFactory.class;
}
 
Example #28
Source File: PolicySpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return PolicyProvider.class;
}
 
Example #29
Source File: AuthorizationSpi.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return AuthorizationProvider.class;
}
 
Example #30
Source File: HealthIndicatorSpi.java    From keycloak-health-checks with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends Provider> getProviderClass() {
    return HealthIndicator.class;
}