List of usage examples for org.apache.commons.compress.archivers.zip UnrecognizedExtraField setHeaderId
public void setHeaderId(ZipShort headerId)
From source file:cz.muni.fi.xklinec.zipstream.Mallory.java
/** * Adds given number of bytes as a null padding to extra field. * Minimal padding is 8B. Maximal padding is PAD_BLOCK_MAX. * //from ww w . j a v a 2 s.com * @param ze * @param padlen */ public void addExtraPadding(ZipArchiveEntry ze, int padlen) { if (padlen < EXTRA_FIELD_SIZE) { throw new IllegalArgumentException( "Cannot add padding less than 8 B (due to compulsory extra field structure). Given size " + padlen); } if (padlen > PAD_BLOCK_MAX) { throw new IllegalArgumentException( "Specified padding is too big, maximal size is " + PAD_BLOCK_MAX + " given size is " + padlen); } byte[] paddBuff = new byte[padlen - EXTRA_FIELD_SIZE]; UnrecognizedExtraField zextra = new UnrecognizedExtraField(); zextra.setHeaderId(new ZipShort(PAD_SIGNATURE)); zextra.setLocalFileDataData(new byte[0]); zextra.setCentralDirectoryData(paddBuff); ze.addExtraField(zextra); }