diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2bdf72f2e..b3ed9ffe6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -43,6 +43,7 @@ Christoph Wilhelms Christophe Labouisse Christopher A. Longo Christopher Charlier +Clemens Hammacher Conor MacNeill Craeg Strong Craig Cottingham diff --git a/WHATSNEW b/WHATSNEW index 9c3925c94..59938a3bb 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -214,6 +214,10 @@ Fixed bugs: the link's target. Bugzilla Report 41525. + * when checking whether a jar is signed, ignored the + sigfile attribute. + Bugzilla Report 44805. + Other changes: -------------- diff --git a/contributors.xml b/contributors.xml index f78b0322d..4f9d3993d 100644 --- a/contributors.xml +++ b/contributors.xml @@ -194,6 +194,10 @@ Christopher Charlier + + Clemens + Hammacher + Conor MacNeill diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java index 2b1aa8e6e..ed62f3a0e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java @@ -474,7 +474,7 @@ public class SignJar extends AbstractJarSignerTask { /** * test for a file being signed, by looking for a signature in the META-INF - * directory with our alias. + * directory with our alias/sigfile. * * @param file the file to be checked * @return true if the file is signed @@ -482,7 +482,7 @@ public class SignJar extends AbstractJarSignerTask { */ protected boolean isSigned(File file) { try { - return IsSigned.isSigned(file, alias); + return IsSigned.isSigned(file, sigfile == null ? alias : sigfile); } catch (IOException e) { //just log this log(e.toString(), Project.MSG_VERBOSE); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java index a232d6aa1..ece8eeadb 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java @@ -18,6 +18,7 @@ package org.apache.tools.ant.taskdefs; +import java.io.File; import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.util.JavaEnvUtils; @@ -56,6 +57,27 @@ public class SignJarTest extends BuildFileTest { public void testSigFile() { executeTarget("sigfile"); + SignJarChild sj = new SignJarChild(); + sj.setAlias("testonly"); + sj.setKeystore("testkeystore"); + sj.setStorepass("apacheant"); + File jar = new File(getProject().getProperty("test.jar")); + sj.setJar(jar); + assertFalse("mustn't find signature without sigfile attribute", + sj.isSigned()); + sj.setSigfile("TEST"); + assertTrue("must find signature with sigfile attribute", + sj.isSigned()); + } + + /** + * subclass in order to get access to protected isSigned method if + * tests and task come from different classloaders. + */ + private static class SignJarChild extends SignJar { + public boolean isSigned() { + return isSigned(jar); + } } public void testMaxMemory() {