FileDocCategorySizeDatePackage
AlgorithmParameterGenerator.javaAPI DocAndroid 1.5 API9233Wed May 06 22:41:04 BST 2009java.security

AlgorithmParameterGenerator

public class AlgorithmParameterGenerator extends Object
{@code AlgorithmParameterGenerator} is an engine class which is capable of generating parameters for the algorithm it was initialized with.
since
Android 1.0

Fields Summary
private static final String
SERVICE
private static org.apache.harmony.security.fortress.Engine
engine
private static SecureRandom
randm
private final Provider
provider
private final AlgorithmParameterGeneratorSpi
spiImpl
private final String
algorithm
Constructors Summary
protected AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi paramGenSpi, Provider provider, String algorithm)
Constructs a new instance of {@code AlgorithmParameterGenerator} with the given arguments.

param
paramGenSpi a concrete implementation, this engine instance delegates to.
param
provider the provider.
param
algorithm the name of the algorithm.
since
Android 1.0


                                                                              
     
               
              
        this.provider = provider;
        this.algorithm = algorithm;
        this.spiImpl = paramGenSpi;
    
Methods Summary
public final java.security.AlgorithmParametersgenerateParameters()
Computes and returns {@code AlgorithmParameters} for this generator's algorithm.

return
{@code AlgorithmParameters} for this generator's algorithm.
since
Android 1.0

        return spiImpl.engineGenerateParameters();
    
public final java.lang.StringgetAlgorithm()
Returns the name of the algorithm.

return
the name of the algorithm.
since
Android 1.0

        return algorithm;
    
public static java.security.AlgorithmParameterGeneratorgetInstance(java.lang.String algorithm)
Returns a new instance of {@code AlgorithmParameterGenerator} for the specified algorithm.

param
algorithm the name of the algorithm to use.
return
a new instance of {@code AlgorithmParameterGenerator} for the specified algorithm.
throws
NoSuchAlgorithmException if the specified algorithm is not available.
throws
NullPointerException if {@code algorithm} is {@code null}.
since
Android 1.0

        if (algorithm == null) {
            throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
        }
        synchronized (engine) {
            engine.getInstance(algorithm, null);
            return new AlgorithmParameterGenerator(
                    (AlgorithmParameterGeneratorSpi) engine.spi, engine.provider,
                    algorithm);
        }
    
public static java.security.AlgorithmParameterGeneratorgetInstance(java.lang.String algorithm, java.lang.String provider)
Returns a new instance of {@code AlgorithmParameterGenerator} from the specified provider for the specified algorithm.

param
algorithm the name of the algorithm to use.
param
provider name of the provider of the {@code AlgorithmParameterGenerator}.
return
a new instance of {@code AlgorithmParameterGenerator} for the specified algorithm.
throws
NoSuchAlgorithmException if the specified algorithm is not available.
throws
NoSuchProviderException if the specified provider is not available.
throws
NullPointerException if {@code algorithm} is {@code null}.
since
Android 1.0

        if ((provider == null) || (provider.length() == 0)) {
            throw new IllegalArgumentException(
                    Messages.getString("security.02")); //$NON-NLS-1$
        }
        Provider impProvider = Security.getProvider(provider);
        if (impProvider == null) {
            throw new NoSuchProviderException(provider);
        }
        return getInstance(algorithm, impProvider);
    
public static java.security.AlgorithmParameterGeneratorgetInstance(java.lang.String algorithm, java.security.Provider provider)
Returns a new instance of {@code AlgorithmParameterGenerator} from the specified provider for the specified algorithm.

param
algorithm the name of the algorithm to use.
param
provider the provider of the {@code AlgorithmParameterGenerator}.
return
a new instance of {@code AlgorithmParameterGenerator} for the specified algorithm.
throws
NoSuchAlgorithmException if the specified algorithm is not available.
throws
NullPointerException if {@code algorithm} is {@code null}.
since
Android 1.0

        if (provider == null) {
            throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
        }
        if (algorithm == null) {
            throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
        }
        synchronized (engine) {
            engine.getInstance(algorithm, provider, null);
            return new AlgorithmParameterGenerator(
                    (AlgorithmParameterGeneratorSpi) engine.spi, provider,
                    algorithm);
        }
    
public final java.security.ProvidergetProvider()
Returns the provider associated with this {@code AlgorithmParameterGenerator}.

return
the provider associated with this {@code AlgorithmParameterGenerator}.
since
Android 1.0

        return provider;
    
public final voidinit(java.security.spec.AlgorithmParameterSpec genParamSpec, java.security.SecureRandom random)
Initializes this {@code AlgorithmParameterGenerator} with the given {@code AlgorithmParameterSpec} and the given {@code SecureRandom}.

param
genParamSpec the parameters to use.
param
random the source of randomness.
throws
InvalidAlgorithmParameterException if the specified parameters are not supported.
since
Android 1.0

        spiImpl.engineInit(genParamSpec, random);
    
public final voidinit(int size)
Initializes this {@code AlgorithmParameterGenerator} with the given size. The default parameter set and a default {@code SecureRandom} instance will be used.

param
size the size (in number of bits).
since
Android 1.0

        spiImpl.engineInit(size, randm);
    
public final voidinit(int size, java.security.SecureRandom random)
Initializes this {@code AlgorithmParameterGenerator} with the given size and the given {@code SecureRandom}. The default parameter set will be used.

param
size the size (in number of bits).
param
random the source of randomness.
since
Android 1.0

        spiImpl.engineInit(size, random);
    
public final voidinit(java.security.spec.AlgorithmParameterSpec genParamSpec)
Initializes this {@code AlgorithmParameterGenerator} with the given {@code AlgorithmParameterSpec}. A default {@code SecureRandom} instance will be used.

param
genParamSpec the parameters to use.
throws
InvalidAlgorithmParameterException if the specified parameters are not supported.
since
Android 1.0

        spiImpl.engineInit(genParamSpec, randm);