use of org.syncany.config.to.UserConfigTO in project syncany by syncany.
the class UserConfig method loadAndInitUserConfigFile.
private static void loadAndInitUserConfigFile(File userConfigFile) {
try {
UserConfigTO userConfigTO = UserConfigTO.load(userConfigFile);
// System properties
for (Map.Entry<String, String> systemProperty : userConfigTO.getSystemProperties().entrySet()) {
String propertyValue = (systemProperty.getValue() != null) ? systemProperty.getValue() : "";
System.setProperty(systemProperty.getKey(), propertyValue);
}
// Other options
preventStandby = userConfigTO.isPreventStandby();
configEncryptionKey = userConfigTO.getConfigEncryptionKey();
} catch (ConfigException e) {
System.err.println("ERROR: " + e.getMessage());
System.err.println(" Ignoring user config file!");
System.err.println();
}
}
use of org.syncany.config.to.UserConfigTO in project syncany by syncany.
the class UserConfig method writeExampleUserConfigFile.
private static void writeExampleUserConfigFile(File userConfigFile) {
UserConfigTO userConfigTO = new UserConfigTO();
try {
System.out.println("First launch, creating a secret key (could take a sec)...");
SaltedSecretKey configEncryptionKey = CipherUtil.createMasterKey(CipherUtil.createRandomAlphabeticString(USER_CONFIG_ENCRYPTION_KEY_LENGTH));
userConfigTO.setConfigEncryptionKey(configEncryptionKey);
userConfigTO.save(userConfigFile);
} catch (CipherException e) {
System.err.println("ERROR: " + e.getMessage());
System.err.println(" Failed to create masterkey.");
System.err.println();
} catch (ConfigException e) {
System.err.println("ERROR: " + e.getMessage());
System.err.println(" Failed to save to file.");
System.err.println();
}
}
Aggregations