Package org.apache.commons.compress.archivers.zip

# Class PKWareExtraHeader

java.lang.Object
org.apache.commons.compress.archivers.zip.PKWareExtraHeader

All Implemented Interfaces:
  `ZipExtraField`

Direct Known Subclasses:
  `X0014_X509Certificates`, `X0015_CertificateIdForFile`, `X0016_CertificateIdForCentralDirectory`, `X0017_StrongEncryptionHeader`, `X0019_EncryptionRecipientCertificateList`

public abstract class PKWareExtraHeader extends Object implements ZipExtraField
Base class for all PKWare strong crypto extra headers.

This base class acts as a marker so you know you can ignore all extra fields that extend this class if you are not interested in the meta data of PKWare strong encryption.

Algorithm IDs - integer identifier of the encryption algorithm from the following range

- 0x6601 - DES
- 0x6602 - RC2 (version needed to extract < 5.2)
- 0x6603 - 3DES 168
- 0x6609 - 3DES 112
- 0x660E - AES 128
- 0x660F - AES 192
- 0x6610 - AES 256
- 0x6702 - RC2 (version needed to extract >= 5.2)
- 0x6720 - Blowfish
- 0x6721 - Twofish
- 0x6801 - RC4
- 0xFFFF - Unknown algorithm

Hash Algorithms - integer identifier of the hash algorithm from the following range

- 0x0000 - none
- 0x0001 - CRC32
- 0x8003 - MD5
- 0x8004 - SHA1
- 0x8007 - RIPEMD160
- 0x800C - SHA256
- 0x800D - SHA384
- 0x800E - SHA512

Since:
  1.11

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `PKWareExtraHeader.EncryptionAlgorithm`
  Encryption algorithm.
  `static enum`
  `PKWareExtraHeader.HashAlgorithm`
  Hash Algorithm

- ## Field Summary

  ### Fields inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField

  `EXTRAFIELD_HEADER_SIZE`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `PKWareExtraHeader(ZipShort headerId)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected final void`
  `assertMinimalLength(int minimum, int length)`
  `byte[]`
  `getCentralDirectoryData()`
  Gets the central data.
  `ZipShort`
  `getCentralDirectoryLength()`
  Gets the central data length.
  `ZipShort`
  `getHeaderId()`
  Gets the header id.
  `byte[]`
  `getLocalFileDataData()`
  Gets the local data.
  `ZipShort`
  `getLocalFileDataLength()`
  Gets the length of the local data.
  `void`
  `parseFromCentralDirectoryData(byte[] data, int offset, int length)`
  Populate data from this array as if it was in central directory data.
  `void`
  `parseFromLocalFileData(byte[] data, int offset, int length)`
  Populate data from this array as if it was in local file data.
  `void`
  `setCentralDirectoryData(byte[] data)`
  Sets the extra field data in central directory.
  `void`
  `setLocalFileDataData(byte[] data)`
  Sets the extra field data in the local file data - without Header-ID or length specifier.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PKWareExtraHeader

    protected PKWareExtraHeader(ZipShort headerId)

- ## Method Details

  - ### assertMinimalLength

    protected final void assertMinimalLength(int minimum, int length) throws ZipException
    Throws:
      `ZipException`

  - ### getCentralDirectoryData

    public byte[] getCentralDirectoryData()
    Gets the central data.
    Specified by:
      `getCentralDirectoryData` in interface `ZipExtraField`
    Returns:
      the central data if present, else return the local file data

  - ### getCentralDirectoryLength

    public ZipShort getCentralDirectoryLength()
    Gets the central data length. If there is no central data, get the local file data length.
    Specified by:
      `getCentralDirectoryLength` in interface `ZipExtraField`
    Returns:
      the central data length

  - ### getHeaderId

    public ZipShort getHeaderId()
    Gets the header id.
    Specified by:
      `getHeaderId` in interface `ZipExtraField`
    Returns:
      the header id

  - ### getLocalFileDataData

    public byte[] getLocalFileDataData()
    Gets the local data.
    Specified by:
      `getLocalFileDataData` in interface `ZipExtraField`
    Returns:
      the local data

  - ### getLocalFileDataLength

    public ZipShort getLocalFileDataLength()
    Gets the length of the local data.
    Specified by:
      `getLocalFileDataLength` in interface `ZipExtraField`
    Returns:
      the length of the local data

  - ### parseFromCentralDirectoryData

    public void parseFromCentralDirectoryData(byte[] data, int offset, int length) throws ZipException
    Description copied from interface: `ZipExtraField`
    Populate data from this array as if it was in central directory data.
    Specified by:
      `parseFromCentralDirectoryData` in interface `ZipExtraField`
    Parameters:
      `data` - the array of bytes.
      `offset` - the source location in the data array.
      `length` - the number of bytes to use in the data array.
    Throws:
      `ZipException` - on error
    See Also:
      - `ZipExtraField.parseFromCentralDirectoryData(byte[], int, int)`

  - ### parseFromLocalFileData

    public void parseFromLocalFileData(byte[] data, int offset, int length) throws ZipException
    Description copied from interface: `ZipExtraField`
    Populate data from this array as if it was in local file data.
    Specified by:
      `parseFromLocalFileData` in interface `ZipExtraField`
    Parameters:
      `data` - the array of bytes.
      `offset` - the source location in the data array.
      `length` - the number of bytes to use in the data array.
    Throws:
      `ZipException` - on error
    See Also:
      - `ZipExtraField.parseFromLocalFileData(byte[], int, int)`

  - ### setCentralDirectoryData

    public void setCentralDirectoryData(byte[] data)
    Sets the extra field data in central directory.
    Parameters:
      `data` - the data to use

  - ### setLocalFileDataData

    public void setLocalFileDataData(byte[] data)
    Sets the extra field data in the local file data - without Header-ID or length specifier.
    Parameters:
      `data` - the field data to use