Signing a jar allows users to authenticate the publisher.
-Signs JAR files with the jarsigner command line tool. +
Signs JAR files with the jarsigner command line tool. It will take a named file in the jar attribute, and an optional destDir or signedJar attribute. Nested paths are also supported; here only an (optional) destDir is allowed. If a destination @@ -40,10 +40,10 @@ Dependency rules
jarsigner
executable
@@ -156,14 +166,14 @@ blockTimestamped JAR files were introduced in Java1.5 and supported in Ant since -Ant 1.7. Ant does not yet support proxy setup for this signing process. +Ant 1.7. Since Ant 1.9.5, Ant can use unauthenticated proxies for this signing process.
Common public timestamp authorities include diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java index 7f9b1ee52..009280409 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java @@ -98,6 +98,16 @@ public class SignJar extends AbstractJarSignerTask { */ protected String tsaurl; + /** + * Proxy host to be used when connecting to TSA server + */ + protected String tsaproxyhost; + + /** + * Proxy port to be used when connecting to TSA server + */ + protected String tsaproxyport; + /** * alias for the TSA in the keystore */ @@ -250,6 +260,42 @@ public class SignJar extends AbstractJarSignerTask { this.tsaurl = tsaurl; } + /** + * Get the proxy host to be used when connecting to the TSA url + * @return url or null + * @since Ant 1.9.5 + */ + public String getTsaproxyhost() { + return tsaproxyhost; + } + + /** + * + * @param tsaproxyhost the proxy host to be used when connecting to the TSA. + * @since Ant 1.9.5 + */ + public void setTsaproxyhost(String tsaproxyhost) { + this.tsaproxyhost = tsaproxyhost; + } + + /** + * Get the proxy host to be used when connecting to the TSA url + * @return url or null + * @since Ant 1.9.5 + */ + public String getTsaproxyport() { + return tsaproxyport; + } + + /** + * + * @param tsaproxyport the proxy port to be used when connecting to the TSA. + * @since Ant 1.9.5 + */ + public void setTsaproxyport(String tsaproxyport) { + this.tsaproxyport = tsaproxyport; + } + /** * get the -tsacert option * @since Ant 1.7 @@ -322,7 +368,7 @@ public class SignJar extends AbstractJarSignerTask { * @throws BuildException on errors */ @Override - public void execute() throws BuildException { + public void execute() throws BuildException { //validation logic final boolean hasJar = jar != null; final boolean hasSignedJar = signedjar != null; @@ -504,10 +550,26 @@ public class SignJar extends AbstractJarSignerTask { addValue(cmd, "-tsa"); addValue(cmd, tsaurl); } + if (tsacert != null) { addValue(cmd, "-tsacert"); addValue(cmd, tsacert); } + + if (tsaproxyhost != null) { + final String connectionType; + if (tsaurl.startsWith("https")) { + connectionType = "https"; + } else { + connectionType = "http"; + } + + addValue(cmd, "-J-D" + connectionType + ".proxyHost=" + tsaproxyhost); + + if (tsaproxyport != null) { + addValue(cmd, "-J-D" + connectionType + ".proxyPort=" + tsaproxyport); + } + } } /**