java.security
Class AlgorithmParameterGenerator

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.AlgorithmParameterGenerator

public class AlgorithmParameterGenerator
extends Object sample code for java.lang.Object definition code for java.lang.Object

The AlgorithmParameterGenerator class is used to generate a set of parameters to be used with a certain algorithm. Parameter generators are constructed using the getInstance factory methods (static methods that return instances of a given class).

The object that will generate the parameters can be initialized in two different ways: in an algorithm-independent manner, or in an algorithm-specific manner:

In case the client does not explicitly initialize the AlgorithmParameterGenerator (via a call to an init method), each provider must supply (and document) a default initialization. For example, the Sun provider uses a default modulus prime size of 1024 bits for the generation of DSA parameters.

Since:
1.2
See Also:
AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters , AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec

Constructor Summary
protected AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator.AlgorithmParameterGenerator(java.security.AlgorithmParameterGeneratorSpi, java.security.Provider, java.lang.String) definition code for java.security.AlgorithmParameterGenerator.AlgorithmParameterGenerator(java.security.AlgorithmParameterGeneratorSpi, java.security.Provider, java.lang.String) (AlgorithmParameterGeneratorSpi sample code for java.security.AlgorithmParameterGeneratorSpi definition code for java.security.AlgorithmParameterGeneratorSpi  paramGenSpi, Provider sample code for java.security.Provider definition code for java.security.Provider  provider, String sample code for java.lang.String definition code for java.lang.String  algorithm)
          Creates an AlgorithmParameterGenerator object.
 
Method Summary
 AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters generateParameters sample code for java.security.AlgorithmParameterGenerator.generateParameters() definition code for java.security.AlgorithmParameterGenerator.generateParameters() ()
          Generates the parameters.
 String sample code for java.lang.String definition code for java.lang.String getAlgorithm sample code for java.security.AlgorithmParameterGenerator.getAlgorithm() definition code for java.security.AlgorithmParameterGenerator.getAlgorithm() ()
          Returns the standard name of the algorithm this parameter generator is associated with.
static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  algorithm)
          Generates an AlgorithmParameterGenerator object that implements the specified digest algorithm.
static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.security.Provider) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.security.Provider) (String sample code for java.lang.String definition code for java.lang.String  algorithm, Provider sample code for java.security.Provider definition code for java.security.Provider  provider)
          Generates an AlgorithmParameterGenerator object for the requested algorithm, as supplied from the specified provider, if such a parameter generator is available from the provider.
static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.lang.String) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  algorithm, String sample code for java.lang.String definition code for java.lang.String  provider)
          Generates an AlgorithmParameterGenerator object for the requested algorithm, as supplied from the specified provider, if such a parameter generator is available from the provider.
 Provider sample code for java.security.Provider definition code for java.security.Provider getProvider sample code for java.security.AlgorithmParameterGenerator.getProvider() definition code for java.security.AlgorithmParameterGenerator.getProvider() ()
          Returns the provider of this algorithm parameter generator object.
 void init sample code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec) definition code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec) (AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  genParamSpec)
          Initializes this parameter generator with a set of algorithm-specific parameter generation values.
 void init sample code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) definition code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) (AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  genParamSpec, SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
          Initializes this parameter generator with a set of algorithm-specific parameter generation values.
 void init sample code for java.security.AlgorithmParameterGenerator.init(int) definition code for java.security.AlgorithmParameterGenerator.init(int) (int size)
          Initializes this parameter generator for a certain size.
 void init sample code for java.security.AlgorithmParameterGenerator.init(int, java.security.SecureRandom) definition code for java.security.AlgorithmParameterGenerator.init(int, java.security.SecureRandom) (int size, SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
          Initializes this parameter generator for a certain size and source of randomness.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator(java.security.AlgorithmParameterGeneratorSpi, java.security.Provider, java.lang.String) definition code for java.security.AlgorithmParameterGenerator(java.security.AlgorithmParameterGeneratorSpi, java.security.Provider, java.lang.String)

protected AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi sample code for java.security.AlgorithmParameterGeneratorSpi definition code for java.security.AlgorithmParameterGeneratorSpi  paramGenSpi,
                                      Provider sample code for java.security.Provider definition code for java.security.Provider  provider,
                                      String sample code for java.lang.String definition code for java.lang.String  algorithm)
Creates an AlgorithmParameterGenerator object.

Parameters:
paramGenSpi - the delegate
provider - the provider
algorithm - the algorithm
Method Detail

getAlgorithm sample code for java.security.AlgorithmParameterGenerator.getAlgorithm() definition code for java.security.AlgorithmParameterGenerator.getAlgorithm()

public final String sample code for java.lang.String definition code for java.lang.String  getAlgorithm()
Returns the standard name of the algorithm this parameter generator is associated with.

Returns:
the string name of the algorithm.

getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String)

public static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm)
                                               throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException 
Generates an AlgorithmParameterGenerator object that implements the specified digest algorithm. If the default provider package provides an implementation of the requested digest algorithm, an instance of AlgorithmParameterGenerator containing that implementation is returned. If the algorithm is not available in the default package, other packages are searched.

Parameters:
algorithm - the string name of the algorithm this parameter generator is associated with.
Returns:
the new AlgorithmParameterGenerator object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.lang.String) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.lang.String)

public static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm,
                                                      String sample code for java.lang.String definition code for java.lang.String  provider)
                                               throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException ,
                                                      NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException 
Generates an AlgorithmParameterGenerator object for the requested algorithm, as supplied from the specified provider, if such a parameter generator is available from the provider.

Parameters:
algorithm - the string name of the algorithm.
provider - the string name of the provider.
Returns:
the new AlgorithmParameterGenerator object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available from the provider.
NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException - if the provider is not available in the environment.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the provider name is null or empty.
See Also:
Provider sample code for java.security.Provider definition code for java.security.Provider

getInstance sample code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.security.Provider) definition code for java.security.AlgorithmParameterGenerator.getInstance(java.lang.String, java.security.Provider)

public static AlgorithmParameterGenerator sample code for java.security.AlgorithmParameterGenerator definition code for java.security.AlgorithmParameterGenerator  getInstance(String sample code for java.lang.String definition code for java.lang.String  algorithm,
                                                      Provider sample code for java.security.Provider definition code for java.security.Provider  provider)
                                               throws NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException 
Generates an AlgorithmParameterGenerator object for the requested algorithm, as supplied from the specified provider, if such a parameter generator is available from the provider. Note: the provider doesn't have to be registered.

Parameters:
algorithm - the string name of the algorithm.
provider - the provider.
Returns:
the new AlgorithmParameterGenerator object.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - if the algorithm is not available from the provider.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the provider is null.
Since:
1.4
See Also:
Provider sample code for java.security.Provider definition code for java.security.Provider

getProvider sample code for java.security.AlgorithmParameterGenerator.getProvider() definition code for java.security.AlgorithmParameterGenerator.getProvider()

public final Provider sample code for java.security.Provider definition code for java.security.Provider  getProvider()
Returns the provider of this algorithm parameter generator object.

Returns:
the provider of this algorithm parameter generator object

init sample code for java.security.AlgorithmParameterGenerator.init(int) definition code for java.security.AlgorithmParameterGenerator.init(int)

public final void init(int size)
Initializes this parameter generator for a certain size. To create the parameters, the SecureRandom implementation of the highest-priority installed provider is used as the source of randomness. (If none of the installed providers supply an implementation of SecureRandom, a system-provided source of randomness is used.)

Parameters:
size - the size (number of bits).

init sample code for java.security.AlgorithmParameterGenerator.init(int, java.security.SecureRandom) definition code for java.security.AlgorithmParameterGenerator.init(int, java.security.SecureRandom)

public final void init(int size,
                       SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
Initializes this parameter generator for a certain size and source of randomness.

Parameters:
size - the size (number of bits).
random - the source of randomness.

init sample code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec) definition code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec)

public final void init(AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  genParamSpec)
                throws InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException 
Initializes this parameter generator with a set of algorithm-specific parameter generation values. To generate the parameters, the SecureRandom implementation of the highest-priority installed provider is used as the source of randomness. (If none of the installed providers supply an implementation of SecureRandom, a system-provided source of randomness is used.)

Parameters:
genParamSpec - the set of algorithm-specific parameter generation values.
Throws:
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if the given parameter generation values are inappropriate for this parameter generator.

init sample code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) definition code for java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)

public final void init(AlgorithmParameterSpec sample code for java.security.spec.AlgorithmParameterSpec definition code for java.security.spec.AlgorithmParameterSpec  genParamSpec,
                       SecureRandom sample code for java.security.SecureRandom definition code for java.security.SecureRandom  random)
                throws InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException 
Initializes this parameter generator with a set of algorithm-specific parameter generation values.

Parameters:
genParamSpec - the set of algorithm-specific parameter generation values.
random - the source of randomness.
Throws:
InvalidAlgorithmParameterException sample code for java.security.InvalidAlgorithmParameterException definition code for java.security.InvalidAlgorithmParameterException - if the given parameter generation values are inappropriate for this parameter generator.

generateParameters sample code for java.security.AlgorithmParameterGenerator.generateParameters() definition code for java.security.AlgorithmParameterGenerator.generateParameters()

public final AlgorithmParameters sample code for java.security.AlgorithmParameters definition code for java.security.AlgorithmParameters  generateParameters()
Generates the parameters.

Returns:
the new AlgorithmParameters object.