src/java.base/share/classes/java/util/jar/JarVerifier.java

Print this page




 707                     return true;
 708                 }
 709                 return false;
 710             }
 711 
 712             public String nextElement() {
 713                 if (hasMoreElements()) {
 714                     String value = name;
 715                     name = null;
 716                     return value;
 717                 }
 718                 throw new NoSuchElementException();
 719             }
 720         };
 721     }
 722 
 723     /*
 724      * Like entries() but screens out internal JAR mechanism entries
 725      * and includes signed entries with no ZIP data.
 726      */
 727     public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
 728         final Map<String, CodeSigner[]> map = new HashMap<>();
 729         map.putAll(signerMap());
 730         final Enumeration<? extends ZipEntry> enum_ = e;
 731         return new Enumeration<>() {
 732 
 733             Enumeration<String> signers = null;
 734             JarEntry entry;
 735 
 736             public boolean hasMoreElements() {
 737                 if (entry != null) {
 738                     return true;
 739                 }
 740                 while (enum_.hasMoreElements()) {
 741                     ZipEntry ze = enum_.nextElement();
 742                     if (JarVerifier.isSigningRelated(ze.getName())) {
 743                         continue;
 744                     }
 745                     entry = jar.newEntry(ze);
 746                     return true;
 747                 }
 748                 if (signers == null) {
 749                     signers = Collections.enumeration(map.keySet());
 750                 }
 751                 while (signers.hasMoreElements()) {
 752                     String name = signers.nextElement();
 753                     entry = jar.newEntry(new ZipEntry(name));
 754                     return true;
 755                 }
 756 
 757                 // Any map entries left?
 758                 return false;
 759             }
 760 
 761             public JarEntry nextElement() {
 762                 if (hasMoreElements()) {
 763                     JarEntry je = entry;
 764                     map.remove(je.getName());
 765                     entry = null;
 766                     return je;
 767                 }
 768                 throw new NoSuchElementException();
 769             }
 770         };
 771     }
 772     private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
 773 




 707                     return true;
 708                 }
 709                 return false;
 710             }
 711 
 712             public String nextElement() {
 713                 if (hasMoreElements()) {
 714                     String value = name;
 715                     name = null;
 716                     return value;
 717                 }
 718                 throw new NoSuchElementException();
 719             }
 720         };
 721     }
 722 
 723     /*
 724      * Like entries() but screens out internal JAR mechanism entries
 725      * and includes signed entries with no ZIP data.
 726      */
 727     public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<JarEntry> e) {
 728         final Map<String, CodeSigner[]> map = new HashMap<>();
 729         map.putAll(signerMap());
 730         final Enumeration<JarEntry> enum_ = e;
 731         return new Enumeration<>() {
 732 
 733             Enumeration<String> signers = null;
 734             JarEntry entry;
 735 
 736             public boolean hasMoreElements() {
 737                 if (entry != null) {
 738                     return true;
 739                 }
 740                 while (enum_.hasMoreElements()) {
 741                     JarEntry je = enum_.nextElement();
 742                     if (JarVerifier.isSigningRelated(je.getName())) {
 743                         continue;
 744                     }
 745                     entry = jar.newEntry(je);
 746                     return true;
 747                 }
 748                 if (signers == null) {
 749                     signers = Collections.enumeration(map.keySet());
 750                 }
 751                 while (signers.hasMoreElements()) {
 752                     String name = signers.nextElement();
 753                     entry = jar.newEntry(name);
 754                     return true;
 755                 }
 756 
 757                 // Any map entries left?
 758                 return false;
 759             }
 760 
 761             public JarEntry nextElement() {
 762                 if (hasMoreElements()) {
 763                     JarEntry je = entry;
 764                     map.remove(je.getName());
 765                     entry = null;
 766                     return je;
 767                 }
 768                 throw new NoSuchElementException();
 769             }
 770         };
 771     }
 772     private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
 773