use of i2p.bote.fileencryption.EncryptedOutputStream in project i2p.i2p-bote by i2p.
the class Identities method save.
/**
* Saves all identities to file.
*/
public void save() throws IOException, GeneralSecurityException, PasswordException {
initializeIfNeeded();
OutputStream encryptedStream = new EncryptedOutputStream(new SecureFileOutputStream(identitiesFile), passwordHolder);
try {
Properties properties = saveToProperties();
properties.store(new OutputStreamWriter(encryptedStream, "UTF-8"), null);
} catch (IOException e) {
log.error("Can't save email identities to file <" + identitiesFile.getAbsolutePath() + ">.", e);
throw e;
} finally {
encryptedStream.close();
}
}
use of i2p.bote.fileencryption.EncryptedOutputStream in project i2p.i2p-bote by i2p.
the class ExportableData method export.
public void export(OutputStream exportStream, String password) throws IOException, GeneralSecurityException, PasswordException {
initializeIfNeeded();
OutputStreamWriter writer;
if (password != null) {
// Use same salt and parameters as the on-disk files
PasswordCache cache = new PasswordCache(I2PBote.getInstance().getConfiguration());
cache.setPassword(password.getBytes());
DerivedKey derivedKey = cache.getKey();
writer = new OutputStreamWriter(new EncryptedOutputStream(exportStream, derivedKey), "UTF-8");
} else
writer = new OutputStreamWriter(exportStream, "UTF-8");
Properties properties = saveToProperties();
properties.store(writer, null);
// If a password was provided, this call triggers the encryption
writer.close();
}
Aggregations