/** Mark certificate chain as trusted. */
 public void trustCertificateChain(List trustedChain) {
   if (trustedCerts == null) {
     trustedCerts = new ArrayList(untrustedCerts.size());
   }
   trustedCerts.add(trustedChain);
   untrustedCerts.remove(trustedChain);
   if (untrustedCerts.isEmpty()) {
     untrustedCerts = null;
   }
 }
 /**
  * Get a FileArchive handle to a named Jar file or directory within this archive.
  *
  * @param path Name of Jar file or directory to get.
  * @return A FileArchive object representing new archive, null if not found.
  * @exception IOException if we failed to get top of file archive.
  */
 public FileArchive getFileArchive(String path) {
   if (".".equals(path)) {
     return archive;
   }
   if (archives == null) {
     archives = new ArrayList();
   }
   try {
     Archive a = new Archive(archive, path, archives.size() + 1);
     archives.add(a);
     return a;
   } catch (IOException io) {
     // TBD, Where to log this
     return null;
   }
 }
 /**
  * Return certificates for signed bundle, otherwise null.
  *
  * @return An array of certificates or null.
  */
 public ArrayList getCertificateChains(boolean onlyTrusted) {
   if (checkCerts) {
     Certificate[] c = archive.getCertificates();
     checkCerts = false;
     if (c != null) {
       ArrayList failed = new ArrayList();
       untrustedCerts = Util.getCertificateChains(c, failed);
       if (!failed.isEmpty()) {
         // NYI, log Bundle archive has invalid certificates
         untrustedCerts = null;
       }
     }
   }
   ArrayList res = trustedCerts;
   if (!onlyTrusted && untrustedCerts != null) {
     if (res == null) {
       res = untrustedCerts;
     } else {
       res = new ArrayList(trustedCerts.size() + untrustedCerts.size());
       res.addAll(trustedCerts);
       res.addAll(untrustedCerts);
     }
   }
   return res;
 }
 /** Close archive for further access. It should still be possible to get attributes. */
 public void close() {
   if (archives != null) {
     for (Iterator i = archives.iterator(); i.hasNext(); ) {
       ((Archive) i.next()).close();
     }
     archives = null;
   }
   archive.close();
 }
 /**
  * Get a BundleResourceStream to named entry inside a bundle. Leading '/' is stripped.
  *
  * @param component Entry to get reference to.
  * @param ix index of sub archives. A postive number is the classpath entry index. 0 means look in
  *     the main bundle.
  * @return BundleResourceStream to entry or null if it doesn't exist.
  */
 public BundleResourceStream getBundleResourceStream(String component, int ix) {
   if (component.startsWith("/")) {
     component = component.substring(1);
   }
   if (ix == 0) {
     return archive.getBundleResourceStream(component);
   } else {
     return ((FileArchive) archives.get(ix - 1)).getBundleResourceStream(component);
   }
 }