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

io.quarkus.keycloak.pep.runtime.PolicyEnforcerResolver Maven / Gradle / Ivy

Go to download

Policy enforcer using Keycloak-managed permissions to control access to protected resources

There is a newer version: 3.17.0
Show newest version
package io.quarkus.keycloak.pep.runtime;

import java.util.Map;

import org.keycloak.adapters.authorization.PolicyEnforcer;

public class PolicyEnforcerResolver {

    private final PolicyEnforcer defaultPolicyEnforcer;
    private final Map policyEnforcerTenants;
    private final long readTimeout;

    public PolicyEnforcerResolver(PolicyEnforcer defaultPolicyEnforcer,
            Map policyEnforcerTenants,
            final long readTimeout) {
        this.defaultPolicyEnforcer = defaultPolicyEnforcer;
        this.policyEnforcerTenants = policyEnforcerTenants;
        this.readTimeout = readTimeout;
    }

    public PolicyEnforcer getPolicyEnforcer(String tenantId) {
        return tenantId != null && policyEnforcerTenants.containsKey(tenantId)
                ? policyEnforcerTenants.get(tenantId)
                : defaultPolicyEnforcer;
    }

    public long getReadTimeout() {
        return readTimeout;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy