org.homeunix.thecave.buddi.util
Class BuddiCryptoFactory

java.lang.Object
  extended by org.homeunix.thecave.moss.util.crypto.MossCryptoFactory
      extended by org.homeunix.thecave.buddi.util.BuddiCryptoFactory

public class BuddiCryptoFactory
extends MossCryptoFactory

A class which extends CipherStreamFactory and provides the header value for Buddi to use when saving / loading data files.

Author:
wyatt

Constructor Summary
BuddiCryptoFactory()
           
 
Method Summary
 byte[] getHeader()
          The byte array to use as the header.
 boolean isCompressData()
          Should we filter the data through gzip before encrypting it? For most situations, this should be true.
 boolean isSaveDate()
          Should we include the date timestamp at the beginning of the file? This value is unencrypted, and will appear right after the header.
 
Methods inherited from class org.homeunix.thecave.moss.util.crypto.MossCryptoFactory
getCanary, getDecryptedBytes, getDecryptedStream, getDecryptedString, getEncryptedBytes, getEncryptedStream, getEncryptedString, getTimestamp, isHeaderCorrect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuddiCryptoFactory

public BuddiCryptoFactory()
                   throws CipherException
Throws:
CipherException
Method Detail

getHeader

public byte[] getHeader()
Description copied from class: MossCryptoFactory
The byte array to use as the header. This should be a constant and distinct byte array for each file type. It is stored in plain text at the beginning of the file, and is used by the getCipher*Stream() methods to verify that the file is of the correct type. It can also be used by the OS to associate files with programs, if the windowing system supports signature based file association. You should not change this between versions of the data file, or else you will not be able to load old files in the new program version.

Specified by:
getHeader in class MossCryptoFactory
Returns:
An array of bytes representing the document's header (or file signature).

isSaveDate

public boolean isSaveDate()
Description copied from class: MossCryptoFactory
Should we include the date timestamp at the beginning of the file? This value is unencrypted, and will appear right after the header. You cannot change this value for different versions of the program, or the data files will be invalid.

Specified by:
isSaveDate in class MossCryptoFactory
Returns:
true if we should save the date, false otherwise.

isCompressData

public boolean isCompressData()
Description copied from class: MossCryptoFactory
Should we filter the data through gzip before encrypting it? For most situations, this should be true. If you need to use this for debugging purposes, or if the data is already very compressed, or if for speed reasons, it is better to not compress the data, you can return false here. When reading the files, we first check if it is compressed; if so, we read it in, but if not we assume the data is not compressed, and try it again. Because of this, you can mix and match compression in files, with no ill effects.

Specified by:
isCompressData in class MossCryptoFactory
Returns: