java.security
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.AlgorithmParameterSpec
,
DSAParameterSpec
,
KeyPairGenerator
Modifier | Constructor and Description |
---|---|
protected |
AlgorithmParameters(AlgorithmParametersSpi paramSpi,
Provider provider,
String algorithm)
Constructs a new instance of
AlgorithmParameters . |
Modifier and Type | Method and Description |
---|---|
String |
getAlgorithm() |
byte[] |
getEncoded()
Returns the parameters in the default encoding format.
|
byte[] |
getEncoded(String format)
Returns the parameters in the specified encoding format.
|
static AlgorithmParameters |
getInstance(String algorithm)
Returns a new instance of
AlgorithmParameters representing
the specified algorithm parameters. |
static AlgorithmParameters |
getInstance(String algorithm,
Provider provider)
Returns a new instance of
AlgorithmParameters representing
the specified algorithm parameters from the specified Provider . |
static AlgorithmParameters |
getInstance(String algorithm,
String provider)
Returns a new instance of
AlgorithmParameters representing
the specified algorithm parameters from a named provider. |
<T extends AlgorithmParameterSpec> |
getParameterSpec(Class<T> paramSpec)
Returns a new instance of
AlgorithmParameters as a
designated parameter specification Class . |
Provider |
getProvider() |
void |
init(AlgorithmParameterSpec paramSpec)
Initializes the engine with the specified
AlgorithmParameterSpec . |
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.
|
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.
|
String |
toString()
Returns a string representation of the encoded form.
|
protected AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm)
AlgorithmParameters
.paramSpi
- the engine to use.provider
- the provider to use.algorithm
- the algorithm to use.public final String getAlgorithm()
public static AlgorithmParameters getInstance(String algorithm) throws NoSuchAlgorithmException
AlgorithmParameters
representing
the specified algorithm parameters.
The returned AlgorithmParameters
must still be initialized
with an init()
method.
algorithm
- the algorithm to use.NoSuchAlgorithmException
- if the algorithm is not implemented by any
provider.IllegalArgumentException
- if algorithm
is
null
or is an empty string.public static AlgorithmParameters getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
AlgorithmParameters
representing
the specified algorithm parameters from a named provider.
The returned AlgorithmParameters
must still be intialized
with an init()
method.
algorithm
- the algorithm to use.provider
- the name of the Provider
to use.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.public static AlgorithmParameters getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
AlgorithmParameters
representing
the specified algorithm parameters from the specified Provider
.
The returned AlgorithmParameters
must still be intialized
with an init()
method.
algorithm
- the algorithm to use.provider
- the Provider
to use.NoSuchAlgorithmException
- if the algorithm is not implemented by the
Provider
.IllegalArgumentException
- if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.public final Provider getProvider()
public final void init(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
AlgorithmParameterSpec
.paramSpec
- A AlgorithmParameterSpec
to use.InvalidParameterSpecException
- if paramSpec
is invalid.public final void init(byte[] params) throws IOException
IOException
is
thrown.params
- the parameters to use.IOException
- if a decoding error occurs.public final void init(byte[] params, String format) throws IOException
format
is null
, then this method decodes the
byte array using the ASN.1 specification if it exists, otherwise it throws
an IOException
.params
- the parameters to use.format
- the name of decoding format to use.IOException
- if a decoding error occurs.public final <T extends AlgorithmParameterSpec> T getParameterSpec(Class<T> paramSpec) throws InvalidParameterSpecException
AlgorithmParameters
as a
designated parameter specification Class
.paramSpec
- the Class
to use.InvalidParameterSpecException
- if paramSpec
is invalid.public final byte[] getEncoded() throws IOException
IOException
public final byte[] getEncoded(String format) throws IOException
format
is null
then the ASN.1 encoding
format is used if it exists for the specified type.format
- the name of the encoding format to use.IOException
- if an encoding exception occurs, or if this parameter object has
not been initialized.public final String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)