/** * Hash the JarEntry completely. * * @param jf the JarFile * @param je the JarEntry * @throws IOException * @return resulting hash */ private String hash(JarFile jf, JarEntry je) throws IOException { byte[] data = readJarEntry(jf, je); return b64encoder.encodeBuffer(md.digest(data)).trim(); }
/** * If jar is signed, return existing Signature file, else return null. * * @param jf The jar file * @return Signature file * @throws IOException */ private static byte[] getExistingSignatureFile(JarFile jf) throws IOException { Enumeration<JarEntry> entries = jf.entries(); JarEntry je = null; while (entries.hasMoreElements()) { JarEntry cje = entries.nextElement(); if (cje.getName().startsWith("META-INF/") && cje.getName().endsWith(".SF")) { je = cje; break; } } return readJarEntry(jf, je); }
/** * If jar is signed, return existing Signature file, else return null. * * @param jf The jar file * @return Signature file * @throws IOException */ private static byte[] getExistingSignatureFile(JarFile jf) throws IOException { Enumeration<JarEntry> entries = jf.entries(); JarEntry je = null; while (entries.hasMoreElements()) { JarEntry cje = entries.nextElement(); if (cje.getName().startsWith("META-INF/") && cje.getName().endsWith(".SF")) { je = cje; break; } } return readJarEntry(jf, je); }
sigFileContent = sigFile.toString().getBytes(); } else { manifestContent = readJarEntry(jf, jf.getJarEntry(JarFile.MANIFEST_NAME)); if (!name.equals(JarFile.MANIFEST_NAME)) { zout.putNextEntry(getZipEntry(je)); byte[] data = readJarEntry(jf, je); zout.write(data);
continue; processMetadataForEntry(manifest, manifestEntries, sigFileEntries, name, readJarEntry(jf, je)); sigFileContent = sigFile.toString().getBytes(); } else { manifestContent = readJarEntry(jf, jf.getJarEntry(JarFile.MANIFEST_NAME)); if (!name.equals(JarFile.MANIFEST_NAME)) { zout.putNextEntry(getZipEntry(je)); byte[] data = readJarEntry(jf, je); zout.write(data);