use of i2p.bote.fileencryption.EncryptedInputStream in project i2p.i2p-bote by i2p.
the class EmailFolder method getMetadata.
private EmailMetadata getMetadata(File file) throws IOException, GeneralSecurityException, PasswordException {
InputStream metadataStream = new BufferedInputStream(new EncryptedInputStream(new FileInputStream(file), passwordHolder));
EmailMetadata metadata = new EmailMetadata(metadataStream);
return metadata;
}
use of i2p.bote.fileencryption.EncryptedInputStream in project i2p.i2p-bote by i2p.
the class MigrateTo028 method migrateIdentitiesIfNeeded.
private void migrateIdentitiesIfNeeded(Configuration configuration, PasswordHolder passwordHolder) throws FileNotFoundException, IOException, GeneralSecurityException, PasswordException {
File identitiesFile = configuration.getIdentitiesFile();
if (!identitiesFile.exists())
return;
BufferedReader input = null;
try {
InputStream encryptedStream = new EncryptedInputStream(new FileInputStream(identitiesFile), passwordHolder);
input = new BufferedReader(new InputStreamReader(encryptedStream));
// No PasswordException occurred, so read the input stream and call migrateIdentities() if needed
List<String> lines = Util.readLines(encryptedStream);
if (!isIdentitiesFileMigrated(lines))
migrateIdentities(lines, configuration, passwordHolder);
} finally {
if (input != null)
input.close();
}
}
use of i2p.bote.fileencryption.EncryptedInputStream in project i2p.i2p-bote by i2p.
the class ExportableData method importFromFileDescriptor.
/**
* Imports data from FileDescriptor.
*
* @param importFileDescriptor
* @param password
* @param append Set to false if existing data should be dropped.
* @param replace Set to false to ignore duplicates, true to import and replace existing.
* @return true if the import succeeded, false if no valid data was found.
* @throws PasswordException if the provided password is invalid.
* @throws IOException
* @throws GeneralSecurityException
*/
public boolean importFromFileDescriptor(FileDescriptor importFileDescriptor, String password, boolean append, boolean replace) throws PasswordException, IOException, GeneralSecurityException {
initializeIfNeeded();
InputStream importStream = new FileInputStream(importFileDescriptor);
if (password != null)
importStream = new EncryptedInputStream(importStream, password.getBytes());
try {
Properties properties = new Properties();
properties.load(new InputStreamReader(importStream));
if (loadFromProperties(properties, append, replace)) {
// Save the new data
save();
return true;
} else
// No data found
return false;
} finally {
importStream.close();
}
}
Aggregations