Search in sources :

Example 1 with CipherException

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);
    }
}
Also used : CipherException(net.viperfish.journal.framework.errors.CipherException) Journal(net.viperfish.journal.framework.Journal)

Example 2 with CipherException

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;
}
Also used : CipherException(net.viperfish.journal.framework.errors.CipherException) Journal(net.viperfish.journal.framework.Journal)

Example 3 with CipherException

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);
    }
}
Also used : FailToSyncCipherDataException(net.viperfish.journal.framework.errors.FailToSyncCipherDataException) JournalTransformer(net.viperfish.journal.framework.JournalTransformer) CompromisedDataException(net.viperfish.journal.framework.errors.CompromisedDataException) CipherException(net.viperfish.journal.framework.errors.CipherException) Journal(net.viperfish.journal.framework.Journal) IOException(java.io.IOException) File(java.io.File)

Aggregations

Journal (net.viperfish.journal.framework.Journal)3 CipherException (net.viperfish.journal.framework.errors.CipherException)3 File (java.io.File)1 IOException (java.io.IOException)1 JournalTransformer (net.viperfish.journal.framework.JournalTransformer)1 CompromisedDataException (net.viperfish.journal.framework.errors.CompromisedDataException)1 FailToSyncCipherDataException (net.viperfish.journal.framework.errors.FailToSyncCipherDataException)1