use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class PluginOperation method getRemotePluginInfo.
private PluginInfo getRemotePluginInfo(String pluginId) throws Exception {
String remoteListStr = getRemoteListStr(pluginId);
PluginListResponse pluginListResponse = new Persister().read(PluginListResponse.class, remoteListStr);
if (pluginListResponse.getPlugins().size() > 0) {
return pluginListResponse.getPlugins().get(0);
} else {
return null;
}
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class ConfigTO method save.
public void save(File file) throws ConfigException {
try {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
registry.bind(SaltedSecretKey.class, new SaltedSecretKeyConverter());
registry.bind(String.class, new EncryptedTransferSettingsConverter(transferSettings.getClass()));
new Persister(strategy).write(this, file);
} catch (Exception e) {
throw new ConfigException("Cannot write config to file " + file, e);
}
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class RepoTO method save.
public void save(File file, List<CipherSpec> cipherSpecs, SaltedSecretKey masterKey) throws ConfigException {
try {
ByteArrayOutputStream plaintextRepoOutputStream = new ByteArrayOutputStream();
Serializer serializer = new Persister();
serializer.write(this, plaintextRepoOutputStream);
CipherUtil.encrypt(new ByteArrayInputStream(plaintextRepoOutputStream.toByteArray()), new FileOutputStream(file), cipherSpecs, masterKey);
} catch (Exception e) {
throw new ConfigException("Cannot write repoTO (encrypted) to file " + file, e);
}
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class ConfigHelper method loadEncryptedRepoTO.
private static RepoTO loadEncryptedRepoTO(File repoFile, ConfigTO configTO) throws Exception {
logger.log(Level.INFO, "Loading encrypted repo file from {0} ...", repoFile);
SaltedSecretKey masterKey = configTO.getMasterKey();
if (masterKey == null) {
throw new ConfigException("Repo file is encrypted, but master key not set in config file.");
}
String repoFileStr = new String(CipherUtil.decrypt(new FileInputStream(repoFile), masterKey));
return new Persister().read(RepoTO.class, repoFileStr);
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class TestCliUtil method fixMachineName.
private static void fixMachineName(Map<String, String> client) throws Exception {
File configFile = new File(client.get("localdir") + "/" + Config.DIR_APPLICATION + "/" + Config.FILE_CONFIG);
Serializer serializer = new Persister();
ConfigTO configTO = serializer.read(ConfigTO.class, configFile);
configTO.setMachineName(client.get("machinename"));
serializer.write(configTO, configFile);
}
Aggregations