org.apache.tools.ant.taskdefs

Class AbstractJarSignerTask

public abstract class AbstractJarSignerTask extends Task

This is factored out from {@link SignJar}; a base class that can be used for both signing and verifying JAR files using jarsigner
Field Summary
protected Stringalias
The alias of signer.
static StringERROR_NO_SOURCE
error string for unit test verification: {@value}
protected Vectorfilesets
the filesets of the jars to sign
protected Filejar
The name of the jar file.
protected static StringJARSIGNER_COMMAND
name of JDK program we are looking for
protected Stringkeypass
password for the key in the store
protected Stringkeystore
The url or path of keystore file.
protected StringmaxMemory
The maximum amount of memory to use for Jar signer
protected Stringstorepass
password for the store
protected Stringstoretype
type of store,-storetype param
protected booleanverbose
verbose output
Method Summary
voidaddFileset(FileSet set)
Adds a set of files to sign
voidaddSysproperty(Environment.Variable sysp)
Add a system property.
protected voidaddValue(ExecTask cmd, String value)
add a value argument to a command
protected voidbeginExecution()
init processing logic; this is retained through our execution(s)
protected voidbindToKeystore(ExecTask cmd)
bind to a keystore if the attributes are there
protected ExecTaskcreateJarSigner()
create the jarsigner executable task
PathcreatePath()
Adds a path of files to sign.
protected PathcreateUnifiedSourcePath()
clone our path and add all explicitly specified FileSets as well, patch in the jar attribute as a new fileset if it is defined.
protected VectorcreateUnifiedSources()
clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined
protected voiddeclareSysProperty(ExecTask cmd, Environment.Variable property)
protected voidendExecution()
any cleanup logic
RedirectorElementgetRedirector()
get the redirector.
protected booleanhasResources()
Has either a path or a fileset been specified?
voidsetAlias(String alias)
the alias to sign under; required
protected voidsetCommonOptions(ExecTask cmd)
these are options common to signing and verifying
voidsetJar(File jar)
the jar file to sign; required
voidsetKeypass(String keypass)
password for private key (if different); optional
voidsetKeystore(String keystore)
keystore location; required
voidsetMaxmemory(String max)
Set the maximum memory to be used by the jarsigner process
voidsetStorepass(String storepass)
password for keystore integrity; required
voidsetStoretype(String storetype)
keystore type; optional
voidsetVerbose(boolean verbose)
Enable verbose output when signing ; optional: default false

Field Detail

alias

protected String alias
The alias of signer.

ERROR_NO_SOURCE

public static final String ERROR_NO_SOURCE
error string for unit test verification: {@value}

filesets

protected Vector filesets
the filesets of the jars to sign

jar

protected File jar
The name of the jar file.

JARSIGNER_COMMAND

protected static final String JARSIGNER_COMMAND
name of JDK program we are looking for

keypass

protected String keypass
password for the key in the store

keystore

protected String keystore
The url or path of keystore file.

maxMemory

protected String maxMemory
The maximum amount of memory to use for Jar signer

storepass

protected String storepass
password for the store

storetype

protected String storetype
type of store,-storetype param

verbose

protected boolean verbose
verbose output

Method Detail

addFileset

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

Parameters: set a set of files to sign

Since: Ant 1.4

addSysproperty

public void addSysproperty(Environment.Variable sysp)
Add a system property.

Parameters: sysp system property.

addValue

protected void addValue(ExecTask cmd, String value)
add a value argument to a command

Parameters: cmd command to manipulate value value to add

beginExecution

protected void beginExecution()
init processing logic; this is retained through our execution(s)

bindToKeystore

protected void bindToKeystore(ExecTask cmd)
bind to a keystore if the attributes are there

Parameters: cmd command to configure

createJarSigner

protected ExecTask createJarSigner()
create the jarsigner executable task

Returns: a task set up with the executable of jarsigner, failonerror=true and bound to our redirector

createPath

public Path createPath()
Adds a path of files to sign.

Returns: a path of files to sign.

Since: Ant 1.7

createUnifiedSourcePath

protected Path createUnifiedSourcePath()
clone our path and add all explicitly specified FileSets as well, patch in the jar attribute as a new fileset if it is defined.

Returns: a path that contains all files to sign

Since: Ant 1.7

createUnifiedSources

protected Vector createUnifiedSources()
clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined

Returns: a vector of FileSet instances

declareSysProperty

protected void declareSysProperty(ExecTask cmd, Environment.Variable property)

Parameters: cmd command to configure property property to set

Throws: BuildException if the property is not correctly defined.

endExecution

protected void endExecution()
any cleanup logic

getRedirector

public RedirectorElement getRedirector()
get the redirector. Non-null between invocations of {@link #beginExecution()} and {@link #endExecution()}

Returns: a redirector or null

hasResources

protected boolean hasResources()
Has either a path or a fileset been specified?

Returns: true if a path or fileset has been specified.

Since: Ant 1.7

setAlias

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

Parameters: alias the alias to sign under

setCommonOptions

protected void setCommonOptions(ExecTask cmd)
these are options common to signing and verifying

Parameters: cmd command to configure

setJar

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

Parameters: jar the jar file to sign

setKeypass

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

Parameters: keypass the password for the key (if different)

setKeystore

public void setKeystore(String keystore)
keystore location; required

Parameters: keystore the keystore location

setMaxmemory

public void setMaxmemory(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)

setStorepass

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

Parameters: storepass the password for the keystore

setStoretype

public void setStoretype(String storetype)
keystore type; optional

Parameters: storetype the keystore type

setVerbose

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

Parameters: verbose if true enable verbose output