use of net.viperfish.journal.framework.errors.CipherException in project vsDiaryWriter by shilongdai.
the class JournalEncryptionWrapper method updateEntry.
@Override
public Journal updateEntry(Long id, Journal j) throws FailToSyncEntryException {
Journal trueUpdate;
try {
trueUpdate = encryptor.encryptJournal(j);
Journal result = db.updateEntry(id, trueUpdate);
j.setId(result.getId());
return j;
} catch (CipherException e) {
throw new RuntimeException(e);
}
}
use of net.viperfish.journal.framework.errors.CipherException in project vsDiaryWriter by shilongdai.
the class JournalEncryptionWrapper method addEntry.
@Override
public Journal addEntry(Journal j) throws FailToSyncEntryException {
Journal toAdd;
try {
toAdd = encryptor.encryptJournal(j);
} catch (CipherException e) {
throw new RuntimeException(e);
}
Journal result = db.addEntry(toAdd);
j.setId(result.getId());
return j;
}
use of net.viperfish.journal.framework.errors.CipherException in project vsDiaryWriter by shilongdai.
the class CompressMacTest method testWrapper.
protected void testWrapper() {
JournalTransformer wrapper;
try {
CommonFunctions.initDir(testDir);
wrapper = createTransformer(new File(testDir.getCanonicalPath() + "/salt"));
} catch (IOException e) {
System.err.println("cannot load salt");
throw new RuntimeException(e);
}
try {
wrapper.setPassword("password");
} catch (FailToSyncCipherDataException e1) {
throw new RuntimeException(e1);
}
Journal j = new Journal();
j.setSubject("test get");
j.setContent("test get content");
try {
Journal result = wrapper.encryptJournal(j);
result = wrapper.decryptJournal(result);
String plainContent = result.getContent();
Assert.assertEquals("test get content", plainContent);
Assert.assertEquals("test get", result.getSubject());
} catch (CipherException | CompromisedDataException e) {
throw new RuntimeException(e);
}
}
Aggregations