@Immutable public abstract class ZipRaesDriver extends JarDriver
Sub-classes must be thread-safe and should be immutable!
JAR_CHARSET
Constructor and Description |
---|
ZipRaesDriver() |
Modifier and Type | Method and Description |
---|---|
boolean |
check(JarDriverEntry local,
ZipInputService<JarDriverEntry> input)
Whether or not the content of the given entry shall get
checked/authenticated when reading it.
|
FsController |
decorate(FsController controller)
Decorates the given file system controller.
|
protected abstract long |
getAuthenticationTrigger()
Returns the value of the property
authenticationTrigger . |
boolean |
getPreambled()
Returns the flag for supporting preambles.
|
JarDriverEntry |
newEntry(net.java.truecommons.shed.BitField<FsAccessOption> options,
String name,
net.java.truecommons.cio.Entry.Type type,
net.java.truecommons.cio.Entry template)
Returns a new
JarDriverEntry , requesting that the data gets
DEFLATED if no template is provided. |
protected net.java.truecommons.cio.OutputService<JarDriverEntry> |
newOutput(FsModel model,
FsOutputSocketSink sink,
net.java.truecommons.cio.InputService<JarDriverEntry> input)
Creates a new input service for writing archive entries for the given
model to the target archive file referenced by sink . |
protected ZipInputService<JarDriverEntry> |
newZipInput(FsModel model,
FsInputSocketSource source) |
protected RaesParameters |
raesParameters(FsModel model)
Returns the RAES parameters for the given file system model.
|
protected FsOutputSocketSink |
sink(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsController controller,
FsNodeName name)
|
getCharset, newEntry, newEntry
fileSystemUri, getKeyManagerMap, getLevel, getMethod, getOverheadSize, getPool, getPostambled, getRedundantContentSupport, getRedundantMetaDataSupport, mountPointUri, newInput, rdc, zipCryptoParameters
checkEncodable, isArchiveDriver, newController, newEntry, newInput, newOutput, normalize, source, toString
public final boolean check(JarDriverEntry local, ZipInputService<JarDriverEntry> input)
AbstractZipDriver
true
and the check fails, then an
IOException
gets thrown.check
in class AbstractZipDriver<JarDriverEntry>
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, e.g. the encryption passwords.
This method should be overridden in order to return just controller
if and only if you are overriding
AbstractZipDriver.zipCryptoParameters(FsModel, Charset)
, too, and do not want to use a locatable key manager to resolve
passwords for WinZip AES encryption.
The implementation in the class ZipRaesDriver
decorates the given controller with a package private
controller which keeps track of the AES PBE parameters, e.g. the encryption passwords.
This method should be overridden in order to return just controller
if and only if you are overriding
raesParameters(FsModel)
, too, and do not want to use a locatable key manager to resolve
passwords for RAES encryption.
decorate
in class AbstractZipDriver<JarDriverEntry>
controller
- the file system controller to decorate.FsArchiveDriver
unconditionally returns controller
.protected abstract long getAuthenticationTrigger()
authenticationTrigger
.
If the cipher text length of an input RAES file is smaller than or equal to this value, then the Hash-based Message Authentication Code (HMAC) for the entire cipher text is computed and verified in order to authenticate the input RAES file.
Otherwise, if the cipher text length of an input RAES file is greater than this value, then initially only the cipher key and the cipher text length getKeyManager authenticated. In addition, whenever an entry is subsequently accessed, then it's CRC-32 value is checked.
Consequently, if the value of this property is set to a negative value,
then the entire cipher text gets never authenticated (CRC-32
checking only), and if set to Long.MAX_VALUE
, then the entire
cipher text gets always authenticated (no CRC-32 checking).
authenticationTrigger
.public final boolean getPreambled()
true
, then a ZIP file is allowed to
contain arbitrary data as its preamble before the actual ZIP file data.
Self Extracting Archives typically use a preamble to store the
application code that is required to extract the ZIP file contents.
If this method returns false
, then a ZIP file must start with
either a Local File Header (LFH) signature,
a ZIP64 End Of Central Directory Record (EOCDR) signature or an End Of
Central Directory Record (EOCDR) signature.
The implementation in the class ZipDriver
returns false
.
The implementation in the class ZipRaesDriver
returns
true
for future use.
getPreambled
in interface ZipFileParameters<JarDriverEntry>
getPreambled
in class AbstractZipDriver<JarDriverEntry>
true
public JarDriverEntry newEntry(net.java.truecommons.shed.BitField<FsAccessOption> options, String name, net.java.truecommons.cio.Entry.Type type, @CheckForNull net.java.truecommons.cio.Entry template)
JarDriverEntry
, requesting that the data gets
DEFLATED
if no template is provided.
This feature strengthens the security level of the authentication
process and inhibits the use of an unencrypted temporary I/O entry
(usually a temporary file) in case the sink is not copied from a file
system entry as its input.
Furthermore, the method ZipEntry.clearEncryption()
is
called in order to prevent adding a redundant encryption layer for the
individual ZIP entry because this would confuse users, increase the size
of the resulting archive file and unecessarily heat the CPU.
newEntry
in class AbstractZipDriver<JarDriverEntry>
options
- when called from FsController.make(net.java.truecommons.shed.BitField<net.java.truevfs.kernel.spec.FsAccessOption>, net.java.truevfs.kernel.spec.FsNodeName, net.java.truecommons.cio.Entry.Type, net.java.truecommons.cio.Entry)
, this is its
options
parameter, otherwise it's typically an empty set.name
- the entry name.type
- the entry type.template
- if not null
, then the new entry shall inherit
as much properties from this entry as possible - with the
exception of its name and type.FsArchiveDriver.newEntry(String, Entry.Type, Entry)
protected net.java.truecommons.cio.OutputService<JarDriverEntry> newOutput(FsModel model, FsOutputSocketSink sink, @CheckForNull @WillNotClose net.java.truecommons.cio.InputService<JarDriverEntry> input) throws IOException
FsArchiveDriver
model
to the target archive file referenced by sink
.newOutput
in class AbstractZipDriver<JarDriverEntry>
model
- the file system model.sink
- the sink for writing the target archive file.input
- the nullable InputService
for the target archive
file.
If not null
, then the target archive file is going to
get updated.
This parameter is guaranteed to be the product of this driver's
factory method
FsArchiveDriver.newInput(FsModel, BitField, FsController, FsNodeName)
.IOException
- on any I/O error.FsArchiveDriver.newOutput(FsModel, BitField, FsController, FsNodeName, InputService)
protected ZipInputService<JarDriverEntry> newZipInput(FsModel model, FsInputSocketSource source) throws IOException
newZipInput
in class AbstractZipDriver<JarDriverEntry>
IOException
protected RaesParameters raesParameters(FsModel model)
The implementation in the class ZipRaesDriver
returns
new KeyManagerRaesParameters(getKeyManagerMap().getKeyManager(AesPbeParameters.class), mountPointUri(model))
.
model
- the file system model.protected final FsOutputSocketSink sink(net.java.truecommons.shed.BitField<FsAccessOption> options, FsController controller, FsNodeName name)
sink
in class AbstractZipDriver<JarDriverEntry>
options
- the options for accessing the file system node.controller
- the controller to use for writing an artifact of this
driver.name
- the node name.FsArchiveDriver.newOutput(FsModel, BitField, FsController, FsNodeName, InputService)
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.