Class JarSignerUtil
java.lang.Object
org.apache.maven.shared.jarsigner.JarSignerUtil
-
Method Summary
Modifier and TypeMethodDescriptionprotected static Manifest
buildUnsignedManifest
(Manifest manifest) Build a new manifest from the given one, removing any signing information inside it.static boolean
isArchiveSigned
(File jarFile) Scans an archive for existing signatures.protected static boolean
isManifestFile
(String entryName) protected static boolean
isSignatureFile
(String entryName) Checks whether the specified JAR file entry denotes a signature-related file, i.e.static boolean
Checks whether the specified file is a JAR file.static void
unsignArchive
(File jarFile) Removes any existing signatures from the specified JAR file.
-
Method Details
-
isZipFile
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 benull
.- Returns:
true
if the file looks like a ZIP file,false
otherwise.
-
unsignArchive
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 benull
.- Throws:
IOException
- when error occurs during processing the file
-
buildUnsignedManifest
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
Scans an archive for existing signatures.- Parameters:
jarFile
- The archive to scan, must not benull
.- Returns:
true
, if the archive contains at least one signature file;false
, if the archive does not contain any signature files.- Throws:
IOException
- if scanningjarFile
fails.
-
isSignatureFile
Checks whether the specified JAR file entry denotes a signature-related file, i.e. matchesMETA-INF/*.SF
,META-INF/*.DSA
,META-INF/*.RSA
orMETA-INF/*.EC
.- Parameters:
entryName
- The name of the JAR file entry to check, must not benull
.- Returns:
true
if the entry is related to a signature,false
otherwise.
-
isManifestFile
-