summaryrefslogtreecommitdiffstats
path: root/zookeeper-common
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-12-17 12:45:29 +0100
committerjonmv <venstad@gmail.com>2023-12-17 12:45:29 +0100
commit5eb199b2b5670458324c4e6073a5a810bee33364 (patch)
treecaf488f7fe3c1d0c4062248d394547384d8ab21c /zookeeper-common
parentf9c603a4bb98169c29372e93ebaf8203deb24089 (diff)
Revert "Merge pull request #29683 from vespa-engine/revert-29678-jonmv/reapply-zk-3.9.1"
This reverts commit c8ece8b229362c7bf725e4433ef4fec86024cd29, reversing changes made to d42b67f0fe821d122548a345f27fda7f9c9c9d10.
Diffstat (limited to 'zookeeper-common')
-rw-r--r--zookeeper-common/OWNERS1
-rw-r--r--zookeeper-common/README.md4
-rw-r--r--zookeeper-common/pom.xml51
-rw-r--r--zookeeper-common/src/main/java/com/yahoo/vespa/zookeeper/tls/VespaZookeeperTlsContextUtils.java26
4 files changed, 82 insertions, 0 deletions
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 @@
+<!-- Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+# 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 @@
+<?xml version="1.0"?>
+<!-- Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>parent</artifactId>
+ <version>8-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>zookeeper-common</artifactId>
+ <packaging>jar</packaging>
+ <version>8-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>security-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>defaults</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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> tlsContext() {
+ return Optional.ofNullable(tlsContext);
+ }
+
+}