diff --git a/WHATSNEW b/WHATSNEW
index ff59e6314..19b2c0f96 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -38,6 +38,14 @@ Other changes:
* junitlauncher task now supports forking and can be used with JaCoCo
(see https://github.com/jacoco/jacoco/issues/673).
+ * signjar and verifyjar now support the -providerName, -providerClass
+ and -providerArg command line options of keytool via new attributes.
+ Bugzilla Report 65234
+
+ * signjar and verifyjar now supported nested elements for
+ command line arguments that are not supported explicitly by the
+ tasks via attributes.
+
Changes from Ant 1.10.4 TO Ant 1.10.5
=====================================
diff --git a/manual/Tasks/signjar.html b/manual/Tasks/signjar.html
index 03f915659..bc098e791 100644
--- a/manual/Tasks/signjar.html
+++ b/manual/Tasks/signjar.html
@@ -178,6 +178,29 @@ place.
name of TSA digest algorithm. since Ant 1.10.2 |
No |
+
+ providername |
+ name of a cryptographic service provider's name
+ when listed in the security properties file.
+ since Ant 1.10.6. |
+ No |
+
+
+ providerclass |
+ name of a cryptographic service provider's master
+ class file when the service provider is not listed in the security
+ properties file.
+ since Ant 1.10.6. |
+ No |
+
+
+ providerarg |
+ Represents an optional string input argument for
+ the constructor of provider_class_name. Ignored
+ if providerclass is not set.
+ since Ant 1.10.6. |
+ No |
+
Parameters as nested elements
@@ -207,7 +230,15 @@ place.
variables
No, and only one can be supplied |
-
+
+ arg |
+ Use this to specify a keytool
+ command line argument not
+ explicitly supported via an attribute.
+ since Ant 1.10.6. |
+ No |
+
+
Examples
For instructions on generating a code signing certificate, see
diff --git a/manual/Tasks/verifyjar.html b/manual/Tasks/verifyjar.html
index db140f06c..e519d23c4 100644
--- a/manual/Tasks/verifyjar.html
+++ b/manual/Tasks/verifyjar.html
@@ -100,6 +100,29 @@ the jar attribute. Nested paths are also supported.
options as the Sun JDK jarsigner command. since Ant 1.8.0.
No |
+
+ providername |
+ name of a cryptographic service provider's name
+ when listed in the security properties file.
+ since Ant 1.10.6. |
+ No |
+
+
+ providerclass |
+ name of a cryptographic service provider's master
+ class file when the service provider is not listed in the security
+ properties file.
+ since Ant 1.10.6. |
+ No |
+
+
+ providerarg |
+ Represents an optional string input argument for
+ the constructor of provider_class_name. Ignored
+ if providerclass is not set.
+ since Ant 1.10.6. |
+ No |
+
Parameters as nested elements
@@ -124,6 +147,14 @@ the jar attribute. Nested paths are also supported.
variables
No, and only one can be supplied |
+
+ arg |
+ Use this to specify a keytool
+ command line argument not
+ explicitly supported via an attribute.
+ since Ant 1.10.6. |
+ No |
+
Examples
diff --git a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
index 2fadd12bf..fa2741f58 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
@@ -1,4 +1,4 @@
-/*
+g/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -19,11 +19,14 @@
package org.apache.tools.ant.taskdefs;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.filters.LineContainsRegExp;
+import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Environment;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
@@ -116,6 +119,15 @@ public abstract class AbstractJarSignerTask extends Task {
*/
private String executable;
+ /**
+ * Values for the providerName, providerClass, and providerArg options.
+ *
+ * @since Ant 1.10.6
+ */
+ private String providerName, providerClass, providerArg;
+
+ private List additionalArgs = new ArrayList();
+
/**
* Set the maximum memory to be used by the jarsigner process
*
@@ -230,6 +242,49 @@ public abstract class AbstractJarSignerTask extends Task {
return path.createPath();
}
+ /**
+ * Sets the value for the -providerName command line argument.
+ *
+ * @param providerName the value for the -providerName command line argument
+ *
+ * @since Ant 1.10.6
+ */
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ /**
+ * Sets the value for the -providerClass command line argument.
+ *
+ * @param providerClass the value for the -providerClass command line argument
+ *
+ * @since Ant 1.10.6
+ */
+ public void setProviderClass(String providerClass) {
+ this.providerClass = providerClass;
+ }
+
+ /**
+ * Sets the value for the -providerArg command line argument.
+ *
+ * @param providerArg the value for the -providerArg command line argument
+ *
+ * @since Ant 1.10.6
+ */
+ public void setProviderArg(String providerArg) {
+ this.providerArg = providerArg;
+ }
+
+ /**
+ * Adds a nested <arg> element that can be used to specify
+ * command line arguments not supported via specific attributes.
+ *
+ * @since Ant 1.10.6
+ */
+ public void addArg(Commandline.Argument arg) {
+ additionalArgs.add(arg);
+ }
+
/**
* init processing logic; this is retained through our execution(s)
*/
@@ -311,6 +366,10 @@ public abstract class AbstractJarSignerTask extends Task {
for (Environment.Variable variable : sysProperties.getVariablesVector()) {
declareSysProperty(cmd, variable);
}
+
+ for (Commandline.Argument arg : additionalArgs) {
+ addArgument(cmd, arg);
+ }
}
/**
@@ -346,6 +405,20 @@ public abstract class AbstractJarSignerTask extends Task {
addValue(cmd, "-storetype");
addValue(cmd, storetype);
}
+ if (null != providerName) {
+ addValue(cmd, "-providerName");
+ addValue(cmd, providerName);
+ }
+ if (null != providerClass) {
+ addValue(cmd, "-providerClass");
+ addValue(cmd, providerClass);
+ if (null != providerArg) {
+ addValue(cmd, "-providerArg");
+ addValue(cmd, providerArg);
+ }
+ } else if (null != providerArg) {
+ log("Ignoring providerArg as providerClass has not been set");
+ }
}
/**
@@ -417,4 +490,13 @@ public abstract class AbstractJarSignerTask extends Task {
protected void addValue(final ExecTask cmd, String value) {
cmd.createArg().setValue(value);
}
+
+ /**
+ * add an argument to a command
+ * @param cmd command to manipulate
+ * @param arg argument to add
+ */
+ protected void addArgument(final ExecTask cmd, Commandline.Argument arg) {
+ cmd.createArg().copyFrom(arg);
+ }
}
diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java
index 4653c7755..a39099053 100644
--- a/src/main/org/apache/tools/ant/types/Commandline.java
+++ b/src/main/org/apache/tools/ant/types/Commandline.java
@@ -178,6 +178,17 @@ public class Commandline implements Cloneable {
this.suffix = suffix != null ? suffix : "";
}
+ /**
+ * Copies settings from a different argument.
+ *
+ * @since Ant 1.10.6
+ */
+ public void copyFrom(Argument other) {
+ this.parts = other.parts;
+ this.prefix = other.prefix;
+ this.suffix = other.suffix;
+ }
+
/**
* Return the constituent parts of this Argument.
* @return an array of strings.