Search in sources :

Example 1 with UserConfigTO

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();
    }
}
Also used : UserConfigTO(org.syncany.config.to.UserConfigTO) Map(java.util.Map)

Example 2 with UserConfigTO

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();
    }
}
Also used : SaltedSecretKey(org.syncany.crypto.SaltedSecretKey) CipherException(org.syncany.crypto.CipherException) UserConfigTO(org.syncany.config.to.UserConfigTO)

Aggregations

UserConfigTO (org.syncany.config.to.UserConfigTO)2 Map (java.util.Map)1 CipherException (org.syncany.crypto.CipherException)1 SaltedSecretKey (org.syncany.crypto.SaltedSecretKey)1