@ThreadSafe public class KeyManagerZipCryptoParameters extends Object implements ZipParametersProvider, ZipCryptoParameters
ZipCryptoParameters
by using a
KeyManagerMap
.
The current implementation supports only WinZipAesParameters
.
Modifier and Type | Field and Description |
---|---|
protected Charset |
charset
The character set which has been provided to the constructor and is
used for encoding entry names and the file comment in the ZIP file .
|
Constructor and Description |
---|
KeyManagerZipCryptoParameters(AbstractZipDriver<?> driver,
FsModel model,
Charset charset)
Constructs new ZIP crypto parameters.
|
Modifier and Type | Method and Description |
---|---|
<P extends ZipParameters> |
get(Class<P> type)
|
protected byte[] |
password(char[] characters,
String name)
A template method to derive password bytes from the given password
characters and the given entry name.
|
protected final Charset charset
public KeyManagerZipCryptoParameters(AbstractZipDriver<?> driver, FsModel model, Charset charset)
driver
- the ZIP driver.model
- the file system model.charset
- the character set which is used for encoding entry names
and the file comment in the ZIP file.public <P extends ZipParameters> P get(Class<P> type)
ZipParameters
of the given type
or null
if not available.
If type
is assignable from WinZipAesParameters
, then a
KeyManager
for AesPbeParameters
will getKeyManager used
which is obtained from the driver
which has
been provided to the constructor.
Otherwise, null
gets returned.
get
in interface ZipParametersProvider
P
- the type of the ZIP parameters.type
- the ZipParameters
interface class which's
implementation is required.ZipParameters
of the given type
or null
if not available.protected byte[] password(char[] characters, String name)
The implementation in the class KeyManagerZipCryptoParameters
ignores the given entry name and just encodes the given password
characters using
PBEParametersGenerator.PKCS5PasswordToBytes(char[])
.
A reasonable alternative implementation could encode the given password
characters using the value of the field charset
, which is the
character set actually used to encode entry names and comments in the
ZIP file, e.g. UTF-8 or CP437.
characters
- the password characters to encode.name
- the entry name for optional mixing into the result.Discussion Of Alternative Character Set Encodings
,
RFC 2898: PKCS #5: Password-Based Cryptography Specification Version 2.0 (IETF et al.)Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.