aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-09-10 13:39:32 +0200
committerBjørn Christian Seime <bjorncs@oath.com>2018-09-12 10:49:39 +0200
commit81741cbe24b6f4e45091da4f4add4ee5195970d8 (patch)
tree08648b7e0948cb0460ee44801de80bd61100c78c /config-model
parent74a2ba02e99956a9f033beaed7fb3365eb67a4ad (diff)
Inject ThrowingSslContextFactoryProvider for non-ssl connectors
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/http/ConnectorFactory.java9
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/http/ssl/DummySslProvider.java30
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/JettyConnectorBuilder.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java4
4 files changed, 40 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/ConnectorFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/ConnectorFactory.java
index 8e4288d5f5e..8bfd0b1e4da 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/ConnectorFactory.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/ConnectorFactory.java
@@ -9,6 +9,7 @@ import com.yahoo.jdisc.http.ssl.DefaultSslTrustStoreConfigurator;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.text.XML;
import com.yahoo.vespa.model.container.component.SimpleComponent;
+import com.yahoo.vespa.model.container.http.ssl.DummySslProvider;
import org.w3c.dom.Element;
import java.util.Optional;
@@ -28,7 +29,7 @@ public class ConnectorFactory extends SimpleComponent implements ConnectorConfig
private final Element legacyConfig;
public ConnectorFactory(String name, int listenPort) {
- this(name, listenPort, null, null, null, null);
+ this(name, listenPort, null, null, null, new DummySslProvider(name));
}
public ConnectorFactory(String name,
@@ -44,10 +45,8 @@ public class ConnectorFactory extends SimpleComponent implements ConnectorConfig
this.name = name;
this.listenPort = listenPort;
this.legacyConfig = legacyConfig;
- Optional.ofNullable(sslProviderComponent).ifPresent(component -> {
- addChild(component);
- inject(component);
- });
+ addChild(sslProviderComponent);
+ inject(sslProviderComponent);
addSslKeyStoreConfigurator(name, sslKeystoreConfigurator);
addSslTrustStoreConfigurator(name, sslTruststoreConfigurator);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/ssl/DummySslProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/ssl/DummySslProvider.java
new file mode 100644
index 00000000000..e1cefbf675f
--- /dev/null
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/ssl/DummySslProvider.java
@@ -0,0 +1,30 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.model.container.http.ssl;
+
+import com.yahoo.component.ComponentId;
+import com.yahoo.container.bundle.BundleInstantiationSpecification;
+import com.yahoo.jdisc.http.ConnectorConfig;
+import com.yahoo.osgi.provider.model.ComponentModel;
+import com.yahoo.vespa.model.container.component.SimpleComponent;
+
+import static com.yahoo.component.ComponentSpecification.fromString;
+
+/**
+ * @author bjorncs
+ */
+public class DummySslProvider extends SimpleComponent implements ConnectorConfig.Producer {
+
+ public static final String COMPONENT_ID_PREFIX = "dummy-ssl-provider@";
+ public static final String COMPONENT_CLASS = "com.yahoo.jdisc.http.ssl.ThrowingSslContextFactoryProvider";
+ public static final String COMPONENT_BUNDLE = "jdisc_http_service";
+
+ public DummySslProvider(String serverName) {
+ super(new ComponentModel(
+ new BundleInstantiationSpecification(new ComponentId(COMPONENT_ID_PREFIX + serverName),
+ fromString(COMPONENT_CLASS),
+ fromString(COMPONENT_BUNDLE))));
+ }
+
+ @Override
+ public void getConfig(ConnectorConfig.Builder builder) {}
+}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/JettyConnectorBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/JettyConnectorBuilder.java
index 5c15c9bfe7d..4ab70b05a54 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/JettyConnectorBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/JettyConnectorBuilder.java
@@ -9,6 +9,7 @@ import com.yahoo.vespa.model.container.component.SimpleComponent;
import com.yahoo.vespa.model.container.http.ConnectorFactory;
import com.yahoo.vespa.model.container.http.ssl.CustomSslProvider;
import com.yahoo.vespa.model.container.http.ssl.DefaultSslProvider;
+import com.yahoo.vespa.model.container.http.ssl.DummySslProvider;
import org.w3c.dom.Element;
import java.util.Optional;
@@ -62,8 +63,9 @@ public class JettyConnectorBuilder extends VespaDomBuilder.DomConfigProducerBuil
String className = sslProviderConfigurator.getAttribute("class");
String bundle = sslProviderConfigurator.getAttribute("bundle");
return new CustomSslProvider(id, className, bundle);
+ } else {
+ // No ssl config..
+ return new DummySslProvider(serverName);
}
- // No ssl config..
- return null;
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
index 4f51d4cca7e..71e0deeb9b0 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
@@ -214,7 +214,7 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
List<ConnectorFactory> connectorFactories = cluster.getChildrenByTypeRecursive(ConnectorFactory.class);
{
ConnectorFactory firstConnector = connectorFactories.get(0);
- assertConnectorHasInjectedComponents(firstConnector, "ssl-keystore-configurator@foo", "ssl-truststore-configurator@foo");
+ assertConnectorHasInjectedComponents(firstConnector, "ssl-keystore-configurator@foo", "ssl-truststore-configurator@foo", "dummy-ssl-provider@foo");
assertComponentHasClassNameAndBundle(getChildComponent(firstConnector, 0),
"com.yahoo.MySslKeyStoreConfigurator",
"mybundle");
@@ -224,7 +224,7 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
}
{
ConnectorFactory secondConnector = connectorFactories.get(1);
- assertConnectorHasInjectedComponents(secondConnector, "ssl-keystore-configurator@bar", "ssl-truststore-configurator@bar");
+ assertConnectorHasInjectedComponents(secondConnector, "ssl-keystore-configurator@bar", "ssl-truststore-configurator@bar", "dummy-ssl-provider@bar");
assertComponentHasClassNameAndBundle(getChildComponent(secondConnector, 0),
DefaultSslKeyStoreConfigurator.class.getName(),
"jdisc_http_service");