Package org.apache.james.mime4j.storage
Class CipherStorageProvider
- java.lang.Object
-
- org.apache.james.mime4j.storage.AbstractStorageProvider
-
- org.apache.james.mime4j.storage.CipherStorageProvider
-
- All Implemented Interfaces:
StorageProvider
public class CipherStorageProvider extends AbstractStorageProvider
AStorageProvider
that transparently scrambles and unscrambles the data stored by anotherStorageProvider
.Example usage:
StorageProvider mistrusted = new TempFileStorageProvider(); StorageProvider enciphered = new CipherStorageProvider(mistrusted); StorageProvider provider = new ThresholdStorageProvider(enciphered); DefaultStorageProvider.setInstance(provider);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CipherStorageProvider.CipherStorage
private static class
CipherStorageProvider.CipherStorageOutputStream
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
algorithm
private StorageProvider
backend
private javax.crypto.KeyGenerator
keygen
-
Constructor Summary
Constructors Constructor Description CipherStorageProvider(StorageProvider backend)
Creates a newCipherStorageProvider
for the given back-end using the Blowfish cipher algorithm.CipherStorageProvider(StorageProvider backend, java.lang.String algorithm)
Creates a newCipherStorageProvider
for the given back-end and cipher algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StorageOutputStream
createStorageOutputStream()
Creates aStorageOutputStream
where data to be stored can be written to.private javax.crypto.spec.SecretKeySpec
getSecretKeySpec()
-
Methods inherited from class org.apache.james.mime4j.storage.AbstractStorageProvider
store
-
-
-
-
Field Detail
-
backend
private final StorageProvider backend
-
algorithm
private final java.lang.String algorithm
-
keygen
private final javax.crypto.KeyGenerator keygen
-
-
Constructor Detail
-
CipherStorageProvider
public CipherStorageProvider(StorageProvider backend)
Creates a newCipherStorageProvider
for the given back-end using the Blowfish cipher algorithm.- Parameters:
backend
- back-end storage strategy to encrypt.
-
CipherStorageProvider
public CipherStorageProvider(StorageProvider backend, java.lang.String algorithm)
Creates a newCipherStorageProvider
for the given back-end and cipher algorithm.- Parameters:
backend
- back-end storage strategy to encrypt.algorithm
- the name of the symmetric block cipher algorithm such as "Blowfish", "AES" or "RC2".
-
-
Method Detail
-
createStorageOutputStream
public StorageOutputStream createStorageOutputStream() throws java.io.IOException
Description copied from interface:StorageProvider
Creates aStorageOutputStream
where data to be stored can be written to. Subsequently the user can calltoStorage()
on that object to get aStorage
instance that holds the data that has been written.- Returns:
- a
StorageOutputStream
where data can be written to. - Throws:
java.io.IOException
- if an I/O error occurs.
-
getSecretKeySpec
private javax.crypto.spec.SecretKeySpec getSecretKeySpec()
-
-