Browse Source

use sigfile attribute when checking whether a jar is already signed. PR 44805. Submitted by Clemens Hammacher.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@695797 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
dda05149e5
5 changed files with 33 additions and 2 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/SignJar.java
  5. +22
    -0
      src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java

+ 1
- 0
CONTRIBUTORS View File

@@ -43,6 +43,7 @@ Christoph Wilhelms
Christophe Labouisse
Christopher A. Longo
Christopher Charlier
Clemens Hammacher
Conor MacNeill
Craeg Strong
Craig Cottingham


+ 4
- 0
WHATSNEW View File

@@ -214,6 +214,10 @@ Fixed bugs:
the link's target.
Bugzilla Report 41525.

* when checking whether a jar is signed, <signjar> ignored the
sigfile attribute.
Bugzilla Report 44805.

Other changes:
--------------



+ 4
- 0
contributors.xml View File

@@ -194,6 +194,10 @@
<first>Christopher</first>
<last>Charlier</last>
</name>
<name>
<first>Clemens</first>
<last>Hammacher</last>
</name>
<name>
<first>Conor</first>
<last>MacNeill</last>


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/SignJar.java View File

@@ -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);


+ 22
- 0
src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java View File

@@ -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() {


Loading…
Cancel
Save