E - the type of the ZIP driver entries.@Immutable public abstract class AbstractZipDriver<E extends AbstractZipDriverEntry> extends FsArchiveDriver<E> implements ZipOutputStreamParameters, ZipFileParameters<E>
Sub-classes must be thread-safe and should be immutable!
| Constructor and Description |
|---|
AbstractZipDriver() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
check(E local,
ZipInputService<E> input)
Whether or not the content of the given entry shall get
checked/authenticated when reading it.
|
FsController |
decorate(FsController controller)
The implementation in the class
ZipDriver decorates the
given controller with a package private controller which keeps track of
the AES PBE parameters. |
URI |
fileSystemUri(FsModel model,
String name)
A template method for resolving the resource URI which is required to
look up the
KeyProvider for the entry with the given name in the
file system with the given model. |
net.java.truecommons.key.spec.KeyManagerMap |
getKeyManagerMap()
Returns the map of key managers for accessing protected resources
(encryption).
|
int |
getLevel()
The implementation in the class
ZipDriver
returns Deflater#BEST_COMPRESSION. |
int |
getMethod()
The implementation in the class
ZipDriver
returns ZipEntry#DEFLATED. |
int |
getOverheadSize()
The implementation in the class
ZipDriver
returns Maps#OVERHEAD_SIZE. |
net.java.truecommons.cio.IoBufferPool |
getPool()
The implementation in the class
AbstractZipDriver returns
IoBufferPoolLocator.SINGLETON.get(). |
boolean |
getPostambled()
The implementation in the class
ZipDriver
returns false. |
boolean |
getPreambled()
The implementation in the class
ZipDriver
returns false. |
boolean |
getRedundantContentSupport() |
boolean |
getRedundantMetaDataSupport() |
URI |
mountPointUri(FsModel model)
A template method for resolving the resource URI which is required to
look up the
KeyProvider for the mount point of the file system
with the given model. |
E |
newEntry(net.java.truecommons.shed.BitField<FsAccessOption> options,
String name,
net.java.truecommons.cio.Entry.Type type,
net.java.truecommons.cio.Entry template) |
abstract E |
newEntry(String name)
Returns a new ZIP driver entry with the given
name. |
abstract E |
newEntry(String name,
ZipEntry template)
Returns a new ZIP driver entry with the given
name and all
other properties copied from the given template. |
protected ZipInputService<E> |
newInput(FsModel model,
FsInputSocketSource source) |
protected net.java.truecommons.cio.OutputService<E> |
newOutput(FsModel model,
FsOutputSocketSink sink,
net.java.truecommons.cio.InputService<E> input) |
protected ZipInputService<E> |
newZipInput(FsModel model,
FsInputSocketSource source) |
protected boolean |
rdc(AbstractZipDriverEntry input,
AbstractZipDriverEntry output)
Returns
true if and only if the content of the given input
target entry is eligible for Raw Data Copying (RDC). |
boolean |
rdc(ZipInputService<E> input,
E local,
AbstractZipDriverEntry peer) |
boolean |
rdc(ZipOutputService<E> output,
E local,
AbstractZipDriverEntry peer) |
protected FsOutputSocketSink |
sink(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsController controller,
FsNodeName name)
This implementation modifies
options in the following way before
it forwards the call to controller:
FsAccessOption.STORE is set. |
protected ZipCryptoParameters |
zipCryptoParameters(FsModel model,
Charset charset)
Returns the ZIP crypto parameters for the given file system model
and character set or
null if not available. |
ZipCryptoParameters |
zipCryptoParameters(ZipInputService<E> input) |
ZipCryptoParameters |
zipCryptoParameters(ZipOutputService<E> output) |
checkEncodable, getCharset, isArchiveDriver, newController, newEntry, newInput, newOutput, normalize, source, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetCharsetpublic boolean check(E local, @WillNotClose ZipInputService<E> input)
true and the check fails, then an
IOException gets thrown.local - the entry to test.input - the origin of the entry.entry.isEncrypted().public FsController decorate(FsController controller)
The implementation in the class ZipDriver decorates the
given controller with a package private controller which keeps track of
the AES PBE parameters.
This should pool overridden in order to return just controller if
and only if you are overriding
zipCryptoParameters(FsModel, Charset), too, and do not want to
use the locatable key manager to resolve passwords, e.g. for WinZip AES
encryption.
decorate in class FsArchiveDriver<E extends AbstractZipDriverEntry>public URI fileSystemUri(FsModel model, String name)
KeyProvider for the entry with the given name in the
file system with the given model.
The implementation in the class ZipDriver ignores the given
entry name and just returns the expression mountPointUri(model)
in order to lookup the same key provider for all entries in a ZIP file.
An alternative implementation in a sub-class could return the expression
mountPointUri(model).resolve("/" + name) instead.
model - the file system model.name - the entry name.KeyProvider.public net.java.truecommons.key.spec.KeyManagerMap getKeyManagerMap()
This is an immutable property - multiple calls must return the same object.
KeyManagerMapLocator.SINGLETON, as by the implementation
in the class ZipDriver.public int getLevel()
The implementation in the class ZipDriver
returns Deflater#BEST_COMPRESSION.
getLevel in interface ZipOutputStreamParametersDeflater#BEST_COMPRESSIONpublic int getMethod()
The implementation in the class ZipDriver
returns ZipEntry#DEFLATED.
getMethod in interface ZipOutputStreamParametersZipEntry#DEFLATEDpublic int getOverheadSize()
The implementation in the class ZipDriver
returns Maps#OVERHEAD_SIZE.
getOverheadSize in interface ZipOutputStreamParametersMaps#OVERHEAD_SIZEpublic net.java.truecommons.cio.IoBufferPool getPool()
The implementation in the class AbstractZipDriver returns
IoBufferPoolLocator.SINGLETON.get().
getPool in class FsArchiveDriver<E extends AbstractZipDriverEntry>public boolean getPostambled()
The implementation in the class ZipDriver
returns false.
getPostambled in interface ZipFileParameters<E extends AbstractZipDriverEntry>falsepublic boolean getPreambled()
The implementation in the class ZipDriver
returns false.
getPreambled in interface ZipFileParameters<E extends AbstractZipDriverEntry>falsepublic boolean getRedundantContentSupport()
getRedundantContentSupport in class FsArchiveDriver<E extends AbstractZipDriverEntry>ZipDriver returns
true because when reading a ZIP file sequentially,
each ZIP entry should "override" any previously read
ZIP entry with an equal name.
This holds true even if the central directory is used to access
the ZIP entries in random order.public boolean getRedundantMetaDataSupport()
getRedundantMetaDataSupport in class FsArchiveDriver<E extends AbstractZipDriverEntry>ZipDriver returns
true because when reading a ZIP file sequentially,
each ZIP entry should "override" any previously read
ZIP entry with an equal name.
This holds true even if the central directory is used to access
the ZIP entries in random order.public URI mountPointUri(FsModel model)
KeyProvider for the mount point of the file system
with the given model.
The implementation in the class ZipDriver returns the
expression model.getMountPoint().toHierarchicalUri()
in order to improve the readability of the URI in comparison to the
expression model.getMountPoint().getUri().
model - the file system model.public E newEntry(net.java.truecommons.shed.BitField<FsAccessOption> options, String name, net.java.truecommons.cio.Entry.Type type, @CheckForNull net.java.truecommons.cio.Entry template)
newEntry in class FsArchiveDriver<E extends AbstractZipDriverEntry>public abstract E newEntry(String name)
name.newEntry in interface ZipEntryFactory<E extends AbstractZipDriverEntry>name - the entry name.public abstract E newEntry(String name, ZipEntry template)
name and all
other properties copied from the given template.name - the entry name.template - the template entry.protected final ZipInputService<E> newInput(FsModel model, FsInputSocketSource source) throws IOException
newInput in class FsArchiveDriver<E extends AbstractZipDriverEntry>IOException@CreatesObligation protected net.java.truecommons.cio.OutputService<E> newOutput(FsModel model, FsOutputSocketSink sink, @CheckForNull@WillNotClose net.java.truecommons.cio.InputService<E> input) throws IOException
newOutput in class FsArchiveDriver<E extends AbstractZipDriverEntry>IOException@CreatesObligation protected ZipInputService<E> newZipInput(FsModel model, FsInputSocketSource source) throws IOException
IOExceptionprotected boolean rdc(AbstractZipDriverEntry input, AbstractZipDriverEntry output)
true if and only if the content of the given input
target entry is eligible for Raw Data Copying (RDC).
This method gets called twice (once on each side of a copy operation)
and should return false unless both target entries can mutually
agree on transferring raw (unprocessed) content.
Note that it is an error to compare the properties of the target entries
because this method may get called before the output target
entry gets mutated to compare equal with the input target entry!
The implementation in the class ZipDriver returns
!local.isEncrypted() && !remote.isEncrypted() in order to cover
the typical case that the cipher keys of both targets are not the same.
Note that there is no secure way to explicitly test for this.
input - the input target entry for copying the contents.output - the output target entry for copying the contents.public final boolean rdc(@WillNotClose ZipInputService<E> input, E local, AbstractZipDriverEntry peer)
public final boolean rdc(@WillNotClose ZipOutputService<E> output, E local, AbstractZipDriverEntry peer)
protected FsOutputSocketSink sink(net.java.truecommons.shed.BitField<FsAccessOption> options, FsController controller, FsNodeName name)
options in the following way before
it forwards the call to controller:
FsAccessOption.STORE is set.
FsAccessOption.GROW is set, then
FsAccessOption.APPEND gets set, too, and
FsAccessOption.CACHE gets cleared.
The resulting output socket is then wrapped in a private nested class
for an upcast in newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>).
Thus, when overriding this method, newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>) should get
overridden, too.
Otherwise, a class cast exception will pool thrown in
newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>).
sink in class FsArchiveDriver<E extends AbstractZipDriverEntry>@CheckForNull protected ZipCryptoParameters zipCryptoParameters(FsModel model, Charset charset)
null if not available.
To enable the use of this method when writing an archive entry with the
client APIs, you must use FsAccessOption.ENCRYPT.
The implementation in the class ZipDriver returns
new KeyManagerZipCryptoParameters(this, model, charset).
model - the file system model.charset - charset the character set used for encoding entry names
and the file comment in the ZIP file.null if not available.@CheckForNull public final ZipCryptoParameters zipCryptoParameters(ZipInputService<E> input)
@CheckForNull public final ZipCryptoParameters zipCryptoParameters(ZipOutputService<E> output)
Copyright © 2005–2014 Schlichtherle IT Services. All rights reserved.