List of usage examples for java.util.jar JarEntry setMethod
public void setMethod(int method)
From source file:net.sf.keystore_explorer.crypto.signing.JarSigner.java
private static void writeJarEntries(JarFile jar, JarOutputStream jos, String signatureName) throws IOException { for (Enumeration<?> jarEntries = jar.entries(); jarEntries.hasMoreElements();) { JarEntry jarEntry = (JarEntry) jarEntries.nextElement(); if (!jarEntry.isDirectory()) { String entryName = jarEntry.getName(); // Signature files not to write across String sigFileLocation = MessageFormat.format(METAINF_FILE_LOCATION, signatureName, SIGNATURE_EXT) .toUpperCase();/* w w w . j a v a2 s. c o m*/ String dsaSigBlockLocation = MessageFormat.format(METAINF_FILE_LOCATION, signatureName, DSA_SIG_BLOCK_EXT); String rsaSigBlockLocation = MessageFormat.format(METAINF_FILE_LOCATION, signatureName, RSA_SIG_BLOCK_EXT); // Do not write across existing manifest or matching signature files if ((!entryName.equalsIgnoreCase(MANIFEST_LOCATION)) && (!entryName.equalsIgnoreCase(sigFileLocation)) && (!entryName.equalsIgnoreCase(dsaSigBlockLocation)) && (!entryName.equalsIgnoreCase(rsaSigBlockLocation))) { // New JAR entry based on original JarEntry newJarEntry = new JarEntry(jarEntry.getName()); newJarEntry.setMethod(jarEntry.getMethod()); newJarEntry.setCompressedSize(jarEntry.getCompressedSize()); newJarEntry.setCrc(jarEntry.getCrc()); jos.putNextEntry(newJarEntry); InputStream jis = null; try { jis = jar.getInputStream(jarEntry); byte[] buffer = new byte[2048]; int read = -1; while ((read = jis.read(buffer)) != -1) { jos.write(buffer, 0, read); } jos.closeEntry(); } finally { IOUtils.closeQuietly(jis); } } } } }
From source file:com.scorpio4.util.io.JarArchiver.java
public String add(InputStream inputStream, String filename, String comment, long size) throws IOException, NoSuchAlgorithmException { if (jarOutputStream == null) throw new IOException("not open"); JarEntry entry = new JarEntry(filename); entry.setSize(size);//from w w w . j a v a2 s .c o m entry.setMethod(JarEntry.DEFLATED); // compressed entry.setTime(System.currentTimeMillis()); if (comment != null) entry.setComment(comment); jarOutputStream.putNextEntry(entry); // copy I/O & return SHA-1 fingerprint String fingerprint = Fingerprint.copy(inputStream, jarOutputStream, 4096); IOUtils.copy(inputStream, jarOutputStream); log.debug("JAR add " + size + " bytes: " + filename + " -> " + fingerprint); jarOutputStream.closeEntry(); // jarOutputStream.finish(); return fingerprint; }
From source file:org.apache.pluto.util.assemble.io.JarStreamingAssembly.java
private static JarEntry smartClone(JarEntry originalJarEntry) { final JarEntry newJarEntry = new JarEntry(originalJarEntry.getName()); newJarEntry.setComment(originalJarEntry.getComment()); newJarEntry.setExtra(originalJarEntry.getExtra()); newJarEntry.setMethod(originalJarEntry.getMethod()); newJarEntry.setTime(originalJarEntry.getTime()); //Must set size and CRC for STORED entries if (newJarEntry.getMethod() == ZipEntry.STORED) { newJarEntry.setSize(originalJarEntry.getSize()); newJarEntry.setCrc(originalJarEntry.getCrc()); }/*ww w .j av a 2s . co m*/ return newJarEntry; }
From source file:org.jahia.modules.serversettings.portlets.BasePortletHelper.java
static JarEntry cloneEntry(JarEntry originalJarEntry) { final JarEntry newJarEntry = new JarEntry(originalJarEntry.getName()); newJarEntry.setComment(originalJarEntry.getComment()); newJarEntry.setExtra(originalJarEntry.getExtra()); newJarEntry.setMethod(originalJarEntry.getMethod()); newJarEntry.setTime(originalJarEntry.getTime()); // Must set size and CRC for STORED entries if (newJarEntry.getMethod() == ZipEntry.STORED) { newJarEntry.setSize(originalJarEntry.getSize()); newJarEntry.setCrc(originalJarEntry.getCrc()); }//from w w w .j a va2 s . co m return newJarEntry; }