io.quarkus.keycloak.pep.runtime.PolicyEnforcerResolver Maven / Gradle / Ivy
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;
}
}