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 Summary
Constructors Modifier Constructor Description protectedAlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi paramGenSpi, Provider provider, String algorithm)Constructs a new instance ofAlgorithmParameterGeneratorwith the given arguments. -
Method Summary
Modifier and Type Method Description AlgorithmParametersgenerateParameters()Computes and returnsAlgorithmParametersfor this generator's algorithm.StringgetAlgorithm()Returns the name of the algorithm.static AlgorithmParameterGeneratorgetInstance(String algorithm)Returns a new instance ofAlgorithmParameterGeneratorfor the specified algorithm.static AlgorithmParameterGeneratorgetInstance(String algorithm, String provider)Returns a new instance ofAlgorithmParameterGeneratorfrom the specified provider for the specified algorithm.static AlgorithmParameterGeneratorgetInstance(String algorithm, Provider provider)Returns a new instance ofAlgorithmParameterGeneratorfrom the specified provider for the specified algorithm.ProvidergetProvider()Returns the provider associated with thisAlgorithmParameterGenerator.voidinit(int size)Initializes thisAlgorithmParameterGeneratorwith the given size.voidinit(int size, SecureRandom random)Initializes thisAlgorithmParameterGeneratorwith the given size and the givenSecureRandom.voidinit(AlgorithmParameterSpec genParamSpec)Initializes thisAlgorithmParameterGeneratorwith the givenAlgorithmParameterSpec.voidinit(AlgorithmParameterSpec genParamSpec, SecureRandom random)Initializes thisAlgorithmParameterGeneratorwith the givenAlgorithmParameterSpecand the givenSecureRandom.
-
Constructor Details
-
AlgorithmParameterGenerator
protected AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi paramGenSpi, Provider provider, String algorithm)Constructs a new instance ofAlgorithmParameterGeneratorwith 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
Returns the name of the algorithm.- Returns:
- the name of the algorithm.
-
getInstance
public static AlgorithmParameterGenerator getInstance(String algorithm) throws NoSuchAlgorithmExceptionReturns a new instance ofAlgorithmParameterGeneratorfor the specified algorithm.- Parameters:
algorithm- the name of the algorithm to use.- Returns:
- a new instance of
AlgorithmParameterGeneratorfor the specified algorithm. - Throws:
NoSuchAlgorithmException- if the specified algorithm is not available.NullPointerException- ifalgorithmisnull.
-
getInstance
public static AlgorithmParameterGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderExceptionReturns a new instance ofAlgorithmParameterGeneratorfrom the specified provider for the specified algorithm.- Parameters:
algorithm- the name of the algorithm to use.provider- name of the provider of theAlgorithmParameterGenerator.- Returns:
- a new instance of
AlgorithmParameterGeneratorfor the specified algorithm. - Throws:
NoSuchAlgorithmException- if the specified algorithm is not available.NoSuchProviderException- if the specified provider is not available.IllegalArgumentException- ifprovider == null || provider.isEmpty()NullPointerException- ifalgorithmisnull.
-
getInstance
public static AlgorithmParameterGenerator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmExceptionReturns a new instance ofAlgorithmParameterGeneratorfrom the specified provider for the specified algorithm.- Parameters:
algorithm- the name of the algorithm to use.provider- the provider of theAlgorithmParameterGenerator.- Returns:
- a new instance of
AlgorithmParameterGeneratorfor the specified algorithm. - Throws:
NoSuchAlgorithmException- if the specified algorithm is not available.NullPointerException- ifalgorithmisnull.IllegalArgumentException- ifprovider == null
-
getProvider
Returns the provider associated with thisAlgorithmParameterGenerator.- Returns:
- the provider associated with this
AlgorithmParameterGenerator.
-
init
public final void init(int size)Initializes thisAlgorithmParameterGeneratorwith the given size. The default parameter set and a defaultSecureRandominstance will be used.- Parameters:
size- the size (in number of bits).
-
init
Initializes thisAlgorithmParameterGeneratorwith the given size and the givenSecureRandom. 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 InvalidAlgorithmParameterExceptionInitializes thisAlgorithmParameterGeneratorwith the givenAlgorithmParameterSpec. A defaultSecureRandominstance 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 InvalidAlgorithmParameterExceptionInitializes thisAlgorithmParameterGeneratorwith the givenAlgorithmParameterSpecand the givenSecureRandom.- Parameters:
genParamSpec- the parameters to use.random- the source of randomness.- Throws:
InvalidAlgorithmParameterException- if the specified parameters are not supported.
-
generateParameters
Computes and returnsAlgorithmParametersfor this generator's algorithm.- Returns:
AlgorithmParametersfor this generator's algorithm.
-