java.security

Class AlgorithmParameters

public class AlgorithmParameters extends Object

AlgorithmParameters is an Algorithm Parameters class which provides an interface through which the user can manage the parameters of an Algorithm.

Since: 1.2

See Also: AlgorithmParameterSpec DSAParameterSpec KeyPairGenerator

Constructor Summary
protected AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm)
Constructs a new instance of AlgorithmParameters.
Method Summary
StringgetAlgorithm()
byte[]getEncoded()
Returns the parameters in the default encoding format.
byte[]getEncoded(String format)
Returns the parameters in the specified encoding format.
static AlgorithmParametersgetInstance(String algorithm)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters.
static AlgorithmParametersgetInstance(String algorithm, String provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from a named provider.
static AlgorithmParametersgetInstance(String algorithm, Provider provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from the specified {@link Provider}.
<T extends AlgorithmParameterSpec> TgetParameterSpec(Class<T> paramSpec)
Returns a new instance of AlgorithmParameters as a designated parameter specification {@link Class}.
ProvidergetProvider()
voidinit(AlgorithmParameterSpec paramSpec)
Initializes the engine with the specified {@link AlgorithmParameterSpec}.
voidinit(byte[] params)
Initializes the engine with the specified parameters stored in the byte array and decodes them according to the ASN.1 specification.
voidinit(byte[] params, String format)
Initializes the engine with the specified parameters stored in the byte array and decodes them according to the specified decoding specification.
StringtoString()
Returns a string representation of the encoded form.

Constructor Detail

AlgorithmParameters

protected AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm)
Constructs a new instance of AlgorithmParameters.

Parameters: paramSpi the engine to use. provider the provider to use. algorithm the algorithm to use.

Method Detail

getAlgorithm

public final String getAlgorithm()

Returns: A string with the name of the algorithm used.

getEncoded

public final byte[] getEncoded()
Returns the parameters in the default encoding format. The primary encoding format is ASN.1 if it exists for the specified type.

Returns: byte array representing the parameters.

getEncoded

public final byte[] getEncoded(String format)
Returns the parameters in the specified encoding format. If format is null then the ASN.1 encoding format is used if it exists for the specified type.

Parameters: format the name of the encoding format to use.

Returns: the parameters encoded using the specified encoding scheme.

Throws: IOException if an encoding exception occurs, or if this parameter object has not been initialized.

getInstance

public static AlgorithmParameters getInstance(String algorithm)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters.

The returned AlgorithmParameters must still be initialized with an init() method.

Parameters: algorithm the algorithm to use.

Returns: the new instance repesenting the desired algorithm.

Throws: NoSuchAlgorithmException if the algorithm is not implemented by any provider. IllegalArgumentException if algorithm is null or is an empty string.

getInstance

public static AlgorithmParameters getInstance(String algorithm, String provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from a named provider.

The returned AlgorithmParameters must still be intialized with an init() method.

Parameters: algorithm the algorithm to use. provider the name of the {@link Provider} to use.

Returns: the new instance repesenting the desired algorithm.

Throws: NoSuchAlgorithmException if the algorithm is not implemented by the named provider. NoSuchProviderException if the named provider was not found. IllegalArgumentException if either algorithm or provider is null or empty.

getInstance

public static AlgorithmParameters getInstance(String algorithm, Provider provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from the specified {@link Provider}.

The returned AlgorithmParameters must still be intialized with an init() method.

Parameters: algorithm the algorithm to use. provider the {@link Provider} to use.

Returns: the new instance repesenting the desired algorithm.

Throws: NoSuchAlgorithmException if the algorithm is not implemented by the {@link Provider}. IllegalArgumentException if either algorithm or provider is null, or if algorithm is an empty string.

Since: 1.4

getParameterSpec

public final <T extends AlgorithmParameterSpec> T getParameterSpec(Class<T> paramSpec)
Returns a new instance of AlgorithmParameters as a designated parameter specification {@link Class}.

Parameters: paramSpec the {@link Class} to use.

Returns: the parameter specification.

Throws: InvalidParameterSpecException if paramSpec is invalid.

getProvider

public final Provider getProvider()

Returns: the provider of this parameter object.

init

public final void init(AlgorithmParameterSpec paramSpec)
Initializes the engine with the specified {@link AlgorithmParameterSpec}.

Parameters: paramSpec A {@link AlgorithmParameterSpec} to use.

Throws: InvalidParameterSpecException if paramSpec is invalid.

init

public final void init(byte[] params)
Initializes the engine with the specified parameters stored in the byte array and decodes them according to the ASN.1 specification. If the ASN.1 specification exists then it succeeds otherwise an {@link IOException} is thrown.

Parameters: params the parameters to use.

Throws: IOException if a decoding error occurs.

init

public final void init(byte[] params, String format)
Initializes the engine with the specified parameters stored in the byte array and decodes them according to the specified decoding specification. If format is null, then this method decodes the byte array using the ASN.1 specification if it exists, otherwise it throws an {@link IOException}.

Parameters: params the parameters to use. format the name of decoding format to use.

Throws: IOException if a decoding error occurs.

toString

public final String toString()
Returns a string representation of the encoded form.

Returns: a string representation of the encoded form.