java.lang.Object
java.security.cert.PKIXParameters
java.security.cert.PKIXBuilderParameters
- 所有已实现的接口:
-
Cloneable,CertPathParameters
用作PKIX
CertPathBuilder算法输入的参数。
PKIX CertPathBuilder使用这些参数来构建根据PKIX认证路径验证算法验证的CertPath。
要实例化一个PKIXBuilderParameters对象,应用程序必须根据PKIX认证路径验证算法定义的一个或多个最受信任的CA指定。最受信任的CA可以使用两个构造函数之一指定。应用程序可以调用PKIXBuilderParameters(Set, CertSelector),指定一个TrustAnchor对象的Set,每个对象标识一个最受信任的CA。另外,应用程序可以调用PKIXBuilderParameters(KeyStore, CertSelector),指定一个包含受信任证书条目的KeyStore实例,其中每个条目将被视为最受信任的CA。
此外,应用程序必须指定CertPathBuilder将尝试构建路径的目标证书的约束。这些约束被指定为一个CertSelector对象。这些约束应该为CertPathBuilder提供足够的搜索条件来找到目标证书。如果未指定足够的条件,CertPathBuilder可能会抛出一个CertPathBuilderException。
并发访问
除非另有说明,此类中定义的方法不是线程安全的。需要同时访问单个对象的多个线程应该在它们之间同步并提供必要的锁定。每个操作不同对象的多个线程不需要同步。
- 自:
- 1.4
- 参见:
-
Constructor Summary
ConstructorsConstructorDescriptionPKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints) 创建一个PKIXBuilderParameters实例,从指定的KeyStore中包含的受信任证书条目中填充最受信任的CA集合。PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) 创建一个具有指定Set最受信任CA的PKIXBuilderParameters实例。 -
Method Summary
Modifier and TypeMethodDescriptionint返回可能存在于认证路径中的中间非自签发证书的最大数量的值。voidsetMaxPathLength(int maxPathLength) 设置可能存在于认证路径中的非自签发中间证书的最大数量的值。toString()返回描述参数的格式化字符串。Methods declared in class java.security.cert.PKIXParameters
addCertPathChecker, addCertStore, clone, getCertPathCheckers, getCertStores, getDate, getInitialPolicies, getPolicyQualifiersRejected, getSigProvider, getTargetCertConstraints, getTrustAnchors, isAnyPolicyInhibited, isExplicitPolicyRequired, isPolicyMappingInhibited, isRevocationEnabled, setAnyPolicyInhibited, setCertPathCheckers, setCertStores, setDate, setExplicitPolicyRequired, setInitialPolicies, setPolicyMappingInhibited, setPolicyQualifiersRejected, setRevocationEnabled, setSigProvider, setTargetCertConstraints, setTrustAnchors
-
Constructor Details
-
PKIXBuilderParameters
public PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) throws InvalidAlgorithmParameterException - 参数:
-
trustAnchors- 一个TrustAnchor的Set -
targetConstraints- 指定目标证书约束的CertSelector - 抛出:
-
InvalidAlgorithmParameterException- 如果trustAnchors为空(trustAnchors.isEmpty() == true) -
NullPointerException- 如果trustAnchors为null -
ClassCastException- 如果trustAnchors的任何元素不是java.security.cert.TrustAnchor类型
-
PKIXBuilderParameters
public PKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints) throws KeyStoreException, InvalidAlgorithmParameterException 创建一个PKIXBuilderParameters实例,从指定的KeyStore中包含的受信任证书条目中填充最受信任的CA集合。只考虑包含受信任X509Certificate的密钥库条目;所有其他证书类型将被忽略。- 参数:
-
keystore- 用于填充最受信任CA集合的KeyStore -
targetConstraints- 指定目标证书约束的CertSelector - 抛出:
-
KeyStoreException- 如果keystore未初始化 -
InvalidAlgorithmParameterException- 如果keystore不包含至少一个受信任的证书条目 -
NullPointerException- 如果keystore为null
-
-
Method Details
-
setMaxPathLength
public void setMaxPathLength(int maxPathLength) 设置可能存在于认证路径中的非自签发中间证书的最大数量的值。如果主题和颁发者字段中出现的DN相同且不为空,则证书是自签发的。请注意,认证路径中的最后一个证书不是中间证书,不包括在此限制中。通常,最后一个证书是终端实体证书,但也可以是CA证书。PKIXCertPathBuilder实例不得构建超过指定长度的路径。值为0意味着路径只能包含单个证书。值为-1意味着路径长度没有限制(即没有最大值)。如果设置小于-1的值,将引发异常。
如果任何CA证书包含
BasicConstraintsExtension,则扩展的pathLenConstraint字段的值将在结果是较小长度的认证路径时覆盖最大路径长度参数。- 参数:
-
maxPathLength- 可存在于认证路径中的非自签发中间证书的最大数量 - 抛出:
-
InvalidParameterException- 如果maxPathLength设置为小于-1的值 - 参见:
-
getMaxPathLength
public int getMaxPathLength()返回可能存在于认证路径中的中间非自签发证书的最大数量的值。有关更多详细信息,请参阅setMaxPathLength(int)方法。- 返回:
- 可存在于认证路径中的非自签发中间证书的最大数量,如果没有限制则为-1
- 参见:
-
toString
返回描述参数的格式化字符串。- 覆盖:
-
toString在类PKIXParameters - 返回:
- 描述参数的格式化字符串
-