use of com.yahoo.vespa.model.container.http.AccessControl 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.AccessControl in project vespa by vespa-engine.
the class AccessControlTest method properties_are_set_from_xml.
@Test
public void properties_are_set_from_xml() throws Exception {
Element clusterElem = DomBuilderTest.parse(" <http>", " <filtering>", " <access-control domain='my-domain'>", " <application>my-app</application>", " <vespa-domain>custom-vespa-domain</vespa-domain>", " </access-control>", " </filtering>", " </http>");
Http http = new HttpBuilder().build(root, clusterElem);
root.freezeModelTopology();
AccessControl accessControl = http.getAccessControl().get();
assertEquals("Wrong domain.", "my-domain", accessControl.domain);
assertEquals("Wrong application.", "my-app", accessControl.applicationId);
assertEquals("Wrong vespa-domain.", "custom-vespa-domain", accessControl.vespaDomain.get());
}
use of com.yahoo.vespa.model.container.http.AccessControl in project vespa by vespa-engine.
the class HttpBuilder method buildAccessControl.
private AccessControl buildAccessControl(AbstractConfigProducer ancestor, Element accessControlElem) {
String application = XmlHelper.getOptionalChildValue(accessControlElem, "application").orElse(getDeployedApplicationId(ancestor).value());
AccessControl.Builder builder = new AccessControl.Builder(accessControlElem.getAttribute("domain"), application);
getContainerCluster(ancestor).ifPresent(cluster -> {
builder.setHandlers(cluster.getHandlers());
builder.setServlets(cluster.getAllServlets());
});
XmlHelper.getOptionalAttribute(accessControlElem, "read").ifPresent(readAttr -> builder.readEnabled(Boolean.valueOf(readAttr)));
XmlHelper.getOptionalAttribute(accessControlElem, "write").ifPresent(writeAttr -> builder.writeEnabled(Boolean.valueOf(writeAttr)));
Element excludeElem = XML.getChild(accessControlElem, "exclude");
if (excludeElem != null) {
XML.getChildren(excludeElem, "binding").stream().map(XML::getValue).forEach(builder::excludeBinding);
}
XmlHelper.getOptionalChildValue(accessControlElem, "vespa-domain").ifPresent(builder::vespaDomain);
return builder.build();
}
Aggregations