diff options
author | Casey Marshall <csm@gnu.org> | 2006-11-28 00:07:58 +0000 |
---|---|---|
committer | Casey Marshall <csm@gnu.org> | 2006-11-28 00:07:58 +0000 |
commit | cc957487d083f32e798a6c804f674fc1ca4cf9c5 (patch) | |
tree | 44024228a0906e0e17bbb03ef44ce0535f94cfe6 /java/util | |
parent | e0ae80efe95751e7f4b551c0d88d289eab9e4c27 (diff) | |
download | classpath-cc957487d083f32e798a6c804f674fc1ca4cf9c5.tar.gz |
2006-11-27Ê Casey MarshallÊ <csm@gnu.org>
* java/util/jar/JarEntry.java (certs): removed.
(jarfile): new field.
(getCertificates): read the certificates from the containing JarFile.
* java/util/jar/JarFile.java (JarEnumeration.nextElement): don't
fill in 'certs,' fill in 'jarfile' for the entry.
(getEntry): likewise.
Diffstat (limited to 'java/util')
-rw-r--r-- | java/util/jar/JarEntry.java | 29 | ||||
-rw-r--r-- | java/util/jar/JarFile.java | 26 |
2 files changed, 20 insertions, 35 deletions
diff --git a/java/util/jar/JarEntry.java b/java/util/jar/JarEntry.java index 722a283bb..515b45fa9 100644 --- a/java/util/jar/JarEntry.java +++ b/java/util/jar/JarEntry.java @@ -1,5 +1,5 @@ /* JarEntry.java - Represents an entry in a jar file - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ package java.util.jar; import java.io.IOException; import java.security.cert.Certificate; +import java.util.Set; import java.util.zip.ZipEntry; /** @@ -60,7 +61,7 @@ public class JarEntry extends ZipEntry // (Package local) fields Attributes attr; - Certificate certs[]; + JarFile jarfile; // Constructors @@ -79,7 +80,7 @@ public class JarEntry extends ZipEntry { super(name); attr = null; - certs = null; + jarfile = null; } /** @@ -93,7 +94,7 @@ public class JarEntry extends ZipEntry { super(entry); attr = null; - certs = null; + jarfile = null; } /** @@ -112,7 +113,7 @@ public class JarEntry extends ZipEntry catch (IOException _) { } - certs = entry.getCertificates(); + jarfile = entry.jarfile; } // Methods @@ -153,13 +154,19 @@ public class JarEntry extends ZipEntry */ public Certificate[] getCertificates() { - if (certs != null) + if (jarfile != null) { - return (Certificate[])certs.clone(); - } - else - { - return null; + synchronized (jarfile) + { + if (jarfile.entryCerts != null) + { + Set certs = (Set) jarfile.entryCerts.get(getName()); + if (certs != null + && jarfile.verified.get(getName()) == Boolean.TRUE) + return (Certificate[]) certs.toArray(new Certificate[certs.size()]); + } + } } + return null; } } diff --git a/java/util/jar/JarFile.java b/java/util/jar/JarFile.java index 4a2b7d3db..4416662a3 100644 --- a/java/util/jar/JarFile.java +++ b/java/util/jar/JarFile.java @@ -382,19 +382,8 @@ public class JarFile extends ZipFile } jarfile.signaturesRead = true; // fudge it. } - - // Include the certificates only if we have asserted that the - // signatures are valid. This means the certificates will not be - // available if the entry hasn't been read yet. - if (jarfile.entryCerts != null - && jarfile.verified.get(zip.getName()) == Boolean.TRUE) - { - Set certs = (Set) jarfile.entryCerts.get(jar.getName()); - if (certs != null) - jar.certs = (Certificate[]) - certs.toArray(new Certificate[certs.size()]); - } } + jar.jarfile = jarfile; return jar; } } @@ -439,18 +428,7 @@ public class JarFile extends ZipFile } signaturesRead = true; } - // See the comments in the JarEnumeration for why we do this - // check. - if (DEBUG) - debug("entryCerts=" + entryCerts + " verified " + name - + " ? " + verified.get(name)); - if (entryCerts != null && verified.get(name) == Boolean.TRUE) - { - Set certs = (Set) entryCerts.get(name); - if (certs != null) - jarEntry.certs = (Certificate[]) - certs.toArray(new Certificate[certs.size()]); - } + jarEntry.jarfile = this; return jarEntry; } return null; |