Search in sources :

Example 1 with JsonConfigComponentModel

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

the class ClientPoliciesUtil method getExecutorProvider.

private static ClientPolicyExecutorProvider getExecutorProvider(KeycloakSession session, RealmModel realm, String providerId, JsonNode config) {
    ComponentModel componentModel = new JsonConfigComponentModel(ClientPolicyExecutorProvider.class, realm.getId(), providerId, config);
    ClientPolicyExecutorProvider executorProvider = session.getComponentProvider(ClientPolicyExecutorProvider.class, componentModel.getId(), sessionFactory -> componentModel);
    if (executorProvider == null) {
        // condition's provider not found. just skip it.
        throw new IllegalStateException("Executor with provider ID " + providerId + " not found");
    }
    ClientPolicyExecutorConfigurationRepresentation configuration = (ClientPolicyExecutorConfigurationRepresentation) JsonSerialization.mapper.convertValue(config, executorProvider.getExecutorConfigurationClass());
    executorProvider.setupConfiguration(configuration);
    return executorProvider;
}
Also used : ClientPolicyExecutorProvider(org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider) ComponentModel(org.keycloak.component.ComponentModel) JsonConfigComponentModel(org.keycloak.component.JsonConfigComponentModel) ClientPolicyExecutorConfigurationRepresentation(org.keycloak.representations.idm.ClientPolicyExecutorConfigurationRepresentation) JsonConfigComponentModel(org.keycloak.component.JsonConfigComponentModel)

Example 2 with JsonConfigComponentModel

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

the class ClientPoliciesUtil method getConditionProvider.

private static ClientPolicyConditionProvider getConditionProvider(KeycloakSession session, RealmModel realm, String providerId, JsonNode config) {
    ComponentModel componentModel = new JsonConfigComponentModel(ClientPolicyConditionProvider.class, realm.getId(), providerId, config);
    ClientPolicyConditionProvider conditionProvider = session.getComponentProvider(ClientPolicyConditionProvider.class, componentModel.getId(), sessionFactory -> componentModel);
    if (conditionProvider == null) {
        // condition's provider not found. just skip it.
        throw new IllegalStateException("Condition with provider ID " + providerId + " not found");
    }
    ClientPolicyConditionConfigurationRepresentation configuration = (ClientPolicyConditionConfigurationRepresentation) JsonSerialization.mapper.convertValue(config, conditionProvider.getConditionConfigurationClass());
    conditionProvider.setupConfiguration(configuration);
    return conditionProvider;
}
Also used : ClientPolicyConditionProvider(org.keycloak.services.clientpolicy.condition.ClientPolicyConditionProvider) ClientPolicyConditionConfigurationRepresentation(org.keycloak.representations.idm.ClientPolicyConditionConfigurationRepresentation) ComponentModel(org.keycloak.component.ComponentModel) JsonConfigComponentModel(org.keycloak.component.JsonConfigComponentModel) JsonConfigComponentModel(org.keycloak.component.JsonConfigComponentModel)

Aggregations

ComponentModel (org.keycloak.component.ComponentModel)2 JsonConfigComponentModel (org.keycloak.component.JsonConfigComponentModel)2 ClientPolicyConditionConfigurationRepresentation (org.keycloak.representations.idm.ClientPolicyConditionConfigurationRepresentation)1 ClientPolicyExecutorConfigurationRepresentation (org.keycloak.representations.idm.ClientPolicyExecutorConfigurationRepresentation)1 ClientPolicyConditionProvider (org.keycloak.services.clientpolicy.condition.ClientPolicyConditionProvider)1 ClientPolicyExecutorProvider (org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider)1