< prev index next >
src/java.base/share/classes/java/util/jar/JarFile.java
Print this page
rev 59204 : imported patch jarf_signature
@@ -713,47 +713,38 @@
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
+ // 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 {
- String[] names = JUZFA.getMetaInfEntryNames(this);
- if (names != null) {
+ List<String> names = JUZFA.getManifestAndSignatureRelatedFiles(this);
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) {
@@ -765,12 +756,10 @@
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;
@@ -938,18 +927,13 @@
// 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))) {
+ String name = JUZFA.getManifestName(this, false);
+ if (name != null) {
manEntry = getEntry0(name);
- break;
- }
- }
}
}
this.manEntry = manEntry;
}
return manEntry;
@@ -1211,11 +1195,11 @@
CodeSource getCodeSource(URL url, String name) {
ensureInitialization();
if (jv != null) {
if (jv.eagerValidation) {
- CodeSource cs = null;
+ CodeSource cs;
JarEntry je = getJarEntry(name);
if (je != null) {
cs = jv.getCodeSource(url, this, je);
} else {
cs = jv.getCodeSource(url, name);
< prev index next >