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

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

Method Summary

extends AlgorithmParameterSpec> T getParameterSpec(Class paramSpec)
Returns a new instance of AlgorithmParameters as a designated parameter specification Class.
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, String provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from a named provider.
static AlgorithmParameters
getInstance(String algorithm, Provider provider)
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from the specified Provider.
Provider
getProvider()
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.
void
init(AlgorithmParameterSpec paramSpec)
Initializes the engine with the specified AlgorithmParameterSpec.
String
toString()
Returns a string representation of the encoded form.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

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 Details

extends AlgorithmParameterSpec> T getParameterSpec

public final extends AlgorithmParameterSpec>
  T getParameterSpec(Class paramSpec)
            throws InvalidParameterSpecException
Returns a new instance of AlgorithmParameters as a designated parameter specification Class.
Parameters:
paramSpec - the Class to use.
Returns:
the parameter specification.
Throws:
InvalidParameterSpecException - if paramSpec is invalid.

getAlgorithm

public final String getAlgorithm()
Returns:
A string with the name of the algorithm used.

getEncoded

public final byte[] getEncoded()
            throws IOException
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)
            throws IOException
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)
            throws NoSuchAlgorithmException
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)
            throws NoSuchAlgorithmException,
                   NoSuchProviderException
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 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)
            throws NoSuchAlgorithmException
Returns a new instance of AlgorithmParameters representing the specified algorithm parameters from the specified Provider.

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

Parameters:
algorithm - the algorithm to use.
provider - the Provider to use.
Returns:
the new instance repesenting the desired algorithm.
Throws:
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.
Since:
1.4

getProvider

public final Provider getProvider()
Returns:
the provider of this parameter object.

init

public final void init(byte[] params)
            throws IOException
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 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)
            throws IOException
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 IOException.
Parameters:
params - the parameters to use.
format - the name of decoding format to use.
Throws:
IOException - if a decoding error occurs.

init

public final void init(AlgorithmParameterSpec paramSpec)
            throws InvalidParameterSpecException
Initializes the engine with the specified AlgorithmParameterSpec.
Parameters:
paramSpec - A AlgorithmParameterSpec to use.
Throws:
InvalidParameterSpecException - if paramSpec is invalid.

toString

public final String toString()
Returns a string representation of the encoded form.
Overrides:
toString in interface Object
Returns:
a string representation of the encoded form.

AlgorithmParameters.java --- Algorithm Parameters Implementation Class Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.