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: - *
* 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
- * 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