GenerateKey (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs, class: GenerateKey

Package org.apache.tools.ant.taskdefs

# Class GenerateKey

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.GenerateKey

All Implemented Interfaces:
  `Cloneable`

public class GenerateKey extends Task
Generates a key in a keystore.

Since:
  Ant 1.2

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `GenerateKey.DistinguishedName`
  A class corresponding to the dname nested element.
  `static class`
  `GenerateKey.DnameParam`
  A DistinguishedName parameter.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `alias`
  The alias of signer.
  `protected String`
  `dname`
  `protected GenerateKey.DistinguishedName`
  `expandedDname`
  `protected String`
  `keyalg`
  `protected String`
  `keypass`
  `protected int`
  `keysize`
  `protected String`
  `keystore`
  The name of keystore file.
  `protected String`
  `saname`
  `protected String`
  `sigalg`
  `protected String`
  `storepass`
  `protected String`
  `storetype`
  `protected int`
  `validity`
  `protected boolean`
  `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

  Constructors
  Constructor
  Description
  `GenerateKey()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `GenerateKey.DistinguishedName`
  `createDname()`
  Distinguished name list.
  `void`
  `execute()`
  Execute the task.
  `void`
  `setAlias(String alias)`
  The alias to add under.
  `void`
  `setDname(String dname)`
  The distinguished name for entity.
  `void`
  `setKeyalg(String keyalg)`
  The method to use when generating name-value pair.
  `void`
  `setKeypass(String keypass)`
  Password for private key (if different).
  `void`
  `setKeysize(String keysize)`
  Indicates the size of key generated.
  `void`
  `setKeystore(String keystore)`
  Keystore location.
  `void`
  `setSaname(String saname)`
  The subject alternative name for entity.
  `void`
  `setSigalg(String sigalg)`
  The algorithm to use in signing.
  `void`
  `setStorepass(String storepass)`
  Password for keystore integrity.
  `void`
  `setStoretype(String storetype)`
  Keystore type.
  `void`
  `setValidity(String validity)`
  Indicates how many days certificate is valid.
  `void`
  `setVerbose(boolean verbose)`
  If true, verbose output when signing.

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

  - ### alias

    protected String alias
    The alias of signer.

  - ### keystore

    protected String keystore
    The name of keystore file.

  - ### storepass

    protected String storepass

  - ### storetype

    protected String storetype

  - ### keypass

    protected String keypass

  - ### sigalg

    protected String sigalg

  - ### keyalg

    protected String keyalg

  - ### saname

    protected String saname

  - ### dname

    protected String dname

  - ### expandedDname

    protected GenerateKey.DistinguishedName expandedDname

  - ### keysize

    protected int keysize

  - ### validity

    protected int validity

  - ### verbose

    protected boolean verbose

- ## Constructor Details

  - ### GenerateKey

    public GenerateKey()

- ## Method Details

  - ### createDname

    public GenerateKey.DistinguishedName createDname() throws BuildException
    Distinguished name list.
    Returns:
      Distinguished name container.
    Throws:
      `BuildException` - If specified more than once or dname attribute is used.

  - ### setDname

    public void setDname(String dname)
    The distinguished name for entity.
    Parameters:
      `dname` - distinguished name

  - ### setSaname

    public void setSaname(String saname)
    The subject alternative name for entity.
    Parameters:
      `saname` - subject alternative name
    Since:
      Ant 1.9.14

  - ### setAlias

    public void setAlias(String alias)
    The alias to add under.
    Parameters:
      `alias` - alias to add under

  - ### setKeystore

    public void setKeystore(String keystore)
    Keystore location.
    Parameters:
      `keystore` - location

  - ### setStorepass

    public void setStorepass(String storepass)
    Password for keystore integrity. Must be at least 6 characters long.
    Parameters:
      `storepass` - password

  - ### setStoretype

    public void setStoretype(String storetype)
    Keystore type.
    Parameters:
      `storetype` - type

  - ### setKeypass

    public void setKeypass(String keypass)
    Password for private key (if different).
    Parameters:
      `keypass` - password

  - ### setSigalg

    public void setSigalg(String sigalg)
    The algorithm to use in signing.
    Parameters:
      `sigalg` - algorithm

  - ### setKeyalg

    public void setKeyalg(String keyalg)
    The method to use when generating name-value pair.
    Parameters:
      `keyalg` - algorithm

  - ### setKeysize

    public void setKeysize(String keysize) throws BuildException
    Indicates the size of key generated.
    Parameters:
      `keysize` - size of key
    Throws:
      `BuildException` - If not an Integer
    To do:
      Could convert this to a plain Integer setter.

  - ### setValidity

    public void setValidity(String validity) throws BuildException
    Indicates how many days certificate is valid.
    Parameters:
      `validity` - days valid
    Throws:
      `BuildException` - If not an Integer

  - ### setVerbose

    public void setVerbose(boolean verbose)
    If true, verbose output when signing.
    Parameters:
      `verbose` - verbose or not

  - ### execute

    public void execute() throws BuildException
    Execute the task.
    Overrides:
      `execute` in class `Task`
    Throws:
      `BuildException` - on error