|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.ProjectComponent org.apache.tools.ant.Task org.apache.tools.ant.taskdefs.AbstractJarSignerTask org.apache.tools.ant.taskdefs.SignJar
public class SignJar
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. Timestamp driven signing is based on the unstable and inadequately documented information in the Java1.5 docs
Field Summary | |
---|---|
protected java.io.File |
destDir
the output directory when using paths. |
static java.lang.String |
ERROR_BAD_MAP
error string for unit test verification: "Cannot map source file to anything sensible: " |
static java.lang.String |
ERROR_MAPPER_WITHOUT_DEST
error string for unit test verification: "The destDir attribute is required if a mapper is set" |
static java.lang.String |
ERROR_NO_ALIAS
error string for unit test verification: "alias attribute must be set" |
static java.lang.String |
ERROR_NO_STOREPASS
error string for unit test verification: "storepass attribute must be set" |
static java.lang.String |
ERROR_SIGNEDJAR_AND_PATHS
error string for unit test verification "You cannot specify the signed JAR when using paths or filesets" |
static java.lang.String |
ERROR_TODIR_AND_SIGNEDJAR
error string for unit test verification: "\'destdir\' and \'signedjar\' cannot both be set" |
static java.lang.String |
ERROR_TOO_MANY_MAPPERS
error string for unit test verification: "Too many mappers" |
protected boolean |
internalsf
flag for internal sf signing |
protected boolean |
lazy
Whether to assume a jar which has an appropriate .SF file in is already signed. |
protected boolean |
sectionsonly
sign sections only? |
protected java.lang.String |
sigfile
name to a signature file |
protected java.io.File |
signedjar
name of a single jar |
protected java.lang.String |
tsacert
alias for the TSA in the keystore |
protected java.lang.String |
tsaurl
URL for a tsa; null implies no tsa support |
Fields inherited from class org.apache.tools.ant.taskdefs.AbstractJarSignerTask |
---|
alias, ERROR_NO_SOURCE, filesets, jar, JARSIGNER_COMMAND, keypass, keystore, maxMemory, storepass, storetype, strict, verbose |
Fields inherited from class org.apache.tools.ant.Task |
---|
target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
---|
description, location, project |
Constructor Summary | |
---|---|
SignJar()
|
Method Summary | |
---|---|
void |
add(FileNameMapper newMapper)
add a mapper to determine file naming policy. |
void |
execute()
sign the jar(s) |
java.lang.String |
getDigestAlg()
Digest Algorithm; optional |
FileNameMapper |
getMapper()
get the active mapper; may be null |
java.lang.String |
getSigAlg()
Signature Algorithm; optional |
java.lang.String |
getTsacert()
get the -tsacert option |
java.lang.String |
getTsaurl()
get the -tsaurl url |
boolean |
isForce()
Should the task force signing of a jar even it is already signed? |
protected boolean |
isSigned(java.io.File file)
test for a file being signed, by looking for a signature in the META-INF directory with our alias/sigfile. |
protected boolean |
isUpToDate(java.io.File jarFile,
java.io.File signedjarFile)
Compare a jar file with its corresponding signed jar. |
void |
setDestDir(java.io.File destDir)
Optionally sets the output directory to be used. |
void |
setDigestAlg(java.lang.String digestAlg)
Digest Algorithm; optional |
void |
setForce(boolean b)
Whether to force signing of a jar even it is already signed. |
void |
setInternalsf(boolean internalsf)
Flag to include the .SF file inside the signature; optional; default false |
void |
setLazy(boolean lazy)
flag to control whether the presence of a signature file means a JAR is signed; optional, default false |
void |
setPreserveLastModified(boolean preserveLastModified)
true to indicate that the signed jar modification date remains the same as the original. |
void |
setSectionsonly(boolean sectionsonly)
flag to compute hash of entire manifest; optional, default false |
void |
setSigAlg(java.lang.String sigAlg)
Signature Algorithm; optional |
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 |
setTsacert(java.lang.String tsacert)
set the alias in the keystore of the TSA to use; |
void |
setTsaurl(java.lang.String tsaurl)
|
Methods inherited from class org.apache.tools.ant.taskdefs.AbstractJarSignerTask |
---|
addFileset, addSysproperty, addValue, beginExecution, bindToKeystore, createJarSigner, createPath, createUnifiedSourcePath, createUnifiedSources, declareSysProperty, endExecution, getRedirector, hasResources, setAlias, setCommonOptions, setExecutable, setJar, setKeypass, setKeystore, setMaxmemory, setStorepass, setStoretype, setStrict, setVerbose |
Methods inherited from class org.apache.tools.ant.Task |
---|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
---|
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String sigfile
protected java.io.File signedjar
protected boolean internalsf
protected boolean sectionsonly
protected boolean lazy
protected java.io.File destDir
protected java.lang.String tsaurl
protected java.lang.String tsacert
public static final java.lang.String ERROR_TODIR_AND_SIGNEDJAR
public static final java.lang.String ERROR_TOO_MANY_MAPPERS
public static final java.lang.String ERROR_SIGNEDJAR_AND_PATHS
public static final java.lang.String ERROR_BAD_MAP
public static final java.lang.String ERROR_MAPPER_WITHOUT_DEST
public static final java.lang.String ERROR_NO_ALIAS
public static final java.lang.String ERROR_NO_STOREPASS
Constructor Detail |
---|
public SignJar()
Method Detail |
---|
public void setSigfile(java.lang.String sigfile)
sigfile
- the name of the .SF/.DSA filepublic void setSignedjar(java.io.File signedjar)
signedjar
- the name of the signed jar filepublic void setInternalsf(boolean internalsf)
internalsf
- if true include the .SF file inside the signaturepublic void setSectionsonly(boolean sectionsonly)
sectionsonly
- flag to compute hash of entire manifestpublic void setLazy(boolean lazy)
lazy
- flag to control whether the presence of a signaturepublic void setDestDir(java.io.File destDir)
destDir
- the directory in which to place signed jarspublic void add(FileNameMapper newMapper)
newMapper
- the mapper to add.public FileNameMapper getMapper()
public java.lang.String getTsaurl()
public void setTsaurl(java.lang.String tsaurl)
tsaurl
- the tsa url.public java.lang.String getTsacert()
public void setTsacert(java.lang.String tsacert)
tsacert
- the cert alias.public void setForce(boolean b)
public boolean isForce()
public void setSigAlg(java.lang.String sigAlg)
sigAlg
- the signature algorithmpublic java.lang.String getSigAlg()
public void setDigestAlg(java.lang.String digestAlg)
digestAlg
- the digest algorithmpublic java.lang.String getDigestAlg()
public void execute() throws BuildException
execute
in class Task
BuildException
- on errorsprotected boolean isUpToDate(java.io.File jarFile, java.io.File signedjarFile)
Compare a jar file with its corresponding signed jar. The logic for this is complex, and best explained in the source itself. Essentially if either file doesnt exist, or the destfile has an out of date timestamp, then the return value is false.
If we are signing ourself, the check isSigned(File)
is used to
trigger the process.
jarFile
- the unsigned jar filesignedjarFile
- the result signed jar file
protected boolean isSigned(java.io.File file)
file
- the file to be checked
IsSigned.isSigned(File, String)
public void setPreserveLastModified(boolean preserveLastModified)
preserveLastModified
- if true preserve the last modified time
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |