Exemplo n.º 1
0
 private synchronized Map signerMap() {
   if (signerMap == null) {
     /*
      * Snapshot signer state so it doesn't change on us. We care
      * only about the asserted signatures. Verification of
      * signature validity happens via the JarEntry apis.
      */
     signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size());
     signerMap.putAll(verifiedSigners);
     signerMap.putAll(sigFileSigners);
   }
   return signerMap;
 }
Exemplo n.º 2
0
  /*
   * Like entries() but screens out internal JAR mechanism entries
   * and includes signed entries with no ZIP data.
   */
  public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration e) {
    final Map map = new HashMap();
    map.putAll(signerMap());
    final Enumeration enum_ = e;
    return new Enumeration<JarEntry>() {

      Enumeration signers = null;
      JarEntry entry;

      public boolean hasMoreElements() {
        if (entry != null) {
          return true;
        }
        while (enum_.hasMoreElements()) {
          ZipEntry ze = (ZipEntry) enum_.nextElement();
          if (JarVerifier.isSigningRelated(ze.getName())) {
            continue;
          }
          entry = jar.newEntry(ze);
          return true;
        }
        if (signers == null) {
          signers = Collections.enumeration(map.keySet());
        }
        while (signers.hasMoreElements()) {
          String name = (String) signers.nextElement();
          entry = jar.newEntry(new ZipEntry(name));
          return true;
        }

        // Any map entries left?
        return false;
      }

      public JarEntry nextElement() {
        if (hasMoreElements()) {
          JarEntry je = entry;
          map.remove(je.getName());
          entry = null;
          return je;
        }
        throw new NoSuchElementException();
      }
    };
  }