diff --git a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
index 9ba18fa8c..061590e6b 100644
--- a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
+++ b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java
@@ -1,21 +1,24 @@
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.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 properties file {@value PROP_FILENAME} from an OS-dependent location and add all supported properties to the {@link System} properties.
+ * To overwrite system properties, the method {@link #adjustSystemProperties()} loads the JSON file {@value CONFIG_NAME} from an OS-dependent location and add all supported properties to the {@link System} properties.
* The predefined location are:
*
*
Linux - {@value LINUX_DIR }
@@ -37,12 +40,12 @@ import java.util.Set;
*/
class AdminPropertiesSetter {
- private static final Logger LOG = LoggerFactory.getLogger(AdminPropertiesSetter.class);
+ private static final ObjectMapper JSON = JsonMapper.builder().build();
private static final String LINUX_DIR = "/etc/cryptmator";
private static final String MAC_DIR = "/Library/Application Support/Cryptomator";
private static final String WIN_DIR = "%PROGRAMDATA%\\Cryptomator";
- private static final String PROP_FILENAME = "config.properties";
+ private static final String CONFIG_NAME = "config.json";
private static final Set ALLOWED_OVERRIDES = Set.of( //
"cryptomator.logDir", //
"cryptomator.pluginDir", //
@@ -60,7 +63,7 @@ class AdminPropertiesSetter {
} else { //LINUX
adminDir = Path.of(LINUX_DIR);
}
- ADMIN_PROPERTIES_FILE = adminDir.resolve(PROP_FILENAME);
+ ADMIN_PROPERTIES_FILE = adminDir.resolve(CONFIG_NAME);
}
private static final Path ADMIN_PROPERTIES_FILE;
@@ -77,29 +80,34 @@ class AdminPropertiesSetter {
var systemProps = System.getProperties();
var adminProps = loadAdminProperties(ADMIN_PROPERTIES_FILE);
- 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);
+ 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);
} else {
- LOG.debug("Property {} in admin properties is not supported for override.", key);
+ var reason = value instanceof String ? "Unsupported" : "Not a string";
+ log("Property {} in admin config ignored: {}.", List.of(key, reason));
}
- }
+ });
return systemProps;
}
- private static Properties loadAdminProperties(Path adminPropertiesPath) {
- var adminProps = new Properties();
- try {
- adminProps.load(Files.newInputStream(adminPropertiesPath, StandardOpenOption.READ));
+ private static Map loadAdminProperties(Path adminPropertiesPath) {
+ try (var in = Files.newInputStream(adminPropertiesPath, StandardOpenOption.READ)) {
+ var map = JSON.readValue(in, new TypeReference