Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public abstract Class AbstractJarSignerTask

extends Task
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.SignJar, org.apache.tools.ant.taskdefs.VerifyJar
Imports
java.io.File, java.util.ArrayList, .List, .Vector, org.apache.tools.ant.BuildException, .Task, org.apache.tools.ant.filters.LineContainsRegExp, org.apache.tools.ant.types.Commandline, .Environment, .FileSet, .Path, .RedirectorElement, .RegularExpression, org.apache.tools.ant.util.JavaEnvUtils

This is factored out from SignJar; a base class that can be used for both signing and verifying JAR files using jarsigner

Field Summary

Modifier and TypeField and Description
private List<Commandline.Argument>
protected String
alias

The alias of signer.

public static final String
ERROR_NO_SOURCE

error string for unit test verification: jar must be set through jar attribute or nested filesets

private String
executable

The executable to use instead of jarsigner.

protected Vector<FileSet>
filesets

the filesets of the jars to sign

protected File
jar

The name of the jar file.

protected static final String
JARSIGNER_COMMAND

name of JDK program we are looking for

protected String
keypass

password for the key in the store

protected String
keystore

The url or path of keystore file.

protected String
maxMemory

The maximum amount of memory to use for Jar signer

private Path
path

Path holding all non-filesets of filesystem resources we want to sign.

private String
providerArg

Values for the providerName, providerClass, and providerArg options.

private String
providerClass

Values for the providerName, providerClass, and providerArg options.

private String
providerName

Values for the providerName, providerClass, and providerArg options.

private RedirectorElement
redirector

redirector used to talk to the jarsigner program

protected String
storepass

password for the store

protected String
storetype

type of store,-storetype param

protected boolean
strict

strict checking

private Environment
sysProperties

Java declarations -J-Dname=value

protected boolean
verbose

verbose output

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addArg(Commandline.Argument
the argument to add
arg
)

Adds a nested <arg> element that can be used to specify command line arguments not supported via specific attributes.

protected void
addArgument(final ExecTask
command to manipulate
cmd
,
Commandline.Argument
argument to add
arg
)

add an argument to a command

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

Adds a set of files to sign

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

Add a system property.

protected void
addValue(final ExecTask
command to manipulate
cmd
,
String
value to add
value
)

add a value argument to a command

protected void
beginExecution()

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

protected void
bindToKeystore(final ExecTask
command to configure
cmd
)

bind to a keystore if the attributes are there

protected ExecTask

Returns:

a task set up with the executable of jarsigner, failonerror=true and bound to our redirector
createJarSigner
()

create the jarsigner executable task

public Path

Returns:

a path of files to sign.
createPath
()

Adds a path of files to sign.

private RedirectorElement

Returns:

a configured RedirectorElement.
createRedirector
()

Create the redirector to use, if any.

protected Path

Returns:

a path that contains all files to sign
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.

protected Vector<FileSet>

Returns:

a vector of FileSet instances
createUnifiedSources
()

clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined

protected void
declareSysProperty(ExecTask
command to configure
cmd
,
Environment.Variable
property to set
property
)

protected void
endExecution()

any cleanup logic

public RedirectorElement

Returns:

a redirector or null
getRedirector
()

get the redirector.

protected boolean

Returns:

true if a path or fileset has been specified.
hasResources
()

Has either a path or a fileset been specified?

public void
setAlias(final String
the alias to sign under
alias
)

the alias to sign under; required

protected void
setCommonOptions(final ExecTask
command to configure
cmd
)

these are options common to signing and verifying

public void
setExecutable(String
the command to invoke.
executable
)

Sets the actual executable command to invoke, instead of the binary jarsigner found in Ant's JDK.

public void
setJar(final File
the jar file to sign
jar
)

the jar file to sign; required

public void
setKeypass(final String
the password for the key (if different)
keypass
)

password for private key (if different); optional

public void
setKeystore(final String
the keystore location
keystore
)

keystore location; required

public void
setMaxmemory(String
a string indicating the maximum memory according to the JVM conventions (e.g. 128m is 128 Megabytes)
max
)

Set the maximum memory to be used by the jarsigner process

public void
setProviderArg(String
the value for the -providerArg command line argument
providerArg
)

Sets the value for the -providerArg command line argument.

public void
setProviderClass(String
the value for the -providerClass command line argument
providerClass
)

Sets the value for the -providerClass command line argument.

public void
setProviderName(String
the value for the -providerName command line argument
providerName
)

Sets the value for the -providerName command line argument.

public void
setStorepass(final String
the password for the keystore
storepass
)

password for keystore integrity; required

public void
setStoretype(final String
the keystore type
storetype
)

keystore type; optional

public void
setStrict(boolean
boolean
strict
)

do strict checking

public void
setVerbose(final boolean
if true enable verbose output
verbose
)

Enable verbose output when signing; optional: default false

Inherited from org.apache.tools.ant.Task:
bindToOwnerexecutegetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

additionalArgsback to summary
private List<Commandline.Argument> additionalArgs
aliasback to summary
protected String alias

The alias of signer.

ERROR_NO_SOURCEback to summary
public static final String ERROR_NO_SOURCE

error string for unit test verification: jar must be set through jar attribute or nested filesets

executableback to summary
private String executable

The executable to use instead of jarsigner.

Since
Ant 1.8.0
filesetsback to summary
protected Vector<FileSet> filesets

the filesets of the jars to sign

jarback to summary
protected File jar

The name of the jar file.

JARSIGNER_COMMANDback to summary
protected static final String JARSIGNER_COMMAND

name of JDK program we are looking for

keypassback to summary
protected String keypass

password for the key in the store

keystoreback to summary
protected String keystore

The url or path of keystore file.

maxMemoryback to summary
protected String maxMemory

The maximum amount of memory to use for Jar signer

pathback to summary
private Path path

Path holding all non-filesets of filesystem resources we want to sign.

Since
Ant 1.7
providerArgback to summary
private String providerArg

Values for the providerName, providerClass, and providerArg options.

Since
Ant 1.10.6
providerClassback to summary
private String providerClass

Values for the providerName, providerClass, and providerArg options.

Since
Ant 1.10.6
providerNameback to summary
private String providerName

Values for the providerName, providerClass, and providerArg options.

Since
Ant 1.10.6
redirectorback to summary
private RedirectorElement redirector

redirector used to talk to the jarsigner program

storepassback to summary
protected String storepass

password for the store

storetypeback to summary
protected String storetype

type of store,-storetype param

strictback to summary
protected boolean strict

strict checking

Since
Ant 1.9.1
sysPropertiesback to summary
private Environment sysProperties

Java declarations -J-Dname=value

verboseback to summary
protected boolean verbose

verbose output

Constructor Detail

AbstractJarSignerTaskback to summary
public AbstractJarSignerTask()

Method Detail

addArgback to summary
public void addArg(Commandline.Argument arg)

Adds a nested <arg> element that can be used to specify command line arguments not supported via specific attributes.

Parameters
arg:Commandline.Argument

the argument to add

Since
Ant 1.10.6
addArgumentback to summary
protected void addArgument(final ExecTask cmd, Commandline.Argument arg)

add an argument to a command

Parameters
cmd:ExecTask

command to manipulate

arg:Commandline.Argument

argument to add

addFilesetback to summary
public void addFileset(final FileSet set)

Adds a set of files to sign

Parameters
set:FileSet

a set of files to sign

Since
Ant 1.4
addSyspropertyback to summary
public void addSysproperty(Environment.Variable sysp)

Add a system property.

Parameters
sysp:Environment.Variable

system property.

addValueback to summary
protected void addValue(final ExecTask cmd, String value)

add a value argument to a command

Parameters
cmd:ExecTask

command to manipulate

value:String

value to add

beginExecutionback to summary
protected void beginExecution()

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

bindToKeystoreback to summary
protected void bindToKeystore(final ExecTask cmd)

bind to a keystore if the attributes are there

Parameters
cmd:ExecTask

command to configure

createJarSignerback to summary
protected ExecTask createJarSigner()

create the jarsigner executable task

Returns:ExecTask

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

createPathback to summary
public Path createPath()

Adds a path of files to sign.

Returns:Path

a path of files to sign.

Since
Ant 1.7
createRedirectorback to summary
private RedirectorElement createRedirector()

Create the redirector to use, if any.

Returns:RedirectorElement

a configured RedirectorElement.

createUnifiedSourcePathback to summary
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:Path

a path that contains all files to sign

Since
Ant 1.7
createUnifiedSourcesback to summary
protected Vector<FileSet> createUnifiedSources()

clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined

Returns:Vector<FileSet>

a vector of FileSet instances

declareSysPropertyback to summary
protected void declareSysProperty(ExecTask cmd, Environment.Variable property) throws BuildException
Parameters
cmd:ExecTask

command to configure

property:Environment.Variable

property to set

Exceptions
BuildException:
if the property is not correctly defined.
endExecutionback to summary
protected void endExecution()

any cleanup logic

getRedirectorback to summary
public RedirectorElement getRedirector()

get the redirector. Non-null between invocations of beginExecution() and endExecution()

Returns:RedirectorElement

a redirector or null

hasResourcesback to summary
protected boolean hasResources()

Has either a path or a fileset been specified?

Returns:boolean

true if a path or fileset has been specified.

Since
Ant 1.7
setAliasback to summary
public void setAlias(final String alias)

the alias to sign under; required

Parameters
alias:String

the alias to sign under

setCommonOptionsback to summary
protected void setCommonOptions(final ExecTask cmd)

these are options common to signing and verifying

Parameters
cmd:ExecTask

command to configure

setExecutableback to summary
public void setExecutable(String executable)

Sets the actual executable command to invoke, instead of the binary jarsigner found in Ant's JDK.

Parameters
executable:String

the command to invoke.

Since
Ant 1.8.0
setJarback to summary
public void setJar(final File jar)

the jar file to sign; required

Parameters
jar:File

the jar file to sign

setKeypassback to summary
public void setKeypass(final String keypass)

password for private key (if different); optional

Parameters
keypass:String

the password for the key (if different)

setKeystoreback to summary
public void setKeystore(final String keystore)

keystore location; required

Parameters
keystore:String

the keystore location

setMaxmemoryback to summary
public void setMaxmemory(String max)

Set the maximum memory to be used by the jarsigner process

Parameters
max:String

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

setProviderArgback to summary
public void setProviderArg(String providerArg)

Sets the value for the -providerArg command line argument.

Parameters
providerArg:String

the value for the -providerArg command line argument

Since
Ant 1.10.6
setProviderClassback to summary
public void setProviderClass(String providerClass)

Sets the value for the -providerClass command line argument.

Parameters
providerClass:String

the value for the -providerClass command line argument

Since
Ant 1.10.6
setProviderNameback to summary
public void setProviderName(String providerName)

Sets the value for the -providerName command line argument.

Parameters
providerName:String

the value for the -providerName command line argument

Since
Ant 1.10.6
setStorepassback to summary
public void setStorepass(final String storepass)

password for keystore integrity; required

Parameters
storepass:String

the password for the keystore

setStoretypeback to summary
public void setStoretype(final String storetype)

keystore type; optional

Parameters
storetype:String

the keystore type

setStrictback to summary
public void setStrict(boolean strict)

do strict checking

Parameters
strict:boolean

boolean

Since
Ant 1.9.1
setVerboseback to summary
public void setVerbose(final boolean verbose)

Enable verbose output when signing; optional: default false

Parameters
verbose:boolean

if true enable verbose output