0N/A/*
3570N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.util.jar;
0N/A
0N/Aimport java.io.*;
0N/Aimport java.lang.ref.SoftReference;
3570N/Aimport java.net.URL;
0N/Aimport java.util.*;
0N/Aimport java.util.zip.*;
0N/Aimport java.security.CodeSigner;
0N/Aimport java.security.cert.Certificate;
0N/Aimport java.security.AccessController;
3570N/Aimport java.security.CodeSource;
5701N/Aimport sun.misc.IOUtils;
0N/Aimport sun.security.action.GetPropertyAction;
0N/Aimport sun.security.util.ManifestEntryVerifier;
0N/Aimport sun.misc.SharedSecrets;
0N/A
0N/A/**
0N/A * The <code>JarFile</code> class is used to read the contents of a jar file
0N/A * from any file that can be opened with <code>java.io.RandomAccessFile</code>.
0N/A * It extends the class <code>java.util.zip.ZipFile</code> with support
0N/A * for reading an optional <code>Manifest</code> entry. The
0N/A * <code>Manifest</code> can be used to specify meta-information about the
0N/A * jar file and its entries.
0N/A *
0N/A * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
0N/A * or method in this class will cause a {@link NullPointerException} to be
0N/A * thrown.
0N/A *
0N/A * @author David Connelly
0N/A * @see Manifest
0N/A * @see java.util.zip.ZipFile
0N/A * @see java.util.jar.JarEntry
0N/A * @since 1.2
0N/A */
0N/Apublic
0N/Aclass JarFile extends ZipFile {
0N/A private SoftReference<Manifest> manRef;
0N/A private JarEntry manEntry;
0N/A private JarVerifier jv;
0N/A private boolean jvInitialized;
0N/A private boolean verify;
0N/A private boolean computedHasClassPathAttribute;
0N/A private boolean hasClassPathAttribute;
0N/A
0N/A // Set up JavaUtilJarAccess in SharedSecrets
0N/A static {
0N/A SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
0N/A }
0N/A
0N/A /**
0N/A * The JAR manifest file name.
0N/A */
0N/A public static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
0N/A
0N/A /**
0N/A * Creates a new <code>JarFile</code> to read from the specified
0N/A * file <code>name</code>. The <code>JarFile</code> will be verified if
0N/A * it is signed.
0N/A * @param name the name of the jar file to be opened for reading
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws SecurityException if access to the file is denied
0N/A * by the SecurityManager
0N/A */
0N/A public JarFile(String name) throws IOException {
0N/A this(new File(name), true, ZipFile.OPEN_READ);
0N/A }
0N/A
0N/A /**
0N/A * Creates a new <code>JarFile</code> to read from the specified
0N/A * file <code>name</code>.
0N/A * @param name the name of the jar file to be opened for reading
0N/A * @param verify whether or not to verify the jar file if
0N/A * it is signed.
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws SecurityException if access to the file is denied
0N/A * by the SecurityManager
0N/A */
0N/A public JarFile(String name, boolean verify) throws IOException {
0N/A this(new File(name), verify, ZipFile.OPEN_READ);
0N/A }
0N/A
0N/A /**
0N/A * Creates a new <code>JarFile</code> to read from the specified
0N/A * <code>File</code> object. The <code>JarFile</code> will be verified if
0N/A * it is signed.
0N/A * @param file the jar file to be opened for reading
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws SecurityException if access to the file is denied
0N/A * by the SecurityManager
0N/A */
0N/A public JarFile(File file) throws IOException {
0N/A this(file, true, ZipFile.OPEN_READ);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Creates a new <code>JarFile</code> to read from the specified
0N/A * <code>File</code> object.
0N/A * @param file the jar file to be opened for reading
0N/A * @param verify whether or not to verify the jar file if
0N/A * it is signed.
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws SecurityException if access to the file is denied
0N/A * by the SecurityManager.
0N/A */
0N/A public JarFile(File file, boolean verify) throws IOException {
0N/A this(file, verify, ZipFile.OPEN_READ);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Creates a new <code>JarFile</code> to read from the specified
0N/A * <code>File</code> object in the specified mode. The mode argument
0N/A * must be either <tt>OPEN_READ</tt> or <tt>OPEN_READ | OPEN_DELETE</tt>.
0N/A *
0N/A * @param file the jar file to be opened for reading
0N/A * @param verify whether or not to verify the jar file if
0N/A * it is signed.
0N/A * @param mode the mode in which the file is to be opened
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws IllegalArgumentException
0N/A * if the <tt>mode</tt> argument is invalid
0N/A * @throws SecurityException if access to the file is denied
0N/A * by the SecurityManager
0N/A * @since 1.3
0N/A */
0N/A public JarFile(File file, boolean verify, int mode) throws IOException {
0N/A super(file, mode);
0N/A this.verify = verify;
0N/A }
0N/A
0N/A /**
0N/A * Returns the jar file manifest, or <code>null</code> if none.
0N/A *
0N/A * @return the jar file manifest, or <code>null</code> if none
0N/A *
0N/A * @throws IllegalStateException
0N/A * may be thrown if the jar file has been closed
0N/A */
0N/A public Manifest getManifest() throws IOException {
0N/A return getManifestFromReference();
0N/A }
0N/A
0N/A private Manifest getManifestFromReference() throws IOException {
0N/A Manifest man = manRef != null ? manRef.get() : null;
0N/A
0N/A if (man == null) {
0N/A
0N/A JarEntry manEntry = getManEntry();
0N/A
0N/A // If found then load the manifest
0N/A if (manEntry != null) {
0N/A if (verify) {
0N/A byte[] b = getBytes(manEntry);
0N/A man = new Manifest(new ByteArrayInputStream(b));
0N/A if (!jvInitialized) {
4046N/A jv = new JarVerifier(b);
0N/A }
0N/A } else {
0N/A man = new Manifest(super.getInputStream(manEntry));
0N/A }
0N/A manRef = new SoftReference(man);
0N/A }
0N/A }
0N/A return man;
0N/A }
0N/A
0N/A private native String[] getMetaInfEntryNames();
0N/A
0N/A /**
0N/A * Returns the <code>JarEntry</code> for the given entry name or
0N/A * <code>null</code> if not found.
0N/A *
0N/A * @param name the jar file entry name
0N/A * @return the <code>JarEntry</code> for the given entry name or
0N/A * <code>null</code> if not found.
0N/A *
0N/A * @throws IllegalStateException
0N/A * may be thrown if the jar file has been closed
0N/A *
0N/A * @see java.util.jar.JarEntry
0N/A */
0N/A public JarEntry getJarEntry(String name) {
0N/A return (JarEntry)getEntry(name);
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>ZipEntry</code> for the given entry name or
0N/A * <code>null</code> if not found.
0N/A *
0N/A * @param name the jar file entry name
0N/A * @return the <code>ZipEntry</code> for the given entry name or
0N/A * <code>null</code> if not found
0N/A *
0N/A * @throws IllegalStateException
0N/A * may be thrown if the jar file has been closed
0N/A *
0N/A * @see java.util.zip.ZipEntry
0N/A */
0N/A public ZipEntry getEntry(String name) {
0N/A ZipEntry ze = super.getEntry(name);
0N/A if (ze != null) {
0N/A return new JarFileEntry(ze);
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Returns an enumeration of the zip file entries.
0N/A */
0N/A public Enumeration<JarEntry> entries() {
0N/A final Enumeration enum_ = super.entries();
0N/A return new Enumeration<JarEntry>() {
0N/A public boolean hasMoreElements() {
0N/A return enum_.hasMoreElements();
0N/A }
0N/A public JarFileEntry nextElement() {
0N/A ZipEntry ze = (ZipEntry)enum_.nextElement();
0N/A return new JarFileEntry(ze);
0N/A }
0N/A };
0N/A }
0N/A
0N/A private class JarFileEntry extends JarEntry {
0N/A JarFileEntry(ZipEntry ze) {
0N/A super(ze);
0N/A }
0N/A public Attributes getAttributes() throws IOException {
0N/A Manifest man = JarFile.this.getManifest();
0N/A if (man != null) {
0N/A return man.getAttributes(getName());
0N/A } else {
0N/A return null;
0N/A }
0N/A }
0N/A public Certificate[] getCertificates() {
0N/A try {
0N/A maybeInstantiateVerifier();
0N/A } catch (IOException e) {
0N/A throw new RuntimeException(e);
0N/A }
0N/A if (certs == null && jv != null) {
3570N/A certs = jv.getCerts(JarFile.this, this);
0N/A }
0N/A return certs == null ? null : certs.clone();
0N/A }
0N/A public CodeSigner[] getCodeSigners() {
0N/A try {
0N/A maybeInstantiateVerifier();
0N/A } catch (IOException e) {
0N/A throw new RuntimeException(e);
0N/A }
0N/A if (signers == null && jv != null) {
3570N/A signers = jv.getCodeSigners(JarFile.this, this);
0N/A }
0N/A return signers == null ? null : signers.clone();
0N/A }
0N/A }
0N/A
0N/A /*
0N/A * Ensures that the JarVerifier has been created if one is
0N/A * necessary (i.e., the jar appears to be signed.) This is done as
0N/A * a quick check to avoid processing of the manifest for unsigned
0N/A * jars.
0N/A */
0N/A private void maybeInstantiateVerifier() throws IOException {
0N/A if (jv != null) {
0N/A return;
0N/A }
0N/A
0N/A if (verify) {
0N/A String[] names = getMetaInfEntryNames();
0N/A if (names != null) {
0N/A for (int i = 0; i < names.length; i++) {
0N/A String name = names[i].toUpperCase(Locale.ENGLISH);
4046N/A if (name.endsWith(".DSA") ||
4046N/A name.endsWith(".RSA") ||
4046N/A name.endsWith(".EC") ||
4046N/A name.endsWith(".SF")) {
0N/A // Assume since we found a signature-related file
0N/A // that the jar is signed and that we therefore
0N/A // need a JarVerifier and Manifest
0N/A getManifest();
0N/A return;
0N/A }
0N/A }
0N/A }
0N/A // No signature-related files; don't instantiate a
0N/A // verifier
0N/A verify = false;
0N/A }
0N/A }
0N/A
0N/A
0N/A /*
0N/A * Initializes the verifier object by reading all the manifest
0N/A * entries and passing them to the verifier.
0N/A */
0N/A private void initializeVerifier() {
0N/A ManifestEntryVerifier mev = null;
0N/A
0N/A // Verify "META-INF/" entries...
0N/A try {
0N/A String[] names = getMetaInfEntryNames();
0N/A if (names != null) {
0N/A for (int i = 0; i < names.length; i++) {
0N/A JarEntry e = getJarEntry(names[i]);
5701N/A if (e == null) {
5701N/A throw new JarException("corrupted jar file");
5701N/A }
4046N/A if (!e.isDirectory()) {
0N/A if (mev == null) {
0N/A mev = new ManifestEntryVerifier
0N/A (getManifestFromReference());
0N/A }
4046N/A byte[] b = getBytes(e);
4046N/A if (b != null && b.length > 0) {
4046N/A jv.beginEntry(e, mev);
4046N/A jv.update(b.length, b, 0, b.length, mev);
4046N/A jv.update(-1, null, 0, 0, mev);
4046N/A }
0N/A }
0N/A }
0N/A }
0N/A } catch (IOException ex) {
0N/A // if we had an error parsing any blocks, just
0N/A // treat the jar file as being unsigned
0N/A jv = null;
0N/A verify = false;
5701N/A if (JarVerifier.debug != null) {
5701N/A JarVerifier.debug.println("jarfile parsing error!");
5701N/A ex.printStackTrace();
5701N/A }
0N/A }
0N/A
0N/A // if after initializing the verifier we have nothing
0N/A // signed, we null it out.
0N/A
0N/A if (jv != null) {
0N/A
0N/A jv.doneWithMeta();
0N/A if (JarVerifier.debug != null) {
0N/A JarVerifier.debug.println("done with meta!");
0N/A }
0N/A
0N/A if (jv.nothingToVerify()) {
0N/A if (JarVerifier.debug != null) {
0N/A JarVerifier.debug.println("nothing to verify!");
0N/A }
0N/A jv = null;
0N/A verify = false;
0N/A }
0N/A }
0N/A }
0N/A
0N/A /*
0N/A * Reads all the bytes for a given entry. Used to process the
0N/A * META-INF files.
0N/A */
0N/A private byte[] getBytes(ZipEntry ze) throws IOException {
5701N/A try (InputStream is = super.getInputStream(ze)) {
5701N/A return IOUtils.readFully(is, (int)ze.getSize(), true);
3656N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns an input stream for reading the contents of the specified
0N/A * zip file entry.
0N/A * @param ze the zip file entry
0N/A * @return an input stream for reading the contents of the specified
0N/A * zip file entry
0N/A * @throws ZipException if a zip file format error has occurred
0N/A * @throws IOException if an I/O error has occurred
0N/A * @throws SecurityException if any of the jar file entries
0N/A * are incorrectly signed.
0N/A * @throws IllegalStateException
0N/A * may be thrown if the jar file has been closed
0N/A */
0N/A public synchronized InputStream getInputStream(ZipEntry ze)
0N/A throws IOException
0N/A {
0N/A maybeInstantiateVerifier();
0N/A if (jv == null) {
0N/A return super.getInputStream(ze);
0N/A }
0N/A if (!jvInitialized) {
0N/A initializeVerifier();
0N/A jvInitialized = true;
0N/A // could be set to null after a call to
0N/A // initializeVerifier if we have nothing to
0N/A // verify
0N/A if (jv == null)
0N/A return super.getInputStream(ze);
0N/A }
0N/A
0N/A // wrap a verifier stream around the real stream
0N/A return new JarVerifier.VerifierStream(
0N/A getManifestFromReference(),
0N/A ze instanceof JarFileEntry ?
0N/A (JarEntry) ze : getJarEntry(ze.getName()),
0N/A super.getInputStream(ze),
0N/A jv);
0N/A }
0N/A
0N/A // Statics for hand-coded Boyer-Moore search in hasClassPathAttribute()
0N/A // The bad character shift for "class-path"
0N/A private static int[] lastOcc;
0N/A // The good suffix shift for "class-path"
0N/A private static int[] optoSft;
0N/A // Initialize the shift arrays to search for "class-path"
0N/A private static char[] src = {'c','l','a','s','s','-','p','a','t','h'};
0N/A static {
0N/A lastOcc = new int[128];
0N/A optoSft = new int[10];
0N/A lastOcc[(int)'c']=1;
0N/A lastOcc[(int)'l']=2;
0N/A lastOcc[(int)'s']=5;
0N/A lastOcc[(int)'-']=6;
0N/A lastOcc[(int)'p']=7;
0N/A lastOcc[(int)'a']=8;
0N/A lastOcc[(int)'t']=9;
0N/A lastOcc[(int)'h']=10;
0N/A for (int i=0; i<9; i++)
0N/A optoSft[i]=10;
0N/A optoSft[9]=1;
0N/A }
0N/A
0N/A private JarEntry getManEntry() {
0N/A if (manEntry == null) {
0N/A // First look up manifest entry using standard name
0N/A manEntry = getJarEntry(MANIFEST_NAME);
0N/A if (manEntry == null) {
0N/A // If not found, then iterate through all the "META-INF/"
0N/A // entries to find a match.
0N/A String[] names = getMetaInfEntryNames();
0N/A if (names != null) {
0N/A for (int i = 0; i < names.length; i++) {
0N/A if (MANIFEST_NAME.equals(
0N/A names[i].toUpperCase(Locale.ENGLISH))) {
0N/A manEntry = getJarEntry(names[i]);
0N/A break;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A }
0N/A return manEntry;
0N/A }
0N/A
0N/A // Returns true iff this jar file has a manifest with a class path
0N/A // attribute. Returns false if there is no manifest or the manifest
0N/A // does not contain a "Class-Path" attribute. Currently exported to
0N/A // core libraries via sun.misc.SharedSecrets.
0N/A boolean hasClassPathAttribute() throws IOException {
0N/A if (computedHasClassPathAttribute) {
0N/A return hasClassPathAttribute;
0N/A }
0N/A
0N/A hasClassPathAttribute = false;
0N/A if (!isKnownToNotHaveClassPathAttribute()) {
0N/A JarEntry manEntry = getManEntry();
0N/A if (manEntry != null) {
5701N/A byte[] b = getBytes(manEntry);
0N/A int last = b.length - src.length;
0N/A int i = 0;
0N/A next:
0N/A while (i<=last) {
0N/A for (int j=9; j>=0; j--) {
0N/A char c = (char) b[i+j];
0N/A c = (((c-'A')|('Z'-c)) >= 0) ? (char)(c + 32) : c;
0N/A if (c != src[j]) {
0N/A i += Math.max(j + 1 - lastOcc[c&0x7F], optoSft[j]);
0N/A continue next;
0N/A }
0N/A }
0N/A hasClassPathAttribute = true;
0N/A break;
0N/A }
0N/A }
0N/A }
0N/A computedHasClassPathAttribute = true;
0N/A return hasClassPathAttribute;
0N/A }
0N/A
0N/A private static String javaHome;
0N/A private static String[] jarNames;
0N/A private boolean isKnownToNotHaveClassPathAttribute() {
0N/A // Optimize away even scanning of manifest for jar files we
0N/A // deliver which don't have a class-path attribute. If one of
0N/A // these jars is changed to include such an attribute this code
0N/A // must be changed.
0N/A if (javaHome == null) {
0N/A javaHome = AccessController.doPrivileged(
0N/A new GetPropertyAction("java.home"));
0N/A }
0N/A if (jarNames == null) {
0N/A String[] names = new String[10];
0N/A String fileSep = File.separator;
0N/A int i = 0;
0N/A names[i++] = fileSep + "rt.jar";
0N/A names[i++] = fileSep + "sunrsasign.jar";
0N/A names[i++] = fileSep + "jsse.jar";
0N/A names[i++] = fileSep + "jce.jar";
0N/A names[i++] = fileSep + "charsets.jar";
0N/A names[i++] = fileSep + "dnsns.jar";
0N/A names[i++] = fileSep + "ldapsec.jar";
0N/A names[i++] = fileSep + "localedata.jar";
0N/A names[i++] = fileSep + "sunjce_provider.jar";
0N/A names[i++] = fileSep + "sunpkcs11.jar";
0N/A jarNames = names;
0N/A }
0N/A
0N/A String name = getName();
0N/A String localJavaHome = javaHome;
0N/A if (name.startsWith(localJavaHome)) {
0N/A String[] names = jarNames;
0N/A for (int i = 0; i < names.length; i++) {
0N/A if (name.endsWith(names[i])) {
0N/A return true;
0N/A }
0N/A }
0N/A }
0N/A return false;
0N/A }
3570N/A
3570N/A private synchronized void ensureInitialization() {
3570N/A try {
3570N/A maybeInstantiateVerifier();
3570N/A } catch (IOException e) {
3570N/A throw new RuntimeException(e);
3570N/A }
3570N/A if (jv != null && !jvInitialized) {
3570N/A initializeVerifier();
3570N/A jvInitialized = true;
3570N/A }
3570N/A }
3570N/A
3570N/A JarEntry newEntry(ZipEntry ze) {
3570N/A return new JarFileEntry(ze);
3570N/A }
3570N/A
3570N/A Enumeration<String> entryNames(CodeSource[] cs) {
3570N/A ensureInitialization();
3570N/A if (jv != null) {
3570N/A return jv.entryNames(this, cs);
3570N/A }
3570N/A
3570N/A /*
3570N/A * JAR file has no signed content. Is there a non-signing
3570N/A * code source?
3570N/A */
3570N/A boolean includeUnsigned = false;
3570N/A for (int i = 0; i < cs.length; i++) {
3570N/A if (cs[i].getCodeSigners() == null) {
3570N/A includeUnsigned = true;
3570N/A break;
3570N/A }
3570N/A }
3570N/A if (includeUnsigned) {
3570N/A return unsignedEntryNames();
3570N/A } else {
3570N/A return new Enumeration<String>() {
3570N/A
3570N/A public boolean hasMoreElements() {
3570N/A return false;
3570N/A }
3570N/A
3570N/A public String nextElement() {
3570N/A throw new NoSuchElementException();
3570N/A }
3570N/A };
3570N/A }
3570N/A }
3570N/A
3570N/A /**
3570N/A * Returns an enumeration of the zip file entries
3570N/A * excluding internal JAR mechanism entries and including
3570N/A * signed entries missing from the ZIP directory.
3570N/A */
3570N/A Enumeration<JarEntry> entries2() {
3570N/A ensureInitialization();
3570N/A if (jv != null) {
3570N/A return jv.entries2(this, super.entries());
3570N/A }
3570N/A
3570N/A // screen out entries which are never signed
3570N/A final Enumeration enum_ = super.entries();
3570N/A return new Enumeration<JarEntry>() {
3570N/A
3570N/A ZipEntry entry;
3570N/A
3570N/A public boolean hasMoreElements() {
3570N/A if (entry != null) {
3570N/A return true;
3570N/A }
3570N/A while (enum_.hasMoreElements()) {
3570N/A ZipEntry ze = (ZipEntry) enum_.nextElement();
3570N/A if (JarVerifier.isSigningRelated(ze.getName())) {
3570N/A continue;
3570N/A }
3570N/A entry = ze;
3570N/A return true;
3570N/A }
3570N/A return false;
3570N/A }
3570N/A
3570N/A public JarFileEntry nextElement() {
3570N/A if (hasMoreElements()) {
3570N/A ZipEntry ze = entry;
3570N/A entry = null;
3570N/A return new JarFileEntry(ze);
3570N/A }
3570N/A throw new NoSuchElementException();
3570N/A }
3570N/A };
3570N/A }
3570N/A
3570N/A CodeSource[] getCodeSources(URL url) {
3570N/A ensureInitialization();
3570N/A if (jv != null) {
3570N/A return jv.getCodeSources(this, url);
3570N/A }
3570N/A
3570N/A /*
3570N/A * JAR file has no signed content. Is there a non-signing
3570N/A * code source?
3570N/A */
3570N/A Enumeration unsigned = unsignedEntryNames();
3570N/A if (unsigned.hasMoreElements()) {
3570N/A return new CodeSource[]{JarVerifier.getUnsignedCS(url)};
3570N/A } else {
3570N/A return null;
3570N/A }
3570N/A }
3570N/A
3570N/A private Enumeration<String> unsignedEntryNames() {
3570N/A final Enumeration entries = entries();
3570N/A return new Enumeration<String>() {
3570N/A
3570N/A String name;
3570N/A
3570N/A /*
3570N/A * Grab entries from ZIP directory but screen out
3570N/A * metadata.
3570N/A */
3570N/A public boolean hasMoreElements() {
3570N/A if (name != null) {
3570N/A return true;
3570N/A }
3570N/A while (entries.hasMoreElements()) {
3570N/A String value;
3570N/A ZipEntry e = (ZipEntry) entries.nextElement();
3570N/A value = e.getName();
3570N/A if (e.isDirectory() || JarVerifier.isSigningRelated(value)) {
3570N/A continue;
3570N/A }
3570N/A name = value;
3570N/A return true;
3570N/A }
3570N/A return false;
3570N/A }
3570N/A
3570N/A public String nextElement() {
3570N/A if (hasMoreElements()) {
3570N/A String value = name;
3570N/A name = null;
3570N/A return value;
3570N/A }
3570N/A throw new NoSuchElementException();
3570N/A }
3570N/A };
3570N/A }
3570N/A
3570N/A CodeSource getCodeSource(URL url, String name) {
3570N/A ensureInitialization();
3570N/A if (jv != null) {
3570N/A if (jv.eagerValidation) {
3570N/A CodeSource cs = null;
3570N/A JarEntry je = getJarEntry(name);
3570N/A if (je != null) {
3570N/A cs = jv.getCodeSource(url, this, je);
3570N/A } else {
3570N/A cs = jv.getCodeSource(url, name);
3570N/A }
3570N/A return cs;
3570N/A } else {
3570N/A return jv.getCodeSource(url, name);
3570N/A }
3570N/A }
3570N/A
3570N/A return JarVerifier.getUnsignedCS(url);
3570N/A }
3570N/A
3570N/A void setEagerValidation(boolean eager) {
3570N/A try {
3570N/A maybeInstantiateVerifier();
3570N/A } catch (IOException e) {
3570N/A throw new RuntimeException(e);
3570N/A }
3570N/A if (jv != null) {
3570N/A jv.setEagerValidation(eager);
3570N/A }
3570N/A }
3570N/A
3570N/A List getManifestDigests() {
3570N/A ensureInitialization();
3570N/A if (jv != null) {
3570N/A return jv.getManifestDigests();
3570N/A }
3570N/A return new ArrayList();
3570N/A }
0N/A}