Class JarSignerUtil

java.lang.Object
org.apache.maven.shared.jarsigner.JarSignerUtil

public class JarSignerUtil extends Object
Useful methods.
Since:
1.0
  • Constructor Details

    • JarSignerUtil

      private JarSignerUtil()
  • Method Details

    • isZipFile

      public static boolean isZipFile(File file)
      Checks whether the specified file is a JAR file. For our purposes, a ZIP file is a ZIP stream with at least one entry.
      Parameters:
      file - The file to check, must not be null.
      Returns:
      true if the file looks like a ZIP file, false otherwise.
    • unsignArchive

      public static void unsignArchive(File jarFile) throws IOException
      Removes any existing signatures from the specified JAR file. We will stream from the input JAR directly to the output JAR to retain as much metadata from the original JAR as possible.
      Parameters:
      jarFile - The JAR file to unsign, must not be null.
      Throws:
      IOException - when error occurs during processing the file
    • buildUnsignedManifest

      protected static Manifest buildUnsignedManifest(Manifest manifest)
      Build a new manifest from the given one, removing any signing information inside it. This is done by removing any attributes containing some digest information. If an entry has then no more attributes, then it will not be written in the result manifest.
      Parameters:
      manifest - manifest to clean
      Returns:
      the build manifest with no digest attributes
      Since:
      1.3
    • isArchiveSigned

      public static boolean isArchiveSigned(File jarFile) throws IOException
      Scans an archive for existing signatures.
      Parameters:
      jarFile - The archive to scan, must not be null.
      Returns:
      true, if the archive contains at least one signature file; false, if the archive does not contain any signature files.
      Throws:
      IOException - if scanning jarFile fails.
    • isSignatureFile

      protected static boolean isSignatureFile(String entryName)
      Checks whether the specified JAR file entry denotes a signature-related file, i.e. matches META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA or META-INF/*.EC.
      Parameters:
      entryName - The name of the JAR file entry to check, must not be null.
      Returns:
      true if the entry is related to a signature, false otherwise.
    • isManifestFile

      protected static boolean isManifestFile(String entryName)
    • endsWithIgnoreCase

      private static boolean endsWithIgnoreCase(String str, String searchStr)