Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.internet2.middleware.ant.pki
Class SelfSignedCertificate

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              edu.internet2.middleware.ant.pki.SelfSignedCertificate

All Implemented Interfaces:
  Cloneable

    public class SelfSignedCertificate

extends org.apache.tools.ant.Task

An ant task that generates a self-signed certificate. This ant task requires three attributes:

- hostname - the server hostname that will be used in the certificate Subject and Issuer DN

The task also has two optional attributes:

- keyType - type of key generated, possible values are "DSA" or "RSA", the default is RSA
- keySize - size, in bits, of the generated key, default is 2048
- privateKeyFile - file to which the generated private key will be written, in PEM format
- certifcateFile - file to which the self-signed certificate will be written, in PEM format
- keystoreFile - keystore to which the self-signed certificate and key will be written
- keystorePassword - password for the keystore, if none is given the string 'changeit' is used
- dnsSubjectAltNames - space separated list of DNS subject alt names
- uriSubjectAltNames - space separated list of URI subject alt names

Nested Class Summary
`static class` | `SelfSignedCertificate.KeyType` Key type enumeration.

Field Summary

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
`SelfSignedCertificate()`

Method Summary
`protected org.bouncycastle.asn1.ASN1Encodable[]` | `buildSubjectAltNames()` Builds the subject alt names for the certificate.
`void` | `execute()`
`protected X509Certificate` | `generateCertificate(KeyPair keypair)` Generates the self-signed certificate.
`protected KeyPair` | `generateKeyPair()` Generates the key pair for the certificate.
`void` | `setCertificateFile(File file)` Sets the file to which the certificate will be written.
`void` | `setCertificateLifetime(int lifetime)` Sets the number of years for which the certificate will be valid.
`void` | `setDnsSubjectAltNames(String altNames)` Sets the optional DNS subject alt names.
`void` | `setHostName(String name)` Sets the hostname that will appear in the certificate's DN.
`void` | `setKeysize(int size)` Sets the size of the generated key.
`void` | `setKeystoreFile(File file)` Sets the file to which the keystore will be written.
`void` | `setKeystorePassword(String password)` Sets the password for the generated keystore.
`void` | `setKeyType(SelfSignedCertificate.KeyType type)` Sets the type of key that will be generated.
`void` | `setPrivateKeyFile(File file)` Sets the file to which the private key will be written.
`void` | `setUriSubjectAltNames(String altNames)` Sets the optional URI subject alt names.
`protected void` | `validate()` Validates the provided task input.

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`

Constructor Detail

### SelfSignedCertificate

    public SelfSignedCertificate()

Method Detail

### execute

    public void execute()
                 throws org.apache.tools.ant.BuildException

  Overrides:
    `execute` in class `org.apache.tools.ant.Task`
  Throws:
    `org.apache.tools.ant.BuildException`

### setKeyType

    public void setKeyType(SelfSignedCertificate.KeyType type)

  Sets the type of key that will be generated. Defaults to DSA.

  Parameters:
    `type` - type of key that will be generated

### setKeysize

    public void setKeysize(int size)

  Sets the size of the generated key. Defaults to 2048

  Parameters:
    `size` - size of the generated key

### setCertificateLifetime

    public void setCertificateLifetime(int lifetime)

  Sets the number of years for which the certificate will be valid.

  Parameters:
    `lifetime` - number of years for which the certificate will be valid

### setHostName

    public void setHostName(String name)

  Sets the hostname that will appear in the certificate's DN.

  Parameters:
    `name` - hostname that will appear in the certificate's DN

### setPrivateKeyFile

    public void setPrivateKeyFile(File file)

  Sets the file to which the private key will be written.

  Parameters:
    `file` - file to which the private key will be written

### setCertificateFile

    public void setCertificateFile(File file)

  Sets the file to which the certificate will be written.

  Parameters:
    `file` - file to which the certificate will be written

### setKeystoreFile

    public void setKeystoreFile(File file)

  Sets the file to which the keystore will be written.

  Parameters:
    `file` - file to which the keystore will be written

### setKeystorePassword

    public void setKeystorePassword(String password)

  Sets the password for the generated keystore.

  Parameters:
    `password` - password for the generated keystore

### setDnsSubjectAltNames

    public void setDnsSubjectAltNames(String altNames)

  Sets the optional DNS subject alt names.

  Parameters:
    `altNames` - space delimited set of subject alt names.

### setUriSubjectAltNames

    public void setUriSubjectAltNames(String altNames)

  Sets the optional URI subject alt names.

  Parameters:
    `altNames` - space delimited set of subject alt names.

### validate

    protected void validate()
                     throws org.apache.tools.ant.BuildException

  Validates the provided task input.

  Throws:
    `org.apache.tools.ant.BuildException`

### generateKeyPair

    protected KeyPair generateKeyPair()
                               throws org.apache.tools.ant.BuildException

  Generates the key pair for the certificate.

  Returns:
    key pair for the certificate
  Throws:
    `org.apache.tools.ant.BuildException` - thrown if there is a problem generating the keys.

### generateCertificate

    protected X509Certificate generateCertificate(KeyPair keypair)
                                           throws org.apache.tools.ant.BuildException

  Generates the self-signed certificate.

  Parameters:
    `keypair` - keypair associated with the certificate
  Returns:
    self-signed certificate
  Throws:
    `org.apache.tools.ant.BuildException` - thrown if the certificate can not be generated

### buildSubjectAltNames

    protected org.bouncycastle.asn1.ASN1Encodable[] buildSubjectAltNames()

  Builds the subject alt names for the certificate.

  Returns:
    subject alt names for the certificate

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2011 Internet2. All Rights Reserved.