/** * whether the current entry will be encrypted using strong encryption. * @param b whether the current entry will be encrypted using strong encryption */ public void useStrongEncryption(final boolean b) { strongEncryptionFlag = b; if (b) { useEncryption(true); } }
/** * Parses the supported flags from the given archive data. * * @param data local file header or a central directory entry. * @param offset offset at which the general purpose bit starts * @return parsed flags */ public static GeneralPurposeBit parse(final byte[] data, final int offset) { final int generalPurposeFlag = ZipShort.getValue(data, offset); final GeneralPurposeBit b = new GeneralPurposeBit(); b.useDataDescriptor((generalPurposeFlag & DATA_DESCRIPTOR_FLAG) != 0); b.useUTF8ForNames((generalPurposeFlag & UFT8_NAMES_FLAG) != 0); b.useStrongEncryption((generalPurposeFlag & STRONG_ENCRYPTION_FLAG) != 0); b.useEncryption((generalPurposeFlag & ENCRYPTION_FLAG) != 0); b.slidingDictionarySize = (generalPurposeFlag & SLIDING_DICTIONARY_SIZE_FLAG) != 0 ? 8192 : 4096; b.numberOfShannonFanoTrees = (generalPurposeFlag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) != 0 ? 3 : 2; return b; }
@Test public void test1() throws IOException { ZipArchiveInputStream zis = new ZipArchiveInputStream(BadZipEntryFlagTest.class.getResourceAsStream("/bad.zip")); for (ZipArchiveEntry e = zis.getNextZipEntry(); e != null; e = zis.getNextZipEntry()) { e.getGeneralPurposeBit().useEncryption(false); if (!e.isDirectory()) { zis.read(); System.out.println(e.getName()); } } }
/** * whether the current entry will be encrypted using strong encryption. * @param b whether the current entry will be encrypted using strong encryption */ public void useStrongEncryption(final boolean b) { strongEncryptionFlag = b; if (b) { useEncryption(true); } }
/** * Parses the supported flags from the given archive data. * * @param data local file header or a central directory entry. * @param offset offset at which the general purpose bit starts * @return parsed flags */ public static GeneralPurposeBit parse(final byte[] data, final int offset) { final int generalPurposeFlag = ZipShort.getValue(data, offset); final GeneralPurposeBit b = new GeneralPurposeBit(); b.useDataDescriptor((generalPurposeFlag & DATA_DESCRIPTOR_FLAG) != 0); b.useUTF8ForNames((generalPurposeFlag & UFT8_NAMES_FLAG) != 0); b.useStrongEncryption((generalPurposeFlag & STRONG_ENCRYPTION_FLAG) != 0); b.useEncryption((generalPurposeFlag & ENCRYPTION_FLAG) != 0); b.slidingDictionarySize = (generalPurposeFlag & SLIDING_DICTIONARY_SIZE_FLAG) != 0 ? 8192 : 4096; b.numberOfShannonFanoTrees = (generalPurposeFlag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) != 0 ? 3 : 2; return b; }