/** * Returns the {@code Manifest} object associated with this {@code JarFile} * or {@code null} if no MANIFEST entry exists. * * @return the MANIFEST. * @throws IOException * if an error occurs reading the MANIFEST file. * @throws IllegalStateException * if the jar file is closed. * @see Manifest */ public Manifest getManifest() // throws IOException { { if (closed) { // archive.35=JarFile has been closed throw new java.lang.IllegalStateException("JarFile has been closed"); //$NON-NLS-1$ } if (manifest != null) { return(manifest); } try { java.io.InputStream isJ = base.getInputStream(manifestEntry); if (verifier != null) { verifier.addMetaEntry(manifestEntry.getName(), org.apache.harmony.luni.util.InputStreamHelper.readFullyAndClose(isJ)); isJ = base.getInputStream(manifestEntry); } try { manifest = new Manifest(isJ, verifier != null); } finally { isJ.close(); } manifestEntry = null; // Can discard the entry now. } catch (java.lang.NullPointerException) { manifestEntry = null; } return(manifest); }
/** * Called by the JarFile constructors, this method reads the contents of the * file's META-INF/ directory and picks out the MANIFEST.MF file and * verifier signature files if they exist. Any signature files found are * registered with the verifier. * * @throws IOException * if there is a problem reading the jar file entries. */ private void readMetaEntries() // throws IOException { // Get all meta directory entries { java.util.zip.ZipEntry[] metaEntries = getMetaEntriesImpl(); if (metaEntries == null) { verifier = null; return; } bool signed = false; foreach (java.util.zip.ZipEntry entry in metaEntries) { String entryName = entry.getName(); // Is this the entry for META-INF/MANIFEST.MF ? if (manifestEntry == null && org.apache.harmony.archive.util.Util.asciiEqualsIgnoreCase(MANIFEST_NAME, entryName)) { manifestEntry = entry; // If there is no verifier then we don't need to look any further. if (verifier == null) { break; } } else { // Is this an entry that the verifier needs? if (verifier != null && (org.apache.harmony.archive.util.Util.asciiEndsWithIgnoreCase(entryName, ".SF") || org.apache.harmony.archive.util.Util.asciiEndsWithIgnoreCase(entryName, ".DSA") || org.apache.harmony.archive.util.Util.asciiEndsWithIgnoreCase(entryName, ".RSA"))) { signed = true; java.io.InputStream isJ = base.getInputStream(entry); byte[] buf = org.apache.harmony.luni.util.InputStreamHelper.readFullyAndClose(isJ); verifier.addMetaEntry(entryName, buf); } } } // If there were no signature files, then no verifier work to do. if (!signed) { verifier = null; } }
/** * Creates a new zip entry with fields taken from the specified zip entry. * * <p />Assumes the entry represents a directory if and only if the * name ends with a forward slash "/". * * @param entry the entry to get fields from * @throws ZipException on error */ public ZipArchiveEntry(java.util.zip.ZipEntry entry) : base(entry) //throws ZipException { setName(entry.getName()); byte[] extra = entry.getExtra(); if (extra != null) { setExtraFields(ExtraFieldUtils.parse(extra, true, //ExtraFieldUtils. UnparseableExtraField.READ)); } else { // initializes extra data to an empty byte array setExtra(); } setMethod(entry.getMethod()); }
/** * Returns all the ZipEntry's that relate to files in the * JAR's META-INF directory. * * @return the list of ZipEntry's or {@code null} if there are none. */ private java.util.zip.ZipEntry[] getMetaEntriesImpl() { List <java.util.zip.ZipEntry> list = new ArrayList <java.util.zip.ZipEntry>(8); Enumeration <java.util.zip.ZipEntry> allEntries = entries(); while (allEntries.hasMoreElements()) { java.util.zip.ZipEntry ze = allEntries.nextElement(); if (ze.getName().startsWith(META_DIR) && ze.getName().length() > META_DIR.length()) { list.add(ze); } } if (list.size() == 0) { return(null); } java.util.zip.ZipEntry[] result = new java.util.zip.ZipEntry[list.size()]; list.toArray(result); return(result); }
public JarArchiveEntry(java.util.zip.ZipEntry entry) : base(entry) { }