verify a JAR.
if (!jar.exists()) {
throw new BuildException(ERROR_NO_FILE + jar);
}
final ExecTask cmd = createJarSigner();
setCommonOptions(cmd);
bindToKeystore(cmd);
//verify special operations
addValue(cmd, "-verify");
if (certificates) {
addValue(cmd, "-certs");
}
//JAR is required
addValue(cmd, jar.getPath());
log("Verifying JAR: " + jar.getAbsolutePath());
outputCache.clear();
BuildException ex = null;
try {
cmd.execute();
} catch (BuildException e) {
ex = e;
}
String results = outputCache.toString();
//deal with jdk1.4.2 bug:
if (ex != null) {
if (results.indexOf("zip file closed") >= 0) {
log("You are running " + JARSIGNER_COMMAND + " against a JVM with"
+ " a known bug that manifests as an IllegalStateException.",
Project.MSG_WARN);
} else {
throw ex;
}
}
if (results.indexOf(VERIFIED_TEXT) < 0) {
throw new BuildException(ERROR_NO_VERIFY + jar);
}