Package java.security

Class AlgorithmParameterGenerator

java.lang.Object
java.security.AlgorithmParameterGenerator

public class AlgorithmParameterGenerator
extends Object
AlgorithmParameterGenerator is an engine class which is capable of generating parameters for the algorithm it was initialized with.
  • Constructor Details

    • AlgorithmParameterGenerator

      protected AlgorithmParameterGenerator​(AlgorithmParameterGeneratorSpi paramGenSpi, Provider provider, String algorithm)
      Constructs a new instance of AlgorithmParameterGenerator with the given arguments.
      Parameters:
      paramGenSpi - a concrete implementation, this engine instance delegates to.
      provider - the provider.
      algorithm - the name of the algorithm.
  • Method Details

    • getAlgorithm

      public final String getAlgorithm()
      Returns the name of the algorithm.
      Returns:
      the name of the algorithm.
    • getInstance

      public static AlgorithmParameterGenerator getInstance​(String algorithm) throws NoSuchAlgorithmException
      Returns a new instance of AlgorithmParameterGenerator for the specified algorithm.
      Parameters:
      algorithm - the name of the algorithm to use.
      Returns:
      a new instance of AlgorithmParameterGenerator for the specified algorithm.
      Throws:
      NoSuchAlgorithmException - if the specified algorithm is not available.
      NullPointerException - if algorithm is null.
    • getInstance

      public static AlgorithmParameterGenerator getInstance​(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
      Returns a new instance of AlgorithmParameterGenerator from the specified provider for the specified algorithm.
      Parameters:
      algorithm - the name of the algorithm to use.
      provider - name of the provider of the AlgorithmParameterGenerator.
      Returns:
      a new instance of AlgorithmParameterGenerator for the specified algorithm.
      Throws:
      NoSuchAlgorithmException - if the specified algorithm is not available.
      NoSuchProviderException - if the specified provider is not available.
      IllegalArgumentException - if provider == null || provider.isEmpty()
      NullPointerException - if algorithm is null.
    • getInstance

      public static AlgorithmParameterGenerator getInstance​(String algorithm, Provider provider) throws NoSuchAlgorithmException
      Returns a new instance of AlgorithmParameterGenerator from the specified provider for the specified algorithm.
      Parameters:
      algorithm - the name of the algorithm to use.
      provider - the provider of the AlgorithmParameterGenerator.
      Returns:
      a new instance of AlgorithmParameterGenerator for the specified algorithm.
      Throws:
      NoSuchAlgorithmException - if the specified algorithm is not available.
      NullPointerException - if algorithm is null.
      IllegalArgumentException - if provider == null
    • getProvider

      public final Provider getProvider()
      Returns the provider associated with this AlgorithmParameterGenerator.
      Returns:
      the provider associated with this AlgorithmParameterGenerator.
    • init

      public final void init​(int size)
      Initializes this AlgorithmParameterGenerator with the given size. The default parameter set and a default SecureRandom instance will be used.
      Parameters:
      size - the size (in number of bits).
    • init

      public final void init​(int size, SecureRandom random)
      Initializes this AlgorithmParameterGenerator with the given size and the given SecureRandom. The default parameter set will be used.
      Parameters:
      size - the size (in number of bits).
      random - the source of randomness.
    • init

      public final void init​(AlgorithmParameterSpec genParamSpec) throws InvalidAlgorithmParameterException
      Initializes this AlgorithmParameterGenerator with the given AlgorithmParameterSpec. A default SecureRandom instance will be used.
      Parameters:
      genParamSpec - the parameters to use.
      Throws:
      InvalidAlgorithmParameterException - if the specified parameters are not supported.
    • init

      public final void init​(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException
      Initializes this AlgorithmParameterGenerator with the given AlgorithmParameterSpec and the given SecureRandom.
      Parameters:
      genParamSpec - the parameters to use.
      random - the source of randomness.
      Throws:
      InvalidAlgorithmParameterException - if the specified parameters are not supported.
    • generateParameters

      public final AlgorithmParameters generateParameters()
      Computes and returns AlgorithmParameters for this generator's algorithm.
      Returns:
      AlgorithmParameters for this generator's algorithm.