use of com.yahoo.vespa.model.container.http.Http.Binding in project vespa by vespa-engine.
the class HttpBuilder method doBuild.
@Override
protected Http doBuild(AbstractConfigProducer ancestor, Element spec) {
FilterChains filterChains;
List<Binding> bindings = new ArrayList<>();
AccessControl accessControl = null;
Element filteringElem = XML.getChild(spec, "filtering");
if (filteringElem != null) {
filterChains = new FilterChainsBuilder().build(ancestor, filteringElem);
bindings = readFilterBindings(filteringElem);
Element accessControlElem = XML.getChild(filteringElem, "access-control");
if (accessControlElem != null) {
accessControl = buildAccessControl(ancestor, accessControlElem);
bindings.addAll(accessControl.getBindings());
filterChains.add(new Chain<>(FilterChains.emptyChainSpec(ACCESS_CONTROL_CHAIN_ID)));
}
} else {
filterChains = new FilterChainsBuilder().newChainsInstance(ancestor);
}
Http http = new Http(bindings, accessControl);
http.setFilterChains(filterChains);
buildHttpServers(ancestor, http, spec);
return http;
}
use of com.yahoo.vespa.model.container.http.Http.Binding in project vespa by vespa-engine.
the class HttpBuilder method readFilterBindings.
private List<Binding> readFilterBindings(Element filteringSpec) {
List<Binding> result = new ArrayList<>();
for (Element child : XML.getChildren(filteringSpec)) {
String tagName = child.getTagName();
if ((tagName.equals("request-chain") || tagName.equals("response-chain"))) {
ComponentSpecification chainId = XmlHelper.getIdRef(child);
for (Element bindingSpec : XML.getChildren(child, "binding")) {
String binding = XML.getValue(bindingSpec);
result.add(new Binding(chainId, binding));
}
}
}
return result;
}
use of com.yahoo.vespa.model.container.http.Http.Binding in project vespa by vespa-engine.
the class AccessControlTest method access_control_filter_chain_has_correct_handler_bindings.
@Test
public void access_control_filter_chain_has_correct_handler_bindings() throws Exception {
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", " <search/>", " <document-api/>", " <handler id='custom.Handler'>", " <binding>http://*/custom-handler/*</binding>", " </handler>", " <http>", " <filtering>", " <access-control domain='foo' />", " </filtering>", " </http>", "</jdisc>");
Http http = getHttp(clusterElem);
Set<String> foundRequiredBindings = REQUIRED_HANDLER_BINDINGS.stream().filter(requiredBinding -> containsBinding(http.getBindings(), requiredBinding)).collect(Collectors.toSet());
Set<String> missingRequiredBindings = new HashSet<>(REQUIRED_HANDLER_BINDINGS);
missingRequiredBindings.removeAll(foundRequiredBindings);
assertTrue("Access control chain was not bound to: " + CollectionUtil.mkString(missingRequiredBindings, ", "), missingRequiredBindings.isEmpty());
FORBIDDEN_HANDLER_BINDINGS.forEach(forbiddenBinding -> http.getBindings().forEach(binding -> assertFalse("Access control chain was bound to: " + binding.binding, binding.binding.contains(forbiddenBinding))));
}
Aggregations