Browse Source

Restore ability of signjar keystore to take a URL

PR:     10672


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273807 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
5034769eb7
5 changed files with 51 additions and 18 deletions
  1. +4
    -0
      WHATSNEW
  2. +9
    -8
      build.xml
  3. +17
    -5
      src/etc/testcases/taskdefs/signjar.xml
  4. +14
    -5
      src/main/org/apache/tools/ant/taskdefs/SignJar.java
  5. +7
    -0
      src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java

+ 4
- 0
WHATSNEW View File

@@ -17,6 +17,10 @@ Changes that could break older environments:
* The <script> task now requires Apache BSF instead of the older IBM * The <script> task now requires Apache BSF instead of the older IBM
version. See <http://jakarta.apache.org/bsf/> version. See <http://jakarta.apache.org/bsf/>


* The signjar keystore attribute has been reverted to a String allowing
it to once again accept URLs. This should not affect current FIle based usage
unless you are extending the Signjar task.

* <xmlproperty> will no longer fail if the file to be loaded doesn't exist. * <xmlproperty> will no longer fail if the file to be loaded doesn't exist.


Fixed bugs: Fixed bugs:


+ 9
- 8
build.xml View File

@@ -289,6 +289,7 @@
</selector> </selector>
<patternset id="onlinetests"> <patternset id="onlinetests">
<exclude name="**/GetTest.java" if="offline"/> <exclude name="**/GetTest.java" if="offline"/>
<exclude name="**/SignJarTest.java" if="offline"/>
</patternset> </patternset>
<patternset id="teststhatfail"> <patternset id="teststhatfail">
<exclude name="${optional.package}/BeanShellScriptTest.java"/> <exclude name="${optional.package}/BeanShellScriptTest.java"/>
@@ -577,14 +578,14 @@
<selector refid="needs.sun.tools" unless="sun.tools.present"/> <selector refid="needs.sun.tools" unless="sun.tools.present"/>
<selector refid="needs.sun.uue" unless="sunuue.present"/> <selector refid="needs.sun.uue" unless="sunuue.present"/>
<selector refid="needs.sun.b64" unless="base64.present"/> <selector refid="needs.sun.b64" unless="base64.present"/>
<selector refid="needs.trax" unless="trax.present"/> <selector refid="needs.trax" unless="trax.present"/>
<selector refid="needs.xalan1" unless="xalan.present"/> <selector refid="needs.xalan1" unless="xalan.present"/>
<selector refid="needs.xalan2" unless="xalan2.present"/> <selector refid="needs.xalan2" unless="xalan2.present"/>
<selector refid="needs.xslp" unless="xslp.present"/> <selector refid="needs.xslp" unless="xslp.present"/>
<selector refid="needs.apache.resolver" unless="apache.resolver.present"/> <selector refid="needs.apache.resolver" unless="apache.resolver.present"/>
<selector refid="needs.junit" unless="junit.present"/> <selector refid="needs.junit" unless="junit.present"/>
<selector refid="needs.jakarta.regexp"
<selector refid="needs.jakarta.regexp"
unless="jakarta.regexp.present"/> unless="jakarta.regexp.present"/>
<selector refid="needs.jakarta.oro" unless="jakarta.oro.present"/> <selector refid="needs.jakarta.oro" unless="jakarta.oro.present"/>
<selector refid="needs.jakarta.bcel" unless="bcel.present"/> <selector refid="needs.jakarta.bcel" unless="bcel.present"/>
@@ -597,7 +598,7 @@
<selector refid="needs.icontract" unless="icontract.present"/> <selector refid="needs.icontract" unless="icontract.present"/>
<selector refid="needs.netrexx" unless="netrexx.present"/> <selector refid="needs.netrexx" unless="netrexx.present"/>
<selector refid="needs.weblogic.ejbc" unless="ejb.ejbc.present"/> <selector refid="needs.weblogic.ejbc" unless="ejb.ejbc.present"/>
<selector refid="needs.weblogic.ddcreator"
<selector refid="needs.weblogic.ddcreator"
unless="ejb.DDCreator.present"/> unless="ejb.DDCreator.present"/>
<selector refid="needs.weblogic.server" unless="ejb.wls.present"/> <selector refid="needs.weblogic.server" unless="ejb.wls.present"/>
<selector refid="needs.netcomponents" unless="netcomp.present"/> <selector refid="needs.netcomponents" unless="netcomp.present"/>
@@ -782,7 +783,7 @@
<metainf dir="${build.dir}" includes="LICENSE.txt"/> <metainf dir="${build.dir}" includes="LICENSE.txt"/>
</jar> </jar>


<jar destfile="${build.lib}/${optional.jars.prefix}-trax.jar"
<jar destfile="${build.lib}/${optional.jars.prefix}-trax.jar"
basedir="${build.classes}" basedir="${build.classes}"
manifest="${manifest.tmp}"> manifest="${manifest.tmp}">
<selector refid="needs.trax"/> <selector refid="needs.trax"/>
@@ -818,7 +819,7 @@
<selector refid="needs.junit"/> <selector refid="needs.junit"/>
</jar> </jar>


<jar destfile="${build.lib}/${optional.jars.prefix}-jakarta-regexp.jar"
<jar destfile="${build.lib}/${optional.jars.prefix}-jakarta-regexp.jar"
basedir="${build.classes}" manifest="${manifest.tmp}"> basedir="${build.classes}" manifest="${manifest.tmp}">
<selector refid="needs.jakarta.regexp"/> <selector refid="needs.jakarta.regexp"/>
</jar> </jar>
@@ -829,7 +830,7 @@
<selector refid="needs.jakarta.oro"/> <selector refid="needs.jakarta.oro"/>
</jar> </jar>


<jar destfile="${build.lib}/${optional.jars.prefix}-bcel.jar"
<jar destfile="${build.lib}/${optional.jars.prefix}-bcel.jar"
basedir="${build.classes}" basedir="${build.classes}"
manifest="${manifest.tmp}"> manifest="${manifest.tmp}">
<selector refid="needs.jakarta.bcel"/> <selector refid="needs.jakarta.bcel"/>
@@ -841,7 +842,7 @@
<selector refid="needs.jakarta.log4j"/> <selector refid="needs.jakarta.log4j"/>
</jar> </jar>


<jar destfile="${build.lib}/${optional.jars.prefix}-commons-logging.jar"
<jar destfile="${build.lib}/${optional.jars.prefix}-commons-logging.jar"
basedir="${build.classes}" manifest="${manifest.tmp}"> basedir="${build.classes}" manifest="${manifest.tmp}">
<selector refid="needs.commons.logging"/> <selector refid="needs.commons.logging"/>
</jar> </jar>
@@ -1595,7 +1596,7 @@
<target name="run-single-test" if="testcase" depends="compile-tests,run-single-test-only" <target name="run-single-test" if="testcase" depends="compile-tests,run-single-test-only"
description="--> runs the single unit test defined in the testcase property"/> description="--> runs the single unit test defined in the testcase property"/>


<target name="run-single-test-only"
<target name="run-single-test-only"
description="--> runs the single unit test defined in the testcase property"> description="--> runs the single unit test defined in the testcase property">






+ 17
- 5
src/etc/testcases/taskdefs/signjar.xml View File

@@ -1,24 +1,36 @@
<project name="signjartest" default="help">
<property name="classes.dir" value="../../../../build/classes"/>
<project name="signjartest" default="help" basedir="..">
<property name="classes.dir" value="../../../build/classes"/>


<target name="basic"> <target name="basic">
<jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/> <jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
<signjar jar="signtest.jar" alias="testonly" keystore="testkeystore"
storepass="apacheant"/> storepass="apacheant"/>
</target> </target>


<target name="sigfile"> <target name="sigfile">
<jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/> <jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
<signjar jar="signtest.jar" alias="testonly" keystore="testkeystore"
storepass="apacheant" sigfile="TEST"/> storepass="apacheant" sigfile="TEST"/>
</target> </target>


<target name="maxmemory"> <target name="maxmemory">
<jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/> <jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
<signjar jar="signtest.jar" alias="testonly" keystore="testkeystore"
storepass="apacheant" maxmemory="128m"/> storepass="apacheant" maxmemory="128m"/>
</target> </target>


<target name="urlKeystoreFile">
<jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="file://../testkeystore"
storepass="apacheant" maxmemory="128m"/>
</target>

<target name="urlKeystoreHTTP">
<jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly"
keystore="http://cvs.apache.org/viewcvs.cgi/*checkout*/jakarta-ant/src/etc/testcases/testkeystore?rev=HEAD"
storepass="apacheant" maxmemory="128m"/>
</target>


<target name="clean"> <target name="clean">
<delete file="signtest.jar"/> <delete file="signtest.jar"/>


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

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -97,7 +97,7 @@ public class SignJar extends Task {
/** /**
* The name of keystore file. * The name of keystore file.
*/ */
protected File keystore;
private String keystore;


protected String storepass; protected String storepass;
protected String storetype; protected String storetype;
@@ -115,6 +115,7 @@ public class SignJar extends Task {
* the filesets of the jars to sign * the filesets of the jars to sign
*/ */
protected Vector filesets = new Vector(); protected Vector filesets = new Vector();

/** /**
* Whether to assume a jar which has an appropriate .SF file in is already * Whether to assume a jar which has an appropriate .SF file in is already
* signed. * signed.
@@ -149,7 +150,7 @@ public class SignJar extends Task {
/** /**
* keystore location; required * keystore location; required
*/ */
public void setKeystore(final File keystore) {
public void setKeystore(final String keystore) {
this.keystore = keystore; this.keystore = keystore;
} }


@@ -286,8 +287,16 @@ public class SignJar extends Task {
} }


if (null != keystore) { if (null != keystore) {
cmd.createArg().setValue("-keystore");
cmd.createArg().setValue(keystore.toString());
// is the keystore a file
File keystoreFile = getProject().resolveFile(keystore);
if (keystoreFile.exists()) {
cmd.createArg().setValue("-keystore");
cmd.createArg().setValue(keystoreFile.getPath());
} else {
// must be a URL - just pass as is
cmd.createArg().setValue("-keystore");
cmd.createArg().setValue(keystore);
}
} }


if (null != storepass) { if (null != storepass) {


+ 7
- 0
src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java View File

@@ -97,4 +97,11 @@ public class SignJarTest extends BuildFileTest {
executeTarget("maxmemory"); executeTarget("maxmemory");
} }


public void testURLKeystoreFile() {
executeTarget("urlKeystoreFile");
}

public void testURLKeystoreHTTP() {
executeTarget("urlKeystoreHTTP");
}
} }

Loading…
Cancel
Save