private void readSignatures() throws IOException
void readSignatures() throws IOException
  private void readSignatures() throws IOException  {    Map pkcs7Dsa = new HashMap();    Map pkcs7Rsa = new HashMap();    Map sigFiles = new HashMap();    // Phase 1: Read all signature files. These contain the user    // certificates as well as the signatures themselves.    for (Enumeration e = super.entries(); e.hasMoreElements(); )      {        ZipEntry ze = (ZipEntry) e.nextElement();        String name = ze.getName();        if (name.startsWith(META_INF))          {            String alias = name.substring(META_INF.length());            if (alias.lastIndexOf('.') >= 0)              alias = alias.substring(0, alias.lastIndexOf('.'));            if (name.endsWith(PKCS7_DSA_SUFFIX) || name.endsWith(PKCS7_RSA_SUFFIX))              {                if (DEBUG)                  debug("reading PKCS7 info from " + name + ", alias=" + alias);                PKCS7SignedData sig = null;                try                  {                    sig = new PKCS7SignedData(super.getInputStream(ze));                  }                catch (CertificateException ce)                  {                    IOException ioe = new IOException("certificate parsing error");                    ioe.initCause(ce);                    throw ioe;                  }                catch (CRLException crle)                  {                    IOException ioe = new IOException("CRL parsing error");                    ioe.initCause(crle);                    throw ioe;                  }                if (name.endsWith(PKCS7_DSA_SUFFIX))                  pkcs7Dsa.put(alias, sig);                else if (name.endsWith(PKCS7_RSA_SUFFIX))                  pkcs7Rsa.put(alias, sig);              }            else if (name.endsWith(SF_SUFFIX))              {                if (DEBUG)                  debug("reading signature file for " + alias + ": " + name);                Manifest sf = new Manifest(super.getInputStream(ze));                sigFiles.put(alias, sf);                if (DEBUG)                  debug("result: " + sf);              }          }      }    // Phase 2: verify the signatures on any signature files.    Set validCerts = new HashSet();    Map entryCerts = new HashMap();    for (Iterator it = sigFiles.entrySet().iterator(); it.hasNext(); )      {        int valid = 0;        Map.Entry e = (Map.Entry) it.next();        String alias = (String) e.getKey();        PKCS7SignedData sig = (PKCS7SignedData) pkcs7Dsa.get(alias);        if (sig != null)          {            Certificate[] certs = sig.getCertificates();            Set signerInfos = sig.getSignerInfos();            for (Iterator it2 = signerInfos.iterator(); it2.hasNext(); )              verify(certs, (SignerInfo) it2.next(), alias, validCerts);          }        sig = (PKCS7SignedData) pkcs7Rsa.get(alias);        if (sig != null)          {            Certificate[] certs = sig.getCertificates();            Set signerInfos = sig.getSignerInfos();            for (Iterator it2 = signerInfos.iterator(); it2.hasNext(); )              verify(certs, (SignerInfo) it2.next(), alias, validCerts);          }        // It isn't a signature for anything. Punt it.        if (validCerts.isEmpty())          {            it.remove();            continue;          }        entryCerts.put(e.getValue(), new HashSet(validCerts));        validCerts.clear();      }    // Phase 3: verify the signature file signatures against the manifest,    // mapping the entry name to the target certificates.    this.entryCerts = new HashMap();    for (Iterator it = entryCerts.entrySet().iterator(); it.hasNext(); )      {        Map.Entry e = (Map.Entry) it.next();        Manifest sigfile = (Manifest) e.getKey();        Map entries = sigfile.getEntries();        Set certificates = (Set) e.getValue();        for (Iterator it2 = entries.entrySet().iterator(); it2.hasNext(); )          {            Map.Entry e2 = (Map.Entry) it2.next();            String entryname = String.valueOf(e2.getKey());            Attributes attr = (Attributes) e2.getValue();            if (verifyHashes(entryname, attr))              {                if (DEBUG)                  debug("entry " + entryname + " has certificates " + certificates);                Set s = (Set) this.entryCerts.get(entryname);                if (s != null)                  s.addAll(certificates);                else                  this.entryCerts.put(entryname, new HashSet(certificates));              }          }      }    signaturesRead = true;  }