< prev index next >

src/java.base/share/classes/java/util/jar/JarFile.java

Print this page
rev 59204 : imported patch jarf_signature

*** 713,759 **** if (jv != null) { return; } if (verify) { ! String[] names = JUZFA.getMetaInfEntryNames(this); ! if (names != null) { ! for (String nameLower : names) { ! String name = nameLower.toUpperCase(Locale.ENGLISH); ! if (name.endsWith(".DSA") || ! name.endsWith(".RSA") || ! name.endsWith(".EC") || ! name.endsWith(".SF")) { ! // Assume since we found a signature-related file // that the jar is signed and that we therefore // need a JarVerifier and Manifest getManifest(); return; } - } - } // No signature-related files; don't instantiate a // verifier verify = false; } } /* * Initializes the verifier object by reading all the manifest * entries and passing them to the verifier. */ private void initializeVerifier() { ManifestEntryVerifier mev = null; // Verify "META-INF/" entries... try { ! String[] names = JUZFA.getMetaInfEntryNames(this); ! if (names != null) { for (String name : names) { - String uname = name.toUpperCase(Locale.ENGLISH); - if (MANIFEST_NAME.equals(uname) - || SignatureFileVerifier.isBlockOrSF(uname)) { JarEntry e = getJarEntry(name); if (e == null) { throw new JarException("corrupted jar file"); } if (mev == null) { --- 713,750 ---- if (jv != null) { return; } if (verify) { ! // Gets the manifest name, but only if there are ! // signature-related files. If so we can assume // that the jar is signed and that we therefore // need a JarVerifier and Manifest + String name = JUZFA.getManifestName(this, true); + if (name != null) { + manEntry = getEntry0(name); getManifest(); return; } // No signature-related files; don't instantiate a // verifier verify = false; } } + /* * Initializes the verifier object by reading all the manifest * entries and passing them to the verifier. */ private void initializeVerifier() { ManifestEntryVerifier mev = null; // Verify "META-INF/" entries... try { ! List<String> names = JUZFA.getManifestAndSignatureRelatedFiles(this); for (String name : names) { JarEntry e = getJarEntry(name); if (e == null) { throw new JarException("corrupted jar file"); } if (mev == null) {
*** 765,776 **** jv.beginEntry(e, mev); jv.update(b.length, b, 0, b.length, mev); jv.update(-1, null, 0, 0, mev); } } - } - } } catch (IOException ex) { // if we had an error parsing any blocks, just // treat the jar file as being unsigned jv = null; verify = false; --- 756,765 ----
*** 938,955 **** // First look up manifest entry using standard name JarEntry manEntry = getEntry0(MANIFEST_NAME); if (manEntry == null) { // If not found, then iterate through all the "META-INF/" // entries to find a match. ! String[] names = JUZFA.getMetaInfEntryNames(this); ! if (names != null) { ! for (String name : names) { ! if (MANIFEST_NAME.equals(name.toUpperCase(Locale.ENGLISH))) { manEntry = getEntry0(name); - break; - } - } } } this.manEntry = manEntry; } return manEntry; --- 927,939 ---- // First look up manifest entry using standard name JarEntry manEntry = getEntry0(MANIFEST_NAME); if (manEntry == null) { // If not found, then iterate through all the "META-INF/" // entries to find a match. ! String name = JUZFA.getManifestName(this, false); ! if (name != null) { manEntry = getEntry0(name); } } this.manEntry = manEntry; } return manEntry;
*** 1211,1221 **** CodeSource getCodeSource(URL url, String name) { ensureInitialization(); if (jv != null) { if (jv.eagerValidation) { ! CodeSource cs = null; JarEntry je = getJarEntry(name); if (je != null) { cs = jv.getCodeSource(url, this, je); } else { cs = jv.getCodeSource(url, name); --- 1195,1205 ---- CodeSource getCodeSource(URL url, String name) { ensureInitialization(); if (jv != null) { if (jv.eagerValidation) { ! CodeSource cs; JarEntry je = getJarEntry(name); if (je != null) { cs = jv.getCodeSource(url, this, je); } else { cs = jv.getCodeSource(url, name);
< prev index next >