From c198adaf3f99c898c63c110f82a30907a9de716f Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Wed, 21 Jan 2026 11:53:31 +0100
Subject: [PATCH] switch back to properties
---
.../launcher/AdminPropertiesSetter.java | 69 ++++++++-----------
1 file changed, 30 insertions(+), 39 deletions(-)
diff --git a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
index 12d1c50da..69121cd6e 100644
--- a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
+++ b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
@@ -1,30 +1,27 @@
package org.cryptomator.launcher;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.json.JsonMapper;
import org.apache.commons.lang3.SystemUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
-import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* Class to overwrite system properties with an external properties file
*
- * To overwrite system properties, the method {@link #adjustSystemProperties()} loads the JSON file {@value CONFIG_NAME} from an OS-dependent location and adds all whitelisted properties to the {@link System} properties.
- * The predefined locations are:
- *
- *
Linux - {@value LINUX_DIR }
- *
macOS - {@value MAC_DIR }
- *
Windows - {@value WIN_DIR }
- *
+ * To overwrite system properties, the method {@link #adjustSystemProperties()} loads the properties file {@value CONFIG_NAME} from an OS-dependent location and adds all supported properties to the {@link System} properties.
+ * The predefined location is for
+ *
+ *
Linux: {@value LINUX_DIR }
+ *
macOS: {@value MAC_DIR }
+ *
Windows: {@value WIN_DIR }
+ *
*
*
* The overridable properties are:
@@ -40,12 +37,12 @@ import java.util.Set;
*/
class AdminPropertiesSetter {
- private static final ObjectMapper JSON = JsonMapper.builder().build();
+ private static final Logger LOG = LoggerFactory.getLogger(AdminPropertiesSetter.class);
private static final String LINUX_DIR = "/etc/cryptomator";
private static final String MAC_DIR = "/Library/Application Support/Cryptomator";
- private static final String WIN_DIR = "%PROGRAMDATA%\\Cryptomator";
- private static final String CONFIG_NAME = "config.json";
+ private static final String WIN_DIR = "C:\\ProgramData\\Cryptomator";
+ private static final String CONFIG_NAME = "config.properties";
private static final Set ALLOWED_OVERRIDES = Set.of( //
"cryptomator.logDir", //
"cryptomator.pluginDir", //
@@ -57,7 +54,7 @@ class AdminPropertiesSetter {
static {
final Path adminDir;
if (SystemUtils.IS_OS_WINDOWS) {
- adminDir = Path.of(System.getenv().getOrDefault("ProgramData", "C:\\ProgramData"), "Cryptomator");
+ adminDir = Path.of(WIN_DIR);
} else if (SystemUtils.IS_OS_MAC) {
adminDir = Path.of(MAC_DIR);
} else { //LINUX
@@ -71,7 +68,7 @@ class AdminPropertiesSetter {
/**
* Adjusts the system properties by loading administrative properties from a predefined file location.
*
- * If the file exists and is a valid JSON file, its content will overwrite existing system properties.
+ * If the file exists and is a valid properties file, its content will overwrite existing system properties.
* Only some properties can be overridden, see {@link AdminPropertiesSetter}
*
* @return The adjusted system properties.
@@ -80,35 +77,29 @@ class AdminPropertiesSetter {
var systemProps = System.getProperties();
var adminProps = loadAdminProperties(ADMIN_PROPERTIES_FILE);
- adminProps.forEach((key, value) -> {
- if (ALLOWED_OVERRIDES.contains(key) && value instanceof String v) {
- log("Overwriting {} with value {} from admin properties.", List.of(key, v));
- systemProps.setProperty(key, v);
+ for (var key : adminProps.stringPropertyNames()) {
+ if (ALLOWED_OVERRIDES.contains(key)) {
+ var value = adminProps.getProperty(key);
+ LOG.info("Overwriting {} with value {} from admin properties.", key, value);
+ systemProps.setProperty(key, value);
} else {
- var reason = value instanceof String ? "Unsupported" : "Not a string";
- log("Property {} in admin config ignored: {}.", List.of(key, reason));
+ LOG.debug("Property {} in admin properties is not supported for override.", key);
}
- });
+ }
return systemProps;
}
- static Map loadAdminProperties(Path adminPropertiesPath) {
- try (var in = Files.newInputStream(adminPropertiesPath, StandardOpenOption.READ)) {
- var map = JSON.readValue(in, new TypeReference