FileDocCategorySizeDatePackage
AlgorithmParameters.javaAPI DocAndroid 1.5 API11926Wed May 06 22:41:04 BST 2009java.security

AlgorithmParameters

public class AlgorithmParameters extends Object
{@code AlgorithmParameters} is an engine class which provides algorithm parameters.
since
Android 1.0

Fields Summary
private static final String
SEVICE
The service name.
private static org.apache.harmony.security.fortress.Engine
engine
Used to access common engine functionality.
private Provider
provider
The security provider.
private AlgorithmParametersSpi
spiImpl
The SPI implementation.
private String
algorithm
The security algorithm.
private boolean
initialized
The initialization state.
Constructors Summary
protected AlgorithmParameters(AlgorithmParametersSpi algPramSpi, Provider provider, String algorithm)
Constructs a new instance of {@code AlgorithmParameters} with the given arguments.

param
algPramSpi the concrete implementation.
param
provider the security provider.
param
algorithm the name of the algorithm.
since
Android 1.0

 // = false;

                                                                          
      
                
        // BEGIN android-note
        // renamed parameter
        // END android-note
        this.provider = provider;
        this.algorithm = algorithm;
        this.spiImpl = algPramSpi;
    
Methods Summary
public final java.lang.StringgetAlgorithm()
Returns the name of the algorithm.

return
the name of the algorithm.
since
Android 1.0

        return algorithm;
    
public final byte[]getEncoded()
Returns this {@code AlgorithmParameters} in their default encoding format. The default encoding format is ASN.1.

return
the encoded parameters.
throws
IOException if this {@code AlgorithmParameters} has already been initialized, or if this parameters could not be encoded.
since
Android 1.0

        if (!initialized) {
            throw new IOException(Messages.getString("security.1F")); //$NON-NLS-1$
        }
        return spiImpl.engineGetEncoded();
    
public final byte[]getEncoded(java.lang.String format)
Returns this {@code AlgorithmParameters} in the specified encoding format.

param
format the name of the encoding format.
return
the encoded parameters.
throws
IOException if this {@code AlgorithmParameters} has already been initialized, or if this parameters could not be encoded.
since
Android 1.0

        if (!initialized) {
            throw new IOException(Messages.getString("security.1F")); //$NON-NLS-1$
        }
        return spiImpl.engineGetEncoded(format);
    
public static java.security.AlgorithmParametersgetInstance(java.lang.String algorithm)
Returns a new instance of {@code AlgorithmParameters} for the specified algorithm.

param
algorithm the name of the algorithm to use.
return
a new instance of {@code AlgorithmParameters} 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 AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
                    engine.provider, algorithm);
        }
    
public static java.security.AlgorithmParametersgetInstance(java.lang.String algorithm, java.lang.String provider)
Returns a new instance of {@code AlgorithmParameters} 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 AlgorithmParameters}.
return
a new instance of {@code AlgorithmParameters} for the specified algorithm.
throws
NoSuchAlgorithmException if the specified algorithm is not available.
throws
NoSuchProviderException if the specified provider is not available.
throws
IllegalArgumentException if {@code provider} is {@code null} or of length zero.
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 p = Security.getProvider(provider);
        if (p == null) {
            throw new NoSuchProviderException(Messages.getString("security.03", //$NON-NLS-1$
                    provider));
        }
        return getInstance(algorithm, p);
    
public static java.security.AlgorithmParametersgetInstance(java.lang.String algorithm, java.security.Provider provider)
Returns a new instance of {@code AlgorithmParameters} from the specified provider for the specified algorithm.

param
algorithm the name of the algorithm to use.
param
provider the provider of the {@code AlgorithmParameters}.
return
a new instance of {@code AlgorithmParameters} for the specified algorithm.
throws
NoSuchAlgorithmException if the specified algorithm is not available.
throws
NullPointerException if {@code algorithm} is {@code null}.
throws
IllegalArgumentException if {@code provider} 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 AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
                    provider, algorithm);
        }
    
public final TgetParameterSpec(java.lang.Class paramSpec)
Returns the {@code AlgorithmParameterSpec} for this {@code AlgorithmParameters}.

param
paramSpec the type of the parameter specification in which this parameters should be converted.
return
the {@code AlgorithmParameterSpec} for this {@code AlgorithmParameters}.
throws
InvalidParameterSpecException if this {@code AlgorithmParameters} has already been initialized, or if this parameters could not be converted to the specified class.
since
Android 1.0

        if (!initialized) {
            throw new InvalidParameterSpecException(
                    Messages.getString("security.1F")); //$NON-NLS-1$
        }
        return spiImpl.engineGetParameterSpec(paramSpec);
    
public final java.security.ProvidergetProvider()
Returns the provider associated with this {@code AlgorithmParameters}.

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

        return provider;
    
public final voidinit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this {@code AlgorithmParameters} with the specified {@code AlgorithmParameterSpec}.

param
paramSpec the parameter specification.
throws
InvalidParameterSpecException if this {@code AlgorithmParameters} has already been initialized or the given {@code paramSpec} is not appropriate for initializing this {@code AlgorithmParameters}.
since
Android 1.0

        if (initialized) {
            throw new InvalidParameterSpecException(
                    Messages.getString("security.1E")); //$NON-NLS-1$
        }
        spiImpl.engineInit(paramSpec);
        initialized = true;
    
public final voidinit(byte[] params)
Initializes this {@code AlgorithmParameters} with the specified {@code byte[]} using the default decoding format for parameters. The default encoding format is ASN.1.

param
params the encoded parameters.
throws
IOException if this {@code AlgorithmParameters} has already been initialized, or the parameter could not be encoded.
since
Android 1.0

        if (initialized) {
            throw new IOException(Messages.getString("security.1E")); //$NON-NLS-1$
        }
        spiImpl.engineInit(params);
        initialized = true;
    
public final voidinit(byte[] params, java.lang.String format)
Initializes this {@code AlgorithmParameters} with the specified {@code byte[]} using the specified decoding format.

param
params the encoded parameters.
param
format the name of the decoding format.
throws
IOException if this {@code AlgorithmParameters} has already been initialized, or the parameter could not be encoded.
since
Android 1.0

        if (initialized) {
            throw new IOException(Messages.getString("security.1E")); //$NON-NLS-1$
        }
        spiImpl.engineInit(params, format);
        initialized = true;
    
public final java.lang.StringtoString()
Returns a string containing a concise, human-readable description of this {@code AlgorithmParameters}.

return
a printable representation for this {@code AlgorithmParameters}.
since
Android 1.0

        if (!initialized) {
            return null;
        }
        return spiImpl.engineToString();