Search in sources :

Example 1 with PolicyChainResolver

use of io.gravitee.gateway.policy.PolicyChainResolver in project gravitee-gateway by gravitee-io.

the class ApiReactorHandler method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    contextPath = reactable().contextPath() + '/';
    apiPolicyResolver = new ApiPolicyChainResolver();
    PolicyChainResolver securityPolicyResolver = new SecurityPolicyChainResolver();
    PolicyChainResolver planPolicyResolver = new PlanPolicyChainResolver();
    policyResolvers = new ArrayList<PolicyChainResolver>() {

        {
            applicationContext.getAutowireCapableBeanFactory().autowireBean(securityPolicyResolver);
            applicationContext.getAutowireCapableBeanFactory().autowireBean(planPolicyResolver);
            applicationContext.getAutowireCapableBeanFactory().autowireBean(apiPolicyResolver);
            add(securityPolicyResolver);
            add(planPolicyResolver);
            add(apiPolicyResolver);
        }
    };
}
Also used : PlanPolicyChainResolver(io.gravitee.gateway.handlers.api.policy.plan.PlanPolicyChainResolver) PolicyChainResolver(io.gravitee.gateway.policy.PolicyChainResolver) PlanPolicyChainResolver(io.gravitee.gateway.handlers.api.policy.plan.PlanPolicyChainResolver) SecurityPolicyChainResolver(io.gravitee.gateway.security.core.SecurityPolicyChainResolver) ApiPolicyChainResolver(io.gravitee.gateway.handlers.api.policy.api.ApiPolicyChainResolver) ApiPolicyChainResolver(io.gravitee.gateway.handlers.api.policy.api.ApiPolicyChainResolver) SecurityPolicyChainResolver(io.gravitee.gateway.security.core.SecurityPolicyChainResolver)

Example 2 with PolicyChainResolver

use of io.gravitee.gateway.policy.PolicyChainResolver in project gravitee-gateway by gravitee-io.

the class RequestPolicyChainProcessor method execute.

public void execute(Request request, Response response, ExecutionContext executionContext) {
    if (iterator.hasNext()) {
        PolicyChainResolver policyChainResolver = iterator.next();
        PolicyChain policyChain = policyChainResolver.resolve(StreamType.ON_REQUEST, request, response, executionContext);
        lastPolicyChain = policyChain;
        policyChain.setResultHandler(policyResult -> {
            if (!policyResult.isFailure()) {
                execute(request, response, executionContext);
            } else {
                resultHandler.handle(new PolicyChainResult(lastPolicyChain, policyResult));
            }
        });
        policyChain.setStreamErrorHandler(result -> streamErrorHandler.handle(new PolicyChainResult(lastPolicyChain, result)));
        policyChain.doNext(request, response);
    } else {
        resultHandler.handle(new PolicyChainResult(lastPolicyChain, null));
    }
}
Also used : PolicyChainResult(io.gravitee.gateway.policy.PolicyChainResult) PolicyChainResolver(io.gravitee.gateway.policy.PolicyChainResolver)

Aggregations

PolicyChainResolver (io.gravitee.gateway.policy.PolicyChainResolver)2 ApiPolicyChainResolver (io.gravitee.gateway.handlers.api.policy.api.ApiPolicyChainResolver)1 PlanPolicyChainResolver (io.gravitee.gateway.handlers.api.policy.plan.PlanPolicyChainResolver)1 PolicyChainResult (io.gravitee.gateway.policy.PolicyChainResult)1 SecurityPolicyChainResolver (io.gravitee.gateway.security.core.SecurityPolicyChainResolver)1