public class AlgorithmParameters extends Object
可以通过调用getInstance工厂方法(返回给定类的实例的静态方法)来获得用于管理特定算法的AlgorithmParameters对象。
一旦获得了一个AlgorithmParameters对象,它必须通过调用init进行init ,使用适当的参数规范或参数编码。
通过调用getParameterSpec从AlgorithmParameters对象获得getParameterSpec ,并通过调用getEncoded获得参数的字节编码。
Java平台的每个实现都需要支持以下标准的AlgorithmParameters算法:
AES DES DESede DiffieHellman DSA AlgorithmParameterSpec , DSAParameterSpec , KeyPairGenerator
| Modifier | Constructor and Description |
|---|---|
protected |
AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm)
创建一个AlgorithmParameters对象。
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithm()
返回与此参数对象关联的算法的名称。
|
byte[] |
getEncoded()
返回其主要编码格式的参数。
|
byte[] |
getEncoded(String format)
返回在指定方案中编码的参数。
|
static AlgorithmParameters |
getInstance(String algorithm)
返回指定算法的参数对象。
|
static AlgorithmParameters |
getInstance(String algorithm, Provider provider)
返回指定算法的参数对象。
|
static AlgorithmParameters |
getInstance(String algorithm, String provider)
返回指定算法的参数对象。
|
<T extends AlgorithmParameterSpec> |
getParameterSpec(类<T> paramSpec)
返回此参数对象的(透明)规范。
|
Provider |
getProvider()
返回此参数对象的提供者。
|
void |
init(AlgorithmParameterSpec paramSpec)
使用paramSpec中
paramSpec的参数初始化此参数对象。
|
void |
init(byte[] params)
导入指定的参数,并根据参数的主要解码格式进行解码。
|
void |
init(byte[] params, String format)
从
params ,并根据指定的解码方案进行解码。
|
String |
toString()
返回描述参数的格式化字符串。
|
protected AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm)
paramSpi - 代表
provider - 提供商
algorithm - 算法
public final String getAlgorithm()
public static AlgorithmParameters getInstance(String algorithm) throws NoSuchAlgorithmException
此方法遍历已注册的安全提供程序列表,从最优选的提供程序开始。 返回从支持指定算法的第一个Provider中封装AlgorithmParametersSpi实现的新AlgorithmParameters对象。
请注意,可以通过Security.getProviders()方法检索已注册提供商的列表。
返回的参数对象必须通过调用init进行init ,使用适当的参数规范或参数编码。
algorithm - algorithm的名称。
看到的的AlgorithmParameters部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
NoSuchAlgorithmException - 如果没有提供者支持指定算法的AlgorithmParametersSpi实现。
Provider
public static AlgorithmParameters getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
返回从指定提供程序封装AlgorithmParametersSpi实现的新AlgorithmParameters对象。 指定的提供者必须在安全提供程序列表中注册。
请注意,注册提供商的列表可以通过Security.getProviders()方法检索 。
返回的参数对象必须通过调用init进行init ,使用适当的参数规范或参数编码。
algorithm - algorithm的名称。
看到的的AlgorithmParameters部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
provider - 提供者的名称。
NoSuchAlgorithmException - 如果指定算法的AlgorithmParametersSpi实现不能从指定的提供程序获得。
NoSuchProviderException - 如果指定的提供程序未在安全提供程序列表中注册。
IllegalArgumentException - 如果提供者名称为空或为空。
Provider
public static AlgorithmParameters getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
返回从指定的Provider对象封装AlgorithmParametersSpi实现的新AlgorithmParameters对象。 请注意,指定的Provider对象不必在提供者列表中注册。
返回的参数对象必须通过调用init进行init ,使用适当的参数规范或参数编码。
algorithm - algorithm的名称。
看到的的AlgorithmParameters部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
provider - 提供者的名称。
NoSuchAlgorithmException - 如果指定的算法的AlgorithmParameterGeneratorSpi实现从指定的Provider对象中不可用。
IllegalArgumentException - 如果提供者为空。
Provider
public final Provider getProvider()
public final void init(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
paramSpec的参数初始化此参数对象。
paramSpec - 参数规格。
InvalidParameterSpecException - 如果给定的参数规范不适用于此参数对象的初始化,或者该参数对象是否已初始化。
public final void init(byte[] params)
throws IOException
params - 编码参数。
IOException - 解码错误,或者该参数对象是否已被初始化。
public final void init(byte[] params,
String format)
throws IOException
params ,并根据指定的解码方案进行解码。
如果format为空,则使用参数的主要解码格式。
主要解码格式为ASN.1,如果存在这些参数的ASN.1规范。
params - 编码参数。
format - 解码方案的名称。
IOException - 解码错误,或者该参数对象是否已被初始化。
public final <T extends AlgorithmParameterSpec> T getParameterSpec(类<T> paramSpec) throws InvalidParameterSpecException
paramSpec标识了应该返回参数的规范类。
例如,它可以是DSAParameterSpec.class ,以表明在DSAParameterSpec类的实例中应该返回DSAParameterSpec 。
T - 要重新执行的参数规范的类型
paramSpec - 应该返回
paramSpec的规范类。
InvalidParameterSpecException - 如果请求的参数规范不适合此参数对象,或者该参数对象尚未初始化。
public final byte[] getEncoded()
throws IOException
IOException - 编码错误,或者该参数对象尚未初始化。
public final byte[] getEncoded(String format) throws IOException
format为空,则使用参数的主编码格式。
如果存在这些参数的ASN.1规范,则主编码格式为ASN.1。
format - 编码格式的名称
IOException - 对编码错误,或者该参数对象尚未初始化。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.