public class CertPathValidator extends Object
这个类使用基于提供者的架构。 要创建一个CertPathValidator ,请调用静态getInstance方法之一,传递所需的算法名称CertPathValidator和可选的所需提供商的名称。
一旦CertPathValidator对象被创建,它可以用来通过调用来验证证书路径validate方法并传递它的CertPath被验证和特定于算法的一组参数。 如果成功,则会在CertPathValidatorResult CertPathValidatorResult接口的对象中返回结果。
getRevocationChecker()方法允许应用CertPathValidator在检查证书的撤销状态时指定CertPathValidator使用的其他特定于算法的参数和选项。 下面是一个演示如何使用PKIX算法的例子:
CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
PKIXRevocationChecker rc = (PKIXRevocationChecker)cpv.getRevocationChecker();
rc.setOptions(EnumSet.of(Option.SOFT_FAIL));
params.addCertPathChecker(rc);
CertPathValidatorResult cpvr = cpv.validate(path, params);
Java平台的每个实现都需要支持以下标准CertPathValidator算法:
PKIX 并发访问
该类的静态方法保证线程安全。 多个线程可以同时调用此类中定义的静态方法,而不会产生不良影响。
但是,对于此类定义的非静态方法,这不是真的。 除非特定提供者另有说明,否则需要同时访问单个CertPathValidator实例的线程应在其间同步并提供必要的锁定。 多个线程各自操纵不同的CertPathValidator实例不需要同步。
CertPath
| Modifier | Constructor and Description |
|---|---|
protected |
CertPathValidator(CertPathValidatorSpi validatorSpi, Provider provider, String algorithm)
创建给定算法的
CertPathValidator对象,并将给定的提供者实现(SPI对象)封装在其中。
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithm()
返回此的算法名称
CertPathValidator 。
|
static String |
getDefaultType()
返回由
certpathvalidator.type安全属性指定的默认
CertPathValidator类型,如果不存在此属性,则返回字符串“PKIX”。
|
static CertPathValidator |
getInstance(String algorithm)
返回实现
CertPathValidator对象。
|
static CertPathValidator |
getInstance(String algorithm, Provider provider)
返回实现
CertPathValidator对象。
|
static CertPathValidator |
getInstance(String algorithm, String provider)
返回实现
CertPathValidator对象。
|
Provider |
getProvider()
返回此
Provider的
CertPathValidator 。
|
CertPathChecker |
getRevocationChecker()
返回
CertPathChecker ,该封装
CertPathValidatorSpi实现使用检查证书的吊销状态。
|
CertPathValidatorResult |
validate(CertPath certPath, CertPathParameters params)
使用指定的算法参数集验证指定的认证路径。
|
protected CertPathValidator(CertPathValidatorSpi validatorSpi, Provider provider, String algorithm)
CertPathValidator对象,并将给定的提供者实现(SPI对象)封装在其中。
validatorSpi - 提供者实现
provider - 提供商
algorithm - 算法名称
public static CertPathValidator getInstance(String algorithm) throws NoSuchAlgorithmException
CertPathValidator对象。
此方法遍历已注册的安全提供程序列表,从最优选的提供程序开始。 返回从支持指定算法的第一个Provider中封装CertPathValidatorSpi实现的新CertPathValidator对象。
请注意,注册提供商的列表可以通过Security.getProviders()方法检索 。
algorithm - 所请求的CertPathValidator算法的名称。
看到的的CertPathValidator部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
CertPathValidator指定算法的CertPathValidator对象。
NoSuchAlgorithmException - 如果没有提供者支持指定算法的CertPathValidatorSpi实现。
Provider
public static CertPathValidator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
CertPathValidator对象。
返回从指定提供程序封装CertPathValidatorSpi实现的新CertPathValidator对象。 指定的提供者必须在安全提供程序列表中注册。
请注意,注册提供商的列表可以通过Security.getProviders()方法检索 。
algorithm - 所请求的CertPathValidator算法的名称。
看到的的CertPathValidator部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
provider - 提供商的名称。
CertPathValidator指定算法的CertPathValidator对象。
NoSuchAlgorithmException - 如果指定算法的CertPathValidatorSpi实现不能从指定的提供程序获得。
NoSuchProviderException - 如果指定的提供程序未在安全提供程序列表中注册。
IllegalArgumentException - 如果
provider为空或为空。
Provider
public static CertPathValidator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
CertPathValidator对象。
返回从指定的Provider对象封装CertPathValidatorSpi实现的新CertPathValidator对象。 请注意,指定的Provider对象不必在提供者列表中注册。
algorithm - 所请求的CertPathValidator算法的名称。
看到的的CertPathValidator部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准算法名称的信息。
provider - 提供商。
CertPathValidator指定算法的CertPathValidator对象。
NoSuchAlgorithmException - 如果指定的算法的CertPathValidatorSpi实现从指定的Provider对象不可用。
IllegalArgumentException - 如果
provider为空。
Provider
public final Provider getProvider()
Provider的
CertPathValidator 。
Provider的这个
CertPathValidator
public final String getAlgorithm()
CertPathValidator 。
CertPathValidator
public final CertPathValidatorResult validate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, InvalidAlgorithmParameterException
CertPath CertPath必须是CertPath支持的类型, InvalidAlgorithmParameterException将抛出InvalidAlgorithmParameterException 。 例如, CertPathValidator实现该算法PKIX验证CertPath类型X.509的对象。
certPath -在
CertPath进行验证
params - 算法参数
CertPathValidatorException - 如果
CertPath没有验证
InvalidAlgorithmParameterException - 如果指定的参数或指定的类型
CertPath不适合此
CertPathValidator
public static final String getDefaultType()
certpathvalidator.type安全属性指定的默认CertPathValidator类型,如果不存在此属性,则返回字符串“PKIX”。
默认的CertPathValidator类型可以由不想在调用getInstance方法之一时使用硬编码类型的getInstance程序使用,并且希望在用户未指定自己的情况下提供默认类型。
可以通过将certpathvalidator.type安全属性的值设置为所需类型来更改默认值CertPathValidator类型。
CertPathValidator类型由
certpathvalidator.type安全属性指定,或者如果没有这样的属性存在字符串“PKIX”。
security properties
public final CertPathChecker getRevocationChecker()
CertPathChecker ,该封装CertPathValidatorSpi实现使用检查证书的吊销状态。
PKIX实现返回PKIXRevocationChecker类型的PKIXRevocationChecker 。
每次调用此方法返回一个新的实例CertPathChecker 。
此方法的主要目的是允许调用者指定额外的输入参数和特定于撤销检查的选项。 参见课程说明一个例子。
CertPathChecker
UnsupportedOperationException - 如果服务提供商不支持此方法
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.