public class PKIXBuilderParameters
extends PKIXParameters
| java.lang.Object | ||
| java.security.cert.PKIXParameters | ||
| java.security.cert.PKIXBuilderParameters | ||
用作PKIX CertPathBuilder算法输入的参数。
甲PKIX CertPathBuilder使用这些参数来 build一个 CertPath已经根据PKIX证书路径验证算法验证。
要实例化一个PKIXBuilderParameters对象,应用程序必须指定一个或多个由PKIX证书路径验证算法定义的最受信任的CA. 最可信的CA可以使用两个构造函数之一来指定。 应用程序可以调用PKIXBuilderParameters(Set, CertSelector) ,指定Set的TrustAnchor对象,每个对象的标识最信任的CA. 或者,应用程序可以调用PKIXBuilderParameters(KeyStore, CertSelector) ,指定包含可信证书条目的KeyStore实例,每个实例将被视为最受信任的CA.
另外,应用程序必须指定CertPathBuilder将尝试构建路径的目标证书上的约束。 约束被指定为一个CertSelector对象。 这些限制应该为CertPathBuilder提供足够的搜索条件来查找目标证书。 X509Certificate最低标准通常包括主题名称和/或一个或多个主题替代名称。 如果没有指定足够的标准,则CertPathBuilder可能会抛出CertPathBuilderException 。
并发访问
除非另有说明,否则此类中定义的方法不是线程安全的。 需要同时访问单个对象的多个线程应该自己同步并提供必要的锁定。 每个操作单独对象的多个线程不需要同步。
也可以看看:
Public constructors |
|
|---|---|
PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) 使用最受信任的CA的指定 |
|
PKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints) 创建一个 |
|
公共方法(Public methods) |
|
|---|---|
int |
getMaxPathLength() 返回证书路径中可能存在的中间非自我颁发证书的最大数量值。 |
void |
setMaxPathLength(int maxPathLength) 设置证书路径中可能存在的非自发中间证书的最大数量的值。 |
String |
toString() 返回描述参数的格式化字符串。 |
继承方法(Inherited methods) |
|
|---|---|
java.security.cert.PKIXParameters
|
|
java.lang.Object
|
|
java.security.cert.CertPathParameters
|
|
PKIXBuilderParameters (Set<TrustAnchor> trustAnchors, CertSelector targetConstraints)
用指定的Set最受信任的CA创建PKIXBuilderParameters的实例。 该集合中的每个元素都是TrustAnchor 。
请注意,复制了 Set以防止后续修改。
| 参数(Parameters) | |
|---|---|
trustAnchors |
Set: a Set of TrustAnchors |
targetConstraints |
CertSelector: a CertSelector specifying the constraints on the target certificate |
| 抛出异常(Throws) | |
|---|---|
InvalidAlgorithmParameterException |
if trustAnchors is empty (trustAnchors.isEmpty() == true) |
NullPointerException |
if trustAnchors is null |
ClassCastException |
if any of the elements of trustAnchors are not of type java.security.cert.TrustAnchor |
PKIXBuilderParameters (KeyStore keystore, CertSelector targetConstraints)
创建一个PKIXBuilderParameters的实例,该实例从指定的KeyStore包含的可信证书条目填充最受信任CA的KeyStore 。 只考虑包含可信X509Certificate的密钥库条目; 所有其他证书类型都将被忽略。
| 参数(Parameters) | |
|---|---|
keystore |
KeyStore: a KeyStore from which the set of most-trusted CAs will be populated |
targetConstraints |
CertSelector: a CertSelector specifying the constraints on the target certificate |
| 抛出异常(Throws) | |
|---|---|
KeyStoreException |
if keystore has not been initialized |
InvalidAlgorithmParameterException |
if keystore does not contain at least one trusted certificate entry |
NullPointerException |
if keystore is null |
int getMaxPathLength ()
返回证书路径中可能存在的中间非自我颁发证书的最大数量值。 有关更多详细信息,请参阅setMaxPathLength(int)方法。
| 返回(Returns) | |
|---|---|
int |
the maximum number of non-self-issued intermediate certificates that may exist in a certification path, or -1 if there is no limit |
也可以看看:
void setMaxPathLength (int maxPathLength)
设置证书路径中可能存在的非自发中间证书的最大数量的值。 如果出现在主题和发行者字段中的DN相同且不为空,则证书是自行发行的。 请注意,证书路径中的最后一个证书不是中间证书,并且不包含在此限制中。 通常最后一个证书是一个最终实体证书,但它可以是一个CA证书。 PKIX CertPathBuilder实例不得构建比指定长度更长的路径。
值为0意味着该路径只能包含一个证书。 值-1意味着路径长度不受约束(即没有最大值)。 默认的最大路径长度(如果未指定)为5.设置小于-1的值将引发异常。
如果任何CA证书包含 BasicConstraintsExtension ,则只要结果是较小长度的证书路径,扩展的 pathLenConstraint字段的值 pathLenConstraint覆盖最大路径长度参数。
| 参数(Parameters) | |
|---|---|
maxPathLength |
int: the maximum number of non-self-issued intermediate certificates that may exist in a certification path |
| 抛出异常(Throws) | |
|---|---|
InvalidParameterException |
if maxPathLength is set to a value less than -1 |
也可以看看:
String toString ()
返回描述参数的格式化字符串。
| 返回(Returns) | |
|---|---|
String |
a formatted string describing the parameters |