|
|
@@ -58,6 +58,8 @@ public class VerifyJar extends AbstractJarSignerTask { |
|
|
|
/** Error output if there is a failure to verify the jar. */ |
|
|
|
public static final String ERROR_NO_VERIFY = "Failed to verify "; |
|
|
|
|
|
|
|
private String savedStorePass = null; |
|
|
|
|
|
|
|
/** |
|
|
|
* Ask for certificate information to be printed |
|
|
|
* @param certificates if true print certificates. |
|
|
@@ -99,6 +101,42 @@ public class VerifyJar extends AbstractJarSignerTask { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 1.9.11 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
protected void beginExecution() { |
|
|
|
// when using a PKCS12 keystore jarsigner -verify will not |
|
|
|
// prompt for the keystore password but will only properly |
|
|
|
// verify the jar with -strict enabled if the -storepass |
|
|
|
// parameter is used. Note that the documentation of jarsigner |
|
|
|
// says -storepass was never required with -verify - this is |
|
|
|
// wrong. |
|
|
|
// |
|
|
|
// See https://bz.apache.org/bugzilla/show_bug.cgi?id=62194 |
|
|
|
// |
|
|
|
// So if strict is true then we hide storepass from the base |
|
|
|
// implementation and instead add the -storepass command line |
|
|
|
// argument |
|
|
|
if (mustHideStorePass()) { |
|
|
|
savedStorePass = storepass; |
|
|
|
setStorepass(null); |
|
|
|
} |
|
|
|
super.beginExecution(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @since 1.9.11 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
protected void endExecution() { |
|
|
|
if (savedStorePass != null) { |
|
|
|
setStorepass(savedStorePass); |
|
|
|
savedStorePass = null; |
|
|
|
} |
|
|
|
super.endExecution(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* verify a JAR. |
|
|
|
* @param jar the jar to verify. |
|
|
@@ -112,6 +150,10 @@ public class VerifyJar extends AbstractJarSignerTask { |
|
|
|
|
|
|
|
setCommonOptions(cmd); |
|
|
|
bindToKeystore(cmd); |
|
|
|
if (savedStorePass != null) { |
|
|
|
addValue(cmd, "-storepass"); |
|
|
|
addValue(cmd, savedStorePass); |
|
|
|
} |
|
|
|
|
|
|
|
//verify special operations |
|
|
|
addValue(cmd, "-verify"); |
|
|
@@ -151,6 +193,10 @@ public class VerifyJar extends AbstractJarSignerTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private boolean mustHideStorePass() { |
|
|
|
return strict && storepass != null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* we are not thread safe here. Do not use on multiple threads at the same time. |
|
|
|
*/ |
|
|
|