Search in sources :

Example 6 with ResourceDescriptor

use of org.apache.knox.gateway.descriptor.ResourceDescriptor in project knox by apache.

the class GatewayDescriptorImpl method addResource.

@Override
public ResourceDescriptor addResource() {
    ResourceDescriptor resource = createResource();
    addResource(resource);
    return resource;
}
Also used : ResourceDescriptor(org.apache.knox.gateway.descriptor.ResourceDescriptor)

Example 7 with ResourceDescriptor

use of org.apache.knox.gateway.descriptor.ResourceDescriptor in project knox by apache.

the class TestServiceDeploymentContributor method contributeService.

@Override
public void contributeService(DeploymentContext context, Service service) throws Exception {
    ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
    resource.role(service.getRole());
    resource.pattern("test-service-path/**?**");
    addAuthenticationFilter(context, service, resource);
    addIdentityAssertionFilter(context, service, resource);
    addAuthorizationFilter(context, service, resource);
    // addRewriteFilter( context, service, resource, null ); // This shouldn't be included for in-processes services.
    context.contributeFilter(service, resource, "test-provider-role", "test-provider-name", null);
}
Also used : ResourceDescriptor(org.apache.knox.gateway.descriptor.ResourceDescriptor)

Example 8 with ResourceDescriptor

use of org.apache.knox.gateway.descriptor.ResourceDescriptor in project knox by apache.

the class ServiceTestDeploymentContributor method contributeService.

@Override
public void contributeService(DeploymentContext context, Service service) throws Exception {
    String packages = StringUtils.join(getPackages(), ";");
    for (String pattern : getPatterns()) {
        ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
        resource.role(service.getRole());
        resource.pattern(pattern);
        addXForwardedFilter(context, service, resource);
        // addAuthenticationFilter(context, service, resource);
        // addIdentityAssertionFilter(context, service, resource);
        // addAuthorizationFilter(context, service, resource);
        // addRewriteFilter( context, service, resource, null );
        List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
        FilterParamDescriptor param = resource.createFilterParam();
        param.name(PACKAGES_PARAM);
        param.value(packages);
        params.add(param);
        FilterParamDescriptor traceType = resource.createFilterParam();
        traceType.name("jersey.config.server.tracing");
        traceType.value("ALL");
        params.add(traceType);
        FilterParamDescriptor traceLevel = resource.createFilterParam();
        traceLevel.name("jersey.config.server.tracing.threshold");
        traceLevel.value("VERBOSE");
        params.add(traceLevel);
        context.contributeFilter(service, resource, "pivot", "jersey", params);
        context.contributeFilter(service, resource, "pivot", "jersey", params);
    }
}
Also used : FilterParamDescriptor(org.apache.knox.gateway.descriptor.FilterParamDescriptor) ArrayList(java.util.ArrayList) ResourceDescriptor(org.apache.knox.gateway.descriptor.ResourceDescriptor)

Example 9 with ResourceDescriptor

use of org.apache.knox.gateway.descriptor.ResourceDescriptor in project knox by apache.

the class TGSDeploymentContributor method contributeService.

@Override
public void contributeService(DeploymentContext context, Service service) throws URISyntaxException {
    ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
    resource.role(service.getRole());
    resource.pattern(TGS_EXTERNAL_PATH + "/accesstoken");
    if (topologyContainsProviderType(context, "authentication")) {
        context.contributeFilter(service, resource, "authentication", null, null);
    }
    if (topologyContainsProviderType(context, "federation")) {
        context.contributeFilter(service, resource, "federation", null, null);
    }
    context.contributeFilter(service, resource, "identity-assertion", null, null);
}
Also used : ResourceDescriptor(org.apache.knox.gateway.descriptor.ResourceDescriptor)

Example 10 with ResourceDescriptor

use of org.apache.knox.gateway.descriptor.ResourceDescriptor in project knox by apache.

the class ApplicationDeploymentContributor method contributeResource.

private void contributeResource(DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException {
    List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
    ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
    resource.role(service.getRole());
    resource.pattern(binding.getPath());
    // add x-forwarded filter if enabled in config
    if (context.getGatewayConfig().isXForwardedEnabled()) {
        resource.addFilter().name(XFORWARDED_FILTER_NAME).role(XFORWARDED_FILTER_ROLE).impl(XForwardedHeaderFilter.class);
    }
    if (context.getGatewayConfig().isCookieScopingToPathEnabled()) {
        FilterDescriptor filter = resource.addFilter().name(COOKIE_SCOPING_FILTER_NAME).role(COOKIE_SCOPING_FILTER_ROLE).impl(CookieScopeServletFilter.class);
        filter.param().name(GatewayConfigImpl.HTTP_PATH).value(context.getGatewayConfig().getGatewayPath());
    }
    List<Policy> policyBindings = binding.getPolicies();
    if (policyBindings == null) {
        policyBindings = serviceDefinition.getPolicies();
    }
    if (policyBindings == null) {
        // add default set
        addDefaultPolicies(context, service, filterParams, params, resource);
    } else {
        addPolicies(context, service, filterParams, params, resource, policyBindings);
    }
}
Also used : Policy(org.apache.knox.gateway.service.definition.Policy) FilterDescriptor(org.apache.knox.gateway.descriptor.FilterDescriptor) FilterParamDescriptor(org.apache.knox.gateway.descriptor.FilterParamDescriptor) ArrayList(java.util.ArrayList) ResourceDescriptor(org.apache.knox.gateway.descriptor.ResourceDescriptor)

Aggregations

ResourceDescriptor (org.apache.knox.gateway.descriptor.ResourceDescriptor)14 FilterParamDescriptor (org.apache.knox.gateway.descriptor.FilterParamDescriptor)9 FilterDescriptor (org.apache.knox.gateway.descriptor.FilterDescriptor)6 ArrayList (java.util.ArrayList)5 GatewayDescriptor (org.apache.knox.gateway.descriptor.GatewayDescriptor)4 Test (org.junit.Test)4 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 HashMap (java.util.HashMap)2 DeploymentContext (org.apache.knox.gateway.deploy.DeploymentContext)2 Policy (org.apache.knox.gateway.service.definition.Policy)2 Provider (org.apache.knox.gateway.topology.Provider)2 Service (org.apache.knox.gateway.topology.Service)2 Topology (org.apache.knox.gateway.topology.Topology)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1