org.apache.tools.ant.taskdefs
Class SignJar

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.tools.ant.taskdefs.SignJar

public class SignJar
extends Task

Signs JAR or ZIP files with the javasign command line tool. The tool detailed dependency checking: files are only signed if they are not signed. The signjar attribute can point to the file to generate; if this file exists then its modification date is used as a cue as to whether to resign any JAR file.

Since:
Ant 1.1

Field Summary
protected  java.lang.String alias
          The alias of signer.
protected  java.util.Vector filesets
          the filesets of the jars to sign
protected  boolean internalsf
           
protected  java.io.File jar
          The name of the jar file.
protected  java.lang.String keypass
           
protected  boolean lazy
          Whether to assume a jar which has an appropriate .SF file in is already signed.
protected  boolean sectionsonly
           
protected  java.lang.String sigfile
           
protected  java.io.File signedjar
           
protected  java.lang.String storepass
           
protected  java.lang.String storetype
           
protected  boolean verbose
           
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
SignJar()
           
 
Method Summary
 void addFileset(FileSet set)
          Adds a set of files to sign
 void execute()
          sign the jar(s)
protected  boolean isSigned(java.io.File file)
          test for a file being signed, by looking for a signature in the META-INF directory
protected  boolean isUpToDate(java.io.File jarFile, java.io.File signedjarFile)
           
 void setAlias(java.lang.String alias)
          the alias to sign under; required
 void setInternalsf(boolean internalsf)
          Flag to include the .SF file inside the signature; optional; default false
 void setJar(java.io.File jar)
          the jar file to sign; required
 void setKeypass(java.lang.String keypass)
          password for private key (if different); optional
 void setKeystore(java.lang.String keystore)
          keystore location; required
 void setLazy(boolean lazy)
          flag to control whether the presence of a signature file means a JAR is signed; optional, default false
 void setMaxmemory(java.lang.String max)
          Set the maximum memory to be used by the jarsigner process
 void setSectionsonly(boolean sectionsonly)
          flag to compute hash of entire manifest; optional, default false
 void setSigfile(java.lang.String sigfile)
          name of .SF/.DSA file; optional
 void setSignedjar(java.io.File signedjar)
          name of signed JAR file; optional
 void setStorepass(java.lang.String storepass)
          password for keystore integrity; required
 void setStoretype(java.lang.String storetype)
          keystore type; optional
 void setVerbose(boolean verbose)
          Enable verbose output when signing ; optional: default false
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jar

protected java.io.File jar
The name of the jar file.


alias

protected java.lang.String alias
The alias of signer.


storepass

protected java.lang.String storepass

storetype

protected java.lang.String storetype

keypass

protected java.lang.String keypass

sigfile

protected java.lang.String sigfile

signedjar

protected java.io.File signedjar

verbose

protected boolean verbose

internalsf

protected boolean internalsf

sectionsonly

protected boolean sectionsonly

filesets

protected java.util.Vector filesets
the filesets of the jars to sign


lazy

protected boolean lazy
Whether to assume a jar which has an appropriate .SF file in is already signed.

Constructor Detail

SignJar

public SignJar()
Method Detail

setMaxmemory

public void setMaxmemory(java.lang.String max)
Set the maximum memory to be used by the jarsigner process

Parameters:
max - a string indicating the maximum memory according to the JVM conventions (e.g. 128m is 128 Megabytes)

setJar

public void setJar(java.io.File jar)
the jar file to sign; required


setAlias

public void setAlias(java.lang.String alias)
the alias to sign under; required


setKeystore

public void setKeystore(java.lang.String keystore)
keystore location; required


setStorepass

public void setStorepass(java.lang.String storepass)
password for keystore integrity; required


setStoretype

public void setStoretype(java.lang.String storetype)
keystore type; optional


setKeypass

public void setKeypass(java.lang.String keypass)
password for private key (if different); optional


setSigfile

public void setSigfile(java.lang.String sigfile)
name of .SF/.DSA file; optional


setSignedjar

public void setSignedjar(java.io.File signedjar)
name of signed JAR file; optional


setVerbose

public void setVerbose(boolean verbose)
Enable verbose output when signing ; optional: default false


setInternalsf

public void setInternalsf(boolean internalsf)
Flag to include the .SF file inside the signature; optional; default false


setSectionsonly

public void setSectionsonly(boolean sectionsonly)
flag to compute hash of entire manifest; optional, default false


setLazy

public void setLazy(boolean lazy)
flag to control whether the presence of a signature file means a JAR is signed; optional, default false


addFileset

public void addFileset(FileSet set)
Adds a set of files to sign

Since:
Ant 1.4

execute

public void execute()
             throws BuildException
sign the jar(s)

Overrides:
execute in class Task
Throws:
BuildException - if something goes wrong with the build

isUpToDate

protected boolean isUpToDate(java.io.File jarFile,
                             java.io.File signedjarFile)

isSigned

protected boolean isSigned(java.io.File file)
test for a file being signed, by looking for a signature in the META-INF directory

Parameters:
file -
Returns:
true if the file is signed


Copyright 2000-2005 Apache Software Foundation. All Rights Reserved.