Search in sources :

Example 1 with CompromisedDataException

use of net.viperfish.journal.framework.errors.CompromisedDataException 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

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