private static Element createResource( Document dom, ResourceDescriptor resource ) { Element element = dom.createElement( RESOURCE ); String role = resource.role(); if( role != null ) { addTextElement( dom, element, RESOURCE_ROLE, role ); } addTextElement( dom, element, RESOURCE_PATTERN, resource.pattern() ); //addTextElement( dom, element, RESOURCE_TARGET, resource.target() ); for( FilterDescriptor filter : resource.filters() ) { element.appendChild( createFilter( dom, filter ) ); } return element; }
private static Element createResource( Document dom, ResourceDescriptor resource ) { Element element = dom.createElement( RESOURCE ); String role = resource.role(); if( role != null ) { addTextElement( dom, element, RESOURCE_ROLE, role ); } addTextElement( dom, element, RESOURCE_PATTERN, resource.pattern() ); //addTextElement( dom, element, RESOURCE_TARGET, resource.target() ); for( FilterDescriptor filter : resource.filters() ) { element.appendChild( createFilter( dom, filter ) ); } return element; }
private static Map<String, String> createParams( FilterDescriptor filter ) { Map<String, String> paramMap = new HashMap<>(); ResourceDescriptor resource = filter.up(); GatewayDescriptor gateway = resource.up(); for( GatewayParamDescriptor param : gateway.params() ) { paramMap.put( param.name(), param.value() ); } for( ResourceParamDescriptor param : resource.params() ) { paramMap.put( param.name(), param.value() ); } //TODO: Should all elements of the resource and gateway descriptor somehow be added to the filter params? //TODO: Should we use some composite params object instead of copying all these name value pairs? paramMap.put( "pattern", resource.pattern() ); List<FilterParamDescriptor> paramList = filter.params(); for( FilterParamDescriptor param : paramList ) { paramMap.put( param.name(), param.value() ); } return paramMap; }
private static Map<String, String> createParams( FilterDescriptor filter ) { Map<String, String> paramMap = new HashMap<>(); ResourceDescriptor resource = filter.up(); GatewayDescriptor gateway = resource.up(); for( GatewayParamDescriptor param : gateway.params() ) { paramMap.put( param.name(), param.value() ); } for( ResourceParamDescriptor param : resource.params() ) { paramMap.put( param.name(), param.value() ); } //TODO: Should all elements of the resource and gateway descriptor somehow be added to the filter params? //TODO: Should we use some composite params object instead of copying all these name value pairs? paramMap.put( "pattern", resource.pattern() ); List<FilterParamDescriptor> paramList = filter.params(); for( FilterParamDescriptor param : paramList ) { paramMap.put( param.name(), param.value() ); } return paramMap; }
private static void addFilter( GatewayFilter gateway, FilterDescriptor filter ) throws URISyntaxException { String name = filter.name(); if( name == null ) { name = filter.role(); } gateway.addFilter( filter.up().pattern(), name, filter.impl(), createParams( filter ), filter.up().role() ); }
private static void addFilter( GatewayFilter gateway, FilterDescriptor filter ) throws URISyntaxException { String name = filter.name(); if( name == null ) { name = filter.role(); } gateway.addFilter( filter.up().pattern(), name, filter.impl(), createParams( filter ), filter.up().role() ); }
@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 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); } } }
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 ); addWebAppSecFilters( context, service, resource ); 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 param = resource.createFilterParam(); param.name( PACKAGES_PARAM ); param.value( packages ); params.add( param ); // FilterParamDescriptor trace = resource.createFilterParam(); // param.name( TRACE_LOGGING_PARAM ); // param.value( "ALL" ); // params.add( trace ); for ( Map.Entry<String,String> serviceParam : service.getParams().entrySet() ) { context.getWebAppDescriptor().createContextParam().paramName(serviceParam.getKey()).paramValue(serviceParam.getValue()); } context.contributeFilter( service, resource, "pivot", "jersey", params ); } } }
@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 ); addWebAppSecFilters( context, service, resource ); 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 param = resource.createFilterParam(); param.name( PACKAGES_PARAM ); param.value( packages ); params.add( param ); // FilterParamDescriptor trace = resource.createFilterParam(); // param.name( TRACE_LOGGING_PARAM ); // param.value( "ALL" ); // params.add( trace ); for ( Map.Entry<String,String> serviceParam : service.getParams().entrySet() ) { context.getWebAppDescriptor().createContextParam().paramName(serviceParam.getKey()).paramValue(serviceParam.getValue()); } context.contributeFilter( service, resource, "pivot", "jersey", params ); } } }
@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 ); }
@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 ); }
@Override public void contributeService( DeploymentContext context, Service service ) throws URISyntaxException { ResourceDescriptor resource = context.getGatewayDescriptor().addResource(); resource.role( service.getRole() ); resource.pattern( AS_EXTERNAL_PATH + "/authenticate"); 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 ); }
@Override public void contributeService( DeploymentContext context, Service service ) throws URISyntaxException { ResourceDescriptor resource = context.getGatewayDescriptor().addResource(); resource.role( service.getRole() ); resource.pattern( AS_EXTERNAL_PATH + "/authenticate"); 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 ); }
private void contributeResource( DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException { List<FilterParamDescriptor> params = new ArrayList<>(); 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); } }
private void contributeResource(DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException { List<FilterParamDescriptor> params = new ArrayList<>(); 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); } addDispatchFilter(context, service, resource, binding); }
private void contributeResource( DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException { List<FilterParamDescriptor> params = new ArrayList<>(); 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); } }
private void contributeResource(DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException { List<FilterParamDescriptor> params = new ArrayList<>(); 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()); filter.param().name("topologyName").value(context.getTopology().getName()); } 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); } addDispatchFilter(context, service, resource, binding); }