Search in sources :

Example 1 with ClaimInformationPointProviderFactory

use of org.keycloak.adapters.authorization.ClaimInformationPointProviderFactory in project keycloak by keycloak.

the class ClaimInformationPointProviderTest method getClaimInformationProviderForPath.

private ClaimInformationPointProvider getClaimInformationProviderForPath(String path, String providerName) {
    KeycloakDeployment deployment = KeycloakDeploymentBuilder.build(getClass().getResourceAsStream("/authorization-test/enforcer-config-claims-provider.json"));
    deployment.setClient(HttpClients.createDefault());
    PolicyEnforcer policyEnforcer = deployment.getPolicyEnforcer();
    Map<String, ClaimInformationPointProviderFactory> providers = policyEnforcer.getClaimInformationPointProviderFactories();
    PathConfig pathConfig = policyEnforcer.getPaths().get(path);
    assertNotNull(pathConfig);
    Map<String, Map<String, Object>> cipConfig = pathConfig.getClaimInformationPointConfig();
    assertNotNull(cipConfig);
    ClaimInformationPointProviderFactory factory = providers.get(providerName);
    assertNotNull(factory);
    Map<String, Object> claimsConfig = cipConfig.get(providerName);
    return factory.create(claimsConfig);
}
Also used : PathConfig(org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig) KeycloakDeployment(org.keycloak.adapters.KeycloakDeployment) PolicyEnforcer(org.keycloak.adapters.authorization.PolicyEnforcer) ClaimInformationPointProviderFactory(org.keycloak.adapters.authorization.ClaimInformationPointProviderFactory) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 KeycloakDeployment (org.keycloak.adapters.KeycloakDeployment)1 ClaimInformationPointProviderFactory (org.keycloak.adapters.authorization.ClaimInformationPointProviderFactory)1 PolicyEnforcer (org.keycloak.adapters.authorization.PolicyEnforcer)1 PathConfig (org.keycloak.representations.adapters.config.PolicyEnforcerConfig.PathConfig)1