de.schlichtherle.io.archive.zip.raes
Class AbstractZipRaesDriver
java.lang.Object
de.schlichtherle.io.archive.spi.AbstractArchiveDriver
de.schlichtherle.io.archive.zip.ZipDriver
de.schlichtherle.io.archive.zip.JarDriver
de.schlichtherle.io.archive.zip.raes.AbstractZipRaesDriver
- All Implemented Interfaces:
- ArchiveDriver, Serializable
- Direct Known Subclasses:
- AbstractZip32RaesDriver, ParanoidZipRaesDriver, SafeZipRaesDriver, UnsafeZipRaesDriver
public abstract class AbstractZipRaesDriver
- extends JarDriver
An abstract archive driver which builds RAES encrypted ZIP files
and optionally authenticates the cipher data of the input archive files
presented to it.
The constructor takes an optional authentication trigger parameter which
can be used by subclasses to fine tune the authentication process.
When omitted, the RAES Message Authentication Code (MAC) is always
validated for the cipher text of input archive files.
Instances of this base class are immutable.
- Since:
- TrueZIP 6.0
- Version:
- $Id: AbstractZipRaesDriver.java,v 1.4 2010/08/20 13:09:49 christian_schlichtherle Exp $
- Author:
- Christian Schlichtherle
- See Also:
- Serialized Form
|
Constructor Summary |
protected |
AbstractZipRaesDriver(Icon openIcon,
Icon closedIcon,
boolean preambled,
boolean postambled,
int level,
long authenticationTrigger)
Constructs a new abstract ZIP.RAES driver which uses the given byte
size to trigger verification of the Message Authentication Code (MAC). |
|
Method Summary |
ArchiveEntry |
createArchiveEntry(Archive archive,
String entryName,
ArchiveEntry template)
Creates a new ZipEntry, enforcing that the data gets
DEFLATED when written, even if copying data from a
STORED source entry. |
InputArchive |
createInputArchive(Archive archive,
ReadOnlyFile rof)
This implementation calls getRaesParameters(de.schlichtherle.io.archive.Archive), with which it
initializes a new RaesReadOnlyFile. |
OutputArchive |
createOutputArchive(Archive archive,
OutputStream out,
InputArchive source)
This implementation calls getRaesParameters(de.schlichtherle.io.archive.Archive), with which it
initializes a new RaesOutputStream, and finally passes the
resulting stream to the super class implementation. |
long |
getAuthenticationTrigger()
Returns the authentication trigger provided to the constructor. |
RaesParameters |
getRaesParameters(Archive archive)
Returns the RaesParameters for the given canonical path name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractZipRaesDriver
protected AbstractZipRaesDriver(Icon openIcon,
Icon closedIcon,
boolean preambled,
boolean postambled,
int level,
long authenticationTrigger)
- Constructs a new abstract ZIP.RAES driver which uses the given byte
size to trigger verification of the Message Authentication Code (MAC).
Note that the given parameter only affects the authentication of the
cipher text in input archives - the cipher key and
file length are always authenticated with RAES.
- Parameters:
authenticationTrigger - The trigger
If set to a negative value, the MAC of input
archive files gets never verified.
If set to Long.MAX_VALUE, the MAC of input
archive files gets always authenticated.
Otherwise, the MAC of input archive files up to this size in
bytes (including the overhead for the RAES wrapper data) only
gets authenticated.
getAuthenticationTrigger
public final long getAuthenticationTrigger()
- Returns the authentication trigger provided to the constructor.
Note that this method is final for security reasons.
createInputArchive
public InputArchive createInputArchive(Archive archive,
ReadOnlyFile rof)
throws IOException
- This implementation calls
getRaesParameters(de.schlichtherle.io.archive.Archive), with which it
initializes a new RaesReadOnlyFile.
Next, if the gross file length of the archive is smaller than or equal
to the authentication trigger, the MAC authentication on the cipher
text is performed.
Finally, the RaesReadOnlyFile is passed on to the super
class implementation.
- Specified by:
createInputArchive in interface ArchiveDriver- Overrides:
createInputArchive in class ZipDriver
- Parameters:
archive - The abstract archive representation which TrueZIP's
internal ArchiveController is processing
- never null.rof - The ReadOnlyFile to read the
actual archive contents from - never null.
Hint: If you'ld prefer to have an InputStream,
you could decorate this parameter with a
ReadOnlyFileInputStream.
- Returns:
- A new input archive instance.
- Throws:
TransientIOException - If calling this method for the same
archive file again may finally succeed.
This exception is associated with another IOException
as its cause which is unwrapped and interpreted as below.
FileNotFoundException - If the input archive is inaccessible
for any reason and you would like the package
de.schlichtherle.io to mask the archive as a
special file which cannot get read, written or deleted.
IOException - On any other I/O or data format related issue
when reading the input archive and you would like the package
de.schlichtherle.io to treat the archive like a
regular file which may be read, written or deleted.- See Also:
InputArchive
createArchiveEntry
public ArchiveEntry createArchiveEntry(Archive archive,
String entryName,
ArchiveEntry template)
throws CharConversionException
- Creates a new ZipEntry, enforcing that the data gets
DEFLATED when written, even if copying data from a
STORED source entry.
- Specified by:
createArchiveEntry in interface ArchiveDriver- Overrides:
createArchiveEntry in class ZipDriver
- Parameters:
archive - The abstract archive representation which TrueZIP's
internal ArchiveController is processing
- never null.entryName - A valid archive entry name - never null.template - If not null, then the newly created entry
shall inherit as much attributes from this object as possible
(with the exception of the name).
This is typically used for archive copy operations.
Note that there is no guarantee on the runtime type of this
object; it may have been created by other drivers.
It is safe to ignore the metaData property when
copying entries.
- Returns:
- A new archive entry instance.
- Throws:
CharConversionException - If name contains
illegal characters.- See Also:
- Requirements for Archive Entry Names
createOutputArchive
public OutputArchive createOutputArchive(Archive archive,
OutputStream out,
InputArchive source)
throws IOException
- This implementation calls
getRaesParameters(de.schlichtherle.io.archive.Archive), with which it
initializes a new RaesOutputStream, and finally passes the
resulting stream to the super class implementation.
- Specified by:
createOutputArchive in interface ArchiveDriver- Overrides:
createOutputArchive in class ZipDriver
- Parameters:
archive - The abstract archive representation which TrueZIP's
internal ArchiveController is processing
- never null.out - The OutputStream to write the archive entries to
- never null.source - The source InputArchive if
archive is going to get updated.
If not null, this is guaranteed to be a product
of this driver's ArchiveDriver.createInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile) method.
This may be used to copy some meta data which is specific to
the type of archive this driver supports.
For example, this could be used to copy the comment of a ZIP
file.
- Returns:
- A new output archive instance.
- Throws:
TransientIOException - If calling this method for the same
archive file again may finally succeed.
This exception is associated with another IOException
as its cause which is unwrapped and interpreted as below.
FileNotFoundException - If the output archive is inaccessible
for any reason.
IOException - On any other I/O or data format related issue
when writing the output archive.- See Also:
OutputArchive
getRaesParameters
public RaesParameters getRaesParameters(Archive archive)
- Returns the
RaesParameters for the given canonical path name.
- Parameters:
archive - The abstract archive representation which TrueZIP's
internal ArchiveController is processing
- never null.
- Returns:
- The
RaesParameters to use for accessing the
prospective RAES encrypted ZIP file.
Copyright © 2005-2010 Schlichtherle IT Services. All Rights Reserved.