ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52344] Add -sigalg and -digestalg support to the signjar task
Date Fri, 16 Dec 2011 03:50:48 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52344

--- Comment #1 from Wang Weijun <wangweij@gmail.com> 2011-12-16 03:50:48 UTC ---
My proposed patch is included below. Sorry I am new to both the ant tool and
the source codes, and I don't know how to add a test.

I did manually check the result:

1. Specify a digestalg parameter and you can see changes in digest lines in
META-INF/MANIFEST.MF and META-INF/ALIAS.MF.

2. Specify a sigalg and feed the META-INF/ALIAS.RSA file to "openssl asn1parse
-inform DER" and you can see the PKCS #7 SignedData struct now uses a new
signature algorithm (look at the last 6 lines of output).


$ svn di
Index: src/main/org/apache/tools/ant/taskdefs/SignJar.java
===================================================================
--- src/main/org/apache/tools/ant/taskdefs/SignJar.java    (revision 1215029)
+++ src/main/org/apache/tools/ant/taskdefs/SignJar.java    (working copy)
@@ -110,6 +110,16 @@
     private boolean force = false;

     /**
+     * signature algorithm
+     */
+    protected String sigAlg;
+
+    /**
+     * digest algorithm
+     */
+    protected String digestAlg;
+
+    /**
      * error string for unit test verification: {@value}
      */
     public static final String ERROR_TODIR_AND_SIGNEDJAR
@@ -276,6 +286,38 @@
     }

     /**
+     * Signature Algorithm; optional
+     *
+     * @param sigAlg the signature algorithm
+     */
+    public void setSigAlg(String sigAlg) {
+        this.sigAlg = sigAlg;
+    }
+
+    /**
+     * Signature Algorithm; optional
+     */
+    public String getSigAlg() {
+        return sigAlg;
+    }
+
+    /**
+     * Digest Algorithm; optional
+     *
+     * @param digestAlg the digest algorithm
+     */
+    public void setDigestAlg(String digestAlg) {
+        this.digestAlg = digestAlg;
+    }
+
+    /**
+     * Digest Algorithm; optional
+     */
+    public String getDigestAlg() {
+        return digestAlg;
+    }
+
+    /**
      * sign the jar(s)
      *
      * @throws BuildException on errors
@@ -420,6 +462,16 @@
             addValue(cmd, "-sectionsonly");
         }

+        if (sigAlg != null) {
+            addValue(cmd, "-sigalg");
+            addValue(cmd, sigAlg);
+        }
+
+        if (digestAlg != null) {
+            addValue(cmd, "-digestalg");
+            addValue(cmd, digestAlg);
+        }
+
         //add -tsa operations if declared
         addTimestampAuthorityCommands(cmd);

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message