Class CipherStorageProvider

  • All Implemented Interfaces:
    StorageProvider

    public class CipherStorageProvider
    extends AbstractStorageProvider
    A StorageProvider that transparently scrambles and unscrambles the data stored by another StorageProvider.

    Example usage:

     StorageProvider mistrusted = new TempFileStorageProvider();
     StorageProvider enciphered = new CipherStorageProvider(mistrusted);
     StorageProvider provider = new ThresholdStorageProvider(enciphered);
     DefaultStorageProvider.setInstance(provider);
     
    • Field Detail

      • algorithm

        private final java.lang.String algorithm
      • keygen

        private final javax.crypto.KeyGenerator keygen
    • Constructor Detail

      • CipherStorageProvider

        public CipherStorageProvider​(StorageProvider backend)
        Creates a new CipherStorageProvider 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 new CipherStorageProvider 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 a StorageOutputStream where data to be stored can be written to. Subsequently the user can call toStorage() on that object to get a Storage 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()