Beispiel #1
0
    /**
     * Returns whether the argument provided is the same as the attribute name.
     *
     * @return if the attribute names correspond.
     * @param object An attribute name to be compared with this name.
     */
    @Override
    public boolean equals(Object object) {
      if (object == null || object.getClass() != getClass() || object.hashCode() != hashCode()) {
        return false;
      }

      return Util.asciiEqualsIgnoreCase(name, ((Name) object).name);
    }
Beispiel #2
0
  /**
   * 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
    ZipEntry[] metaEntries = getMetaEntriesImpl();
    if (metaEntries == null) {
      verifier = null;
      return;
    }

    boolean signed = false;

    for (ZipEntry entry : metaEntries) {
      String entryName = entry.getName();
      // Is this the entry for META-INF/MANIFEST.MF ?
      if (manifestEntry == null && 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
            && (Util.asciiEndsWithIgnoreCase(entryName, ".SF")
                || Util.asciiEndsWithIgnoreCase(entryName, ".DSA")
                || Util.asciiEndsWithIgnoreCase(entryName, ".RSA"))) {
          signed = true;
          InputStream is = super.getInputStream(entry);
          byte[] buf = getAllBytesFromStreamAndClose(is);
          verifier.addMetaEntry(entryName, buf);
        }
      }
    }

    // If there were no signature files, then no verifier work to do.
    if (!signed) {
      verifier = null;
    }
  }