home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / jar / JarInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  113 lines

  1. package java.util.jar;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.ByteArrayInputStream;
  5. import java.io.ByteArrayOutputStream;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.util.zip.ZipEntry;
  9. import java.util.zip.ZipInputStream;
  10. import sun.security.util.ManifestEntryVerifier;
  11.  
  12. public class JarInputStream extends ZipInputStream {
  13.    private Manifest man;
  14.    private JarEntry first;
  15.    // $FF: renamed from: jv java.util.jar.JarVerifier
  16.    private JarVerifier field_0;
  17.    private ManifestEntryVerifier mev;
  18.  
  19.    public JarInputStream(InputStream var1) throws IOException {
  20.       this(var1, true);
  21.    }
  22.  
  23.    public JarInputStream(InputStream var1, boolean var2) throws IOException {
  24.       super(var1);
  25.       JarEntry var3 = (JarEntry)super.getNextEntry();
  26.       if (var3 != null && ((ZipEntry)var3).getName().equalsIgnoreCase("META-INF/")) {
  27.          var3 = (JarEntry)super.getNextEntry();
  28.       }
  29.  
  30.       if (var3 != null && "META-INF/MANIFEST.MF".equalsIgnoreCase(((ZipEntry)var3).getName())) {
  31.          this.man = new Manifest();
  32.          byte[] var4 = this.getBytes(new BufferedInputStream(this));
  33.          this.man.read(new ByteArrayInputStream(var4));
  34.          ((ZipInputStream)this).closeEntry();
  35.          if (var2) {
  36.             this.field_0 = new JarVerifier(this.man, var4);
  37.             this.mev = new ManifestEntryVerifier(this.man);
  38.          }
  39.  
  40.          this.first = this.getNextJarEntry();
  41.       } else {
  42.          this.first = var3;
  43.       }
  44.  
  45.    }
  46.  
  47.    private byte[] getBytes(InputStream var1) throws IOException {
  48.       byte[] var2 = new byte[8192];
  49.       ByteArrayOutputStream var3 = new ByteArrayOutputStream(2048);
  50.       var3.reset();
  51.  
  52.       int var4;
  53.       while((var4 = var1.read(var2, 0, var2.length)) != -1) {
  54.          var3.write(var2, 0, var4);
  55.       }
  56.  
  57.       return var3.toByteArray();
  58.    }
  59.  
  60.    public Manifest getManifest() {
  61.       return this.man;
  62.    }
  63.  
  64.    public ZipEntry getNextEntry() throws IOException {
  65.       JarEntry var1;
  66.       if (this.first == null) {
  67.          var1 = (JarEntry)super.getNextEntry();
  68.       } else {
  69.          var1 = this.first;
  70.          this.first = null;
  71.       }
  72.  
  73.       if (this.field_0 != null && var1 != null) {
  74.          if (this.field_0.nothingToVerify()) {
  75.             this.field_0 = null;
  76.             this.mev = null;
  77.          } else {
  78.             this.field_0.beginEntry(var1, this.mev);
  79.          }
  80.       }
  81.  
  82.       return var1;
  83.    }
  84.  
  85.    public JarEntry getNextJarEntry() throws IOException {
  86.       return (JarEntry)this.getNextEntry();
  87.    }
  88.  
  89.    public int read(byte[] var1, int var2, int var3) throws IOException {
  90.       int var4;
  91.       if (this.first == null) {
  92.          var4 = super.read(var1, var2, var3);
  93.       } else {
  94.          var4 = -1;
  95.       }
  96.  
  97.       if (this.field_0 != null) {
  98.          this.field_0.update(var4, var1, var2, var3, this.mev);
  99.       }
  100.  
  101.       return var4;
  102.    }
  103.  
  104.    protected ZipEntry createZipEntry(String var1) {
  105.       JarEntry var2 = new JarEntry(var1);
  106.       if (this.man != null) {
  107.          var2.attr = this.man.getAttributes(var1);
  108.       }
  109.  
  110.       return var2;
  111.    }
  112. }
  113.