AbstractJarSignerTask (Apache Ant API)
Date: 2016-08-23

org.apache.tools.ant.taskdefs

## Class AbstractJarSignerTask

- java.lang.Object
- - org.apache.tools.ant.ProjectComponent
  - - org.apache.tools.ant.Task
    - - org.apache.tools.ant.taskdefs.AbstractJarSignerTask

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    SignJar, VerifyJar

      public abstract class AbstractJarSignerTask
      extends Task

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `alias` The alias of signer.
    `static java.lang.String` | `ERROR_NO_SOURCE` error string for unit test verification: "jar must be set through jar attribute or nested filesets"
    `protected java.util.Vector<FileSet>` | `filesets` the filesets of the jars to sign
    `protected java.io.File` | `jar` The name of the jar file.
    `protected static java.lang.String` | `JARSIGNER_COMMAND` name of JDK program we are looking for
    `protected java.lang.String` | `keypass` password for the key in the store
    `protected java.lang.String` | `keystore` The url or path of keystore file.
    `protected java.lang.String` | `maxMemory` The maximum amount of memory to use for Jar signer
    `protected java.lang.String` | `storepass` password for the store
    `protected java.lang.String` | `storetype` type of store,-storetype param
    `protected boolean` | `strict` strict checking
    `protected boolean` | `verbose` verbose output

    - ### 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

    Constructors
    Constructor and Description
    `AbstractJarSignerTask()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFileset(FileSet set)` Adds a set of files to sign
    `void` | `addSysproperty(Environment.Variable sysp)` Add a system property.
    `protected void` | `addValue(ExecTask cmd, java.lang.String value)` add a value argument to a command
    `protected void` | `beginExecution()` init processing logic; this is retained through our execution(s)
    `protected void` | `bindToKeystore(ExecTask cmd)` bind to a keystore if the attributes are there
    `protected ExecTask` | `createJarSigner()` create the jarsigner executable task
    `Path` | `createPath()` Adds a path of files to sign.
    `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.
    `protected java.util.Vector<FileSet>` | `createUnifiedSources()` clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined
    `protected void` | `declareSysProperty(ExecTask cmd, Environment.Variable property)`
    `protected void` | `endExecution()` any cleanup logic
    `RedirectorElement` | `getRedirector()` get the redirector.
    `protected boolean` | `hasResources()` Has either a path or a fileset been specified?
    `void` | `setAlias(java.lang.String alias)` the alias to sign under; required
    `protected void` | `setCommonOptions(ExecTask cmd)` these are options common to signing and verifying
    `void` | `setExecutable(java.lang.String executable)` Sets the actual executable command to invoke, instead of the binary `jarsigner` found in Ant's JDK.
    `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` | `setMaxmemory(java.lang.String max)` Set the maximum memory to be used by the jarsigner process
    `void` | `setStorepass(java.lang.String storepass)` password for keystore integrity; required
    `void` | `setStoretype(java.lang.String storetype)` keystore type; optional
    `void` | `setStrict(boolean strict)` do strict checking
    `void` | `setVerbose(boolean verbose)` Enable verbose output when signing ; optional: default false

    - ### Methods inherited from class org.apache.tools.ant.Task

      `bindToOwner, execute, 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

    - #### jar

          protected java.io.File jar

      The name of the jar file.

    - #### alias

          protected java.lang.String alias

      The alias of signer.

    - #### keystore

          protected java.lang.String keystore

      The url or path of keystore file.

    - #### storepass

          protected java.lang.String storepass

      password for the store

    - #### storetype

          protected java.lang.String storetype

      type of store,-storetype param

    - #### keypass

          protected java.lang.String keypass

      password for the key in the store

    - #### verbose

          protected boolean verbose

      verbose output

    - #### strict

          protected boolean strict

      strict checking
      Since:
        Ant 1.9.1

    - #### maxMemory

          protected java.lang.String maxMemory

      The maximum amount of memory to use for Jar signer

    - #### filesets

          protected java.util.Vector<FileSet> filesets

      the filesets of the jars to sign

    - #### JARSIGNER_COMMAND

          protected static final java.lang.String JARSIGNER_COMMAND

      name of JDK program we are looking for
      See Also:
        Constant Field Values

    - #### ERROR_NO_SOURCE

          public static final java.lang.String ERROR_NO_SOURCE

      error string for unit test verification: "jar must be set through jar attribute or nested filesets"
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractJarSignerTask

          public AbstractJarSignerTask()

  - ### 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
      Parameters:
        `jar` - the jar file to sign

    - #### setAlias

          public void setAlias(java.lang.String alias)

      the alias to sign under; required
      Parameters:
        `alias` - the alias to sign under

    - #### setKeystore

          public void setKeystore(java.lang.String keystore)

      keystore location; required
      Parameters:
        `keystore` - the keystore location

    - #### setStorepass

          public void setStorepass(java.lang.String storepass)

      password for keystore integrity; required
      Parameters:
        `storepass` - the password for the keystore

    - #### setStoretype

          public void setStoretype(java.lang.String storetype)

      keystore type; optional
      Parameters:
        `storetype` - the keystore type

    - #### setKeypass

          public void setKeypass(java.lang.String keypass)

      password for private key (if different); optional
      Parameters:
        `keypass` - the password for the key (if different)

    - #### setVerbose

          public void setVerbose(boolean verbose)

      Enable verbose output when signing ; optional: default false
      Parameters:
        `verbose` - if true enable verbose output

    - #### setStrict

          public void setStrict(boolean strict)

      do strict checking
      Parameters:
        `strict` -
      Since:
        Ant 1.9.1

    - #### 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.

    - #### createPath

          public Path createPath()

      Adds a path of files to sign.
      Returns:
        a path of files to sign.
      Since:
        Ant 1.7

    - #### beginExecution

          protected void beginExecution()

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

    - #### endExecution

          protected void endExecution()

      any cleanup logic

    - #### getRedirector

          public RedirectorElement getRedirector()

      get the redirector. Non-null between invocations of `beginExecution()` and `endExecution()`
      Returns:
        a redirector or null

    - #### setExecutable

          public void setExecutable(java.lang.String executable)

      Sets the actual executable command to invoke, instead of the binary `jarsigner` found in Ant's JDK.
      Parameters:
        `executable` - the command to invoke.
      Since:
        Ant 1.8.0

    - #### setCommonOptions

          protected void setCommonOptions(ExecTask cmd)

      these are options common to signing and verifying
      Parameters:
        `cmd` - command to configure

    - #### declareSysProperty

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

      Parameters:
        `cmd` - command to configure
        `property` - property to set
      Throws:
        `BuildException` - if the property is not correctly defined.

    - #### 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

    - #### createUnifiedSources

          protected java.util.Vector<FileSet> createUnifiedSources()

      clone our filesets vector, and patch in the jar attribute as a new fileset, if is defined
      Returns:
        a vector of FileSet instances

    - #### 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

    - #### 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

    - #### addValue

          protected void addValue(ExecTask cmd,
                                  java.lang.String value)

      add a value argument to a command
      Parameters:
        `cmd` - command to manipulate
        `value` - value to add