private int instrumentZip(final InputStream input, final OutputStream output, final String name) throws IOException { final ZipInputStream zipin = new ZipInputStream(input); final ZipOutputStream zipout = new ZipOutputStream(output); ZipEntry entry; int count = 0; while ((entry = zipin.getNextEntry()) != null) { final String entryName = entry.getName(); if (signatureRemover.removeEntry(entryName)) { continue; } zipout.putNextEntry(new ZipEntry(entryName)); if (!signatureRemover.filterEntry(entryName, zipin, zipout)) { count += instrumentAll(zipin, zipout, name + "@" + entryName); } zipout.closeEntry(); } zipout.finish(); return count; }
/** * Determines whether signatures should be removed from JAR files. This is typically necessary as * instrumentation modifies the class files and therefore invalidates existing JAR signatures. * Default is <code>true</code>. * * @param flag <code>true</code> if signatures should be removed */ public void setRemoveSignatures(final boolean flag) { signatureRemover.setActive(flag); }