From 21ce1b6512aecdf1f74dd1570840243cbff90ea8 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 14 Dec 2023 18:56:52 +0100 Subject: Revert "Revert "Jonmv/zk 3.9.1 clients 2"" --- zookeeper-common/OWNERS | 1 + zookeeper-common/README.md | 4 ++ zookeeper-common/pom.xml | 51 ++++++++++++++++++++++ .../tls/VespaZookeeperTlsContextUtils.java | 26 +++++++++++ 4 files changed, 82 insertions(+) create mode 100644 zookeeper-common/OWNERS create mode 100644 zookeeper-common/README.md create mode 100644 zookeeper-common/pom.xml create mode 100644 zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java (limited to 'zookeeper-common') diff --git a/zookeeper-common/OWNERS b/zookeeper-common/OWNERS new file mode 100644 index 00000000000..d0a102ecbf4 --- /dev/null +++ b/zookeeper-common/OWNERS @@ -0,0 +1 @@ +jonmv diff --git a/zookeeper-common/README.md b/zookeeper-common/README.md new file mode 100644 index 00000000000..f0c7cee342d --- /dev/null +++ b/zookeeper-common/README.md @@ -0,0 +1,4 @@ + +# zookeeper-common + +Shared configuration logic for ZooKeeper diff --git a/zookeeper-common/pom.xml b/zookeeper-common/pom.xml new file mode 100644 index 00000000000..2c8ed8fe476 --- /dev/null +++ b/zookeeper-common/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + com.yahoo.vespa + parent + 8-SNAPSHOT + ../parent/pom.xml + + zookeeper-common + jar + 8-SNAPSHOT + + + + + com.yahoo.vespa + security-utils + ${project.version} + provided + + + + com.yahoo.vespa + defaults + ${project.version} + provided + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + diff --git a/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java b/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java new file mode 100644 index 00000000000..78de6c61e17 --- /dev/null +++ b/zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java @@ -0,0 +1,26 @@ +package com.yahoo.vespa.zookeeper.tls; + +import com.yahoo.security.tls.ConfigFileBasedTlsContext; +import com.yahoo.security.tls.TlsContext; +import com.yahoo.security.tls.TransportSecurityUtils; +import com.yahoo.vespa.defaults.Defaults; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + +/** + * @author jonmv + */ +public class VespaZookeeperTlsContextUtils { + + private static final Path ZOOKEEPER_TLS_CONFIG_FILE = Path.of(Defaults.getDefaults().underVespaHome("var/zookeeper/conf/tls.conf.json")); + private static final TlsContext tlsContext = Files.exists(ZOOKEEPER_TLS_CONFIG_FILE) + ? new ConfigFileBasedTlsContext(ZOOKEEPER_TLS_CONFIG_FILE, TransportSecurityUtils.getInsecureAuthorizationMode()) + : TransportSecurityUtils.getSystemTlsContext().orElse(null); + + public static Optional tlsContext() { + return Optional.ofNullable(tlsContext); + } + +} -- cgit v1.2.3