- java.lang.Object
-
- java.security.cert.PKIXParameters
-
- java.security.cert.PKIXBuilderParameters
-
- All Implemented Interfaces:
-
Cloneable,CertPathParameters
public class PKIXBuilderParameters extends PKIXParameters
参数用作PKIXCertPathBuilder算法的输入。一个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。并发访问
除非另有说明,否则此类中定义的方法不是线程安全的。 需要同时访问单个对象的多个线程应在其间同步并提供必要的锁定。 每个操作单独对象的多个线程不需要同步。
- 从以下版本开始:
- 1.4
- 另请参见:
-
CertPathBuilder
-
-
构造方法摘要
构造方法 Constructor 描述 PKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints)创建一个PKIXBuilderParameters的实例,它从指定的KeyStore包含的受信任证书条目填充最受信任的CAKeyStore。PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints)使用指定的Set最受信任的CA创建PKIXBuilderParameters的实例。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 intgetMaxPathLength()返回证书路径中可能存在的中间非自颁发证书的最大数量的值。voidsetMaxPathLength(int maxPathLength)设置认证路径中可能存在的非自发中间证书的最大数量的值。StringtoString()返回描述参数的格式化字符串。-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from 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
-
-
-
-
构造方法详细信息
-
PKIXBuilderParameters
public PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) throws InvalidAlgorithmParameterException
- 参数
-
trustAnchors- aSetofTrustAnchors -
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包含的受信任证书条目填充最受信任的CAKeyStore。 只考虑包含受信任的X509Certificate的密钥库条目; 所有其他证书类型将被忽略。- 参数
-
keystore- 一个KeyStore,从中可以填充最可靠的CA集 -
targetConstraints- 一个CertSelector指定目标证书的约束 - 异常
-
KeyStoreException- 如果keystore尚未初始化 -
InvalidAlgorithmParameterException- 如果keystore不包含至少一个可信证书条目 -
NullPointerException- 如果keystore是null
-
-
方法详细信息
-
setMaxPathLength
public void setMaxPathLength(int maxPathLength)
设置认证路径中可能存在的非自发中间证书的最大数量的值。 如果主体和发行者字段中出现的DN相同且不为空,则证书是自发证的。 请注意,认证路径中的最后一个证书不是中间证书,不包括在此限制内。 通常最后一个证书是终端实体证书,但它可以是CA证书。 PKIXCertPathBuilder实例不能构建比指定长度更长的路径。值为0表示路径只能包含单个证书。 值-1表示路径长度是无约束的(即没有最大值)。 默认最大路径长度(如果未指定)为5.设置小于-1的值将导致抛出异常。
如果任何CA证书包含
BasicConstraintsExtension,则只要结果是较小长度的认证路径,扩展名的pathLenConstraint字段的值将覆盖最大路径长度参数。- 参数
-
maxPathLength- 认证路径中可能存在的非自发中间证书的最大数量 - 异常
-
InvalidParameterException- 如果maxPathLength设置为小于-1的值 - 另请参见:
-
getMaxPathLength()
-
getMaxPathLength
public int getMaxPathLength()
返回证书路径中可能存在的中间非自颁发证书的最大数量的值。 有关详细信息,请参阅setMaxPathLength(int)方法。- 结果
- 认证路径中可能存在的非自发中间证书的最大数量,如果没有限制,则为-1
- 另请参见:
-
setMaxPathLength(int)
-
toString
public String toString()
返回描述参数的格式化字符串。- 重写:
-
toString在PKIXParameters - 结果
- a formatted string describing the parameters
-
-