- 所有已实现的接口:
-
Cloneable
,CertPathParameters
- 直接已知的子类:
-
PKIXBuilderParameters
CertPathValidator
算法输入的参数。
PKIX CertPathValidator
使用这些参数根据PKIX认证路径验证算法验证CertPath
。
要实例化一个PKIXParameters
对象,应用程序必须根据PKIX认证路径验证算法定义的一个或多个最受信任的CA指定。最受信任的CA可以使用两种构造函数之一指定。应用程序可以调用PKIXParameters(Set)
,指定一个TrustAnchor
对象的Set
,每个对象标识一个最受信任的CA。另外,应用程序可以调用PKIXParameters(KeyStore)
,指定一个包含受信任证书条目的KeyStore
实例,其中每个条目将被视为最受信任的CA。
创建了PKIXParameters
对象后,可以指定其他参数(例如通过调用setInitialPolicies
或setDate
),然后将PKIXParameters
与要验证的CertPath
一起传递给CertPathValidator.validate
。
任何未设置的参数(或设置为null
)将设置为该参数的默认值。 date
参数的默认值为null
,表示验证路径时的当前时间。其余参数的默认值为最不受限制的。
并发访问
除非另有说明,此类中定义的方法不是线程安全的。需要同时访问单个对象的多个线程应在它们之间同步并提供必要的锁定。每个操作不需要同步的多个线程分别操作不同的对象。
- 自:
- 1.4
- 参见:
-
Constructor Summary
ConstructorDescriptionPKIXParameters
(KeyStore keystore) 创建一个PKIXParameters
实例,从指定的KeyStore
中包含的受信任证书条目填充最受信任的CA集合。PKIXParameters
(Set<TrustAnchor> trustAnchors) 创建一个具有指定最受信任CASet
的PKIXParameters
实例。 -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCertPathChecker
(PKIXCertPathChecker checker) 将PKIXCertPathChecker
添加到认证路径检查器列表中。void
addCertStore
(CertStore store) 将CertStore
添加到用于查找证书和CRL的CertStore
列表的末尾。clone()
复制此PKIXParameters
对象。返回认证路径检查器的List
。返回一个不可变的用于查找证书和CRL的CertStore
列表。getDate()
返回应确定认证路径有效性的时间。返回初始策略标识符(OID字符串)的不可变Set
,指示这些策略中的任何一个对于证书用户来说都是可接受的,用于认证路径处理的目的。boolean
获取PolicyQualifiersRejected标志。返回签名提供程序的名称,如果未设置则返回null
。返回目标证书的所需约束。返回一个不可变的最受信任CA的Set
。boolean
检查是否应处理包含在证书中的任何策略OID。boolean
检查是否需要显式策略。boolean
检查是否禁止策略映射。boolean
检查RevocationEnabled标志。void
setAnyPolicyInhibited
(boolean val) 设置状态以确定是否应处理包含在证书中的任何策略OID。void
setCertPathCheckers
(List<PKIXCertPathChecker> checkers) 设置额外认证路径检查器的List
。void
setCertStores
(List<CertStore> stores) 设置用于查找证书和CRL的CertStore
列表。void
设置应确定认证路径有效性的时间。void
setExplicitPolicyRequired
(boolean val) 设置ExplicitPolicyRequired标志。void
setInitialPolicies
(Set<String> initialPolicies) 设置初始策略标识符(OID字符串)的Set
,指示这些策略中的任何一个对于证书用户来说都是可接受的,用于认证路径处理的目的。void
setPolicyMappingInhibited
(boolean val) 设置PolicyMappingInhibited标志。void
setPolicyQualifiersRejected
(boolean qualifiersRejected) 设置PolicyQualifiersRejected标志。void
setRevocationEnabled
(boolean val) 设置RevocationEnabled标志。void
setSigProvider
(String sigProvider) 设置签名提供程序的名称。void
setTargetCertConstraints
(CertSelector selector) 设置目标证书的所需约束。void
setTrustAnchors
(Set<TrustAnchor> trustAnchors) 设置最受信任CA的Set
。toString()
返回描述参数的格式化字符串。
-
Constructor Details
-
PKIXParameters
- 参数:
-
trustAnchors
- 一个TrustAnchor
的Set
- 抛出:
-
InvalidAlgorithmParameterException
- 如果指定的Set
为空(trustAnchors.isEmpty() == true)
-
NullPointerException
- 如果指定的Set
为null
-
ClassCastException
- 如果Set
中的任何元素不是java.security.cert.TrustAnchor
类型
-
PKIXParameters
public PKIXParameters(KeyStore keystore) throws KeyStoreException, InvalidAlgorithmParameterException 创建一个PKIXParameters
实例,从指定的KeyStore
中包含的受信任证书条目填充最受信任的CA集合。仅考虑包含受信任X509Certificates
的密钥库条目;所有其他证书类型将被忽略。- 参数:
-
keystore
- 用于填充最受信任CA集合的KeyStore
- 抛出:
-
KeyStoreException
- 如果密钥库未初始化 -
InvalidAlgorithmParameterException
- 如果密钥库不包含至少一个受信任的证书条目 -
NullPointerException
- 如果密钥库为null
-
-
Method Details
-
getTrustAnchors
返回一个不可变的最受信任CA的Set
。- 返回:
-
一个不可变的
Set
,包含TrustAnchor
(永不为null
) - 参见:
-
setTrustAnchors
public void setTrustAnchors(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException 设置最受信任CA的Set
。请注意,为防止后续修改,将复制
Set
。- 参数:
-
trustAnchors
- 一个TrustAnchor
的Set
- 抛出:
-
InvalidAlgorithmParameterException
- 如果指定的Set
为空(trustAnchors.isEmpty() == true)
-
NullPointerException
- 如果指定的Set
为null
-
ClassCastException
- 如果集合中的任何元素不是java.security.cert.TrustAnchor
类型 - 参见:
-
getInitialPolicies
返回一个不可变的初始策略标识符(OID字符串)的Set
,指示这些策略中的任何一个对于证书用户来说都是可接受的,用于认证路径处理的目的。默认返回值是一个空的Set
,解释为任何策略都是可接受的。- 返回:
-
一个不可变的
Set
,包含String
格式的初始策略OID,或一个空的Set
(表示任何策略都是可接受)。永不返回null
。 - 参见:
-
setInitialPolicies
设置初始策略标识符(OID字符串)的Set
,指示这些策略中的任何一个对于证书用户来说都是可接受的,用于认证路径处理的目的。默认情况下,任何策略都是可接受的(即所有策略),因此希望允许任何策略作为可接受的用户不需要调用此方法,或者可以使用空的Set
(或null
)调用它。请注意,为防止后续修改,将复制
Set
。- Parameters:
-
initialPolicies
- aSet
of initial policy OIDs inString
format (ornull
) - Throws:
-
ClassCastException
- if any of the elements in the set are not of typeString
- See Also:
-
setCertStores
Sets the list ofCertStore
s to be used in finding certificates and CRLs. May benull
, in which case noCertStore
s will be used. The firstCertStore
s in the list may be preferred to those that appear later.Note that the
List
is copied to protect against subsequent modifications.- Parameters:
-
stores
- aList
ofCertStore
s (ornull
) - Throws:
-
ClassCastException
- if any of the elements in the list are not of typejava.security.cert.CertStore
- See Also:
-
addCertStore
Adds aCertStore
to the end of the list ofCertStore
s used in finding certificates and CRLs.- Parameters:
-
store
- theCertStore
to add. Ifnull
, the store is ignored (not added to list).
-
getCertStores
Returns an immutableList
ofCertStore
s that are used to find certificates and CRLs.- Returns:
-
an immutable
List
ofCertStore
s (may be empty, but nevernull
) - See Also:
-
setRevocationEnabled
public void setRevocationEnabled(boolean val) Sets the RevocationEnabled flag. If this flag is true, the default revocation checking mechanism of the underlying PKIX service provider will be used, unless aPKIXRevocationChecker
is passed in as aCertPathChecker
(see below for further explanation). If this flag is false, the default revocation checking mechanism will be disabled (not used).When a
PKIXParameters
object is created, this flag is set to true. This setting reflects the most common strategy for checking revocation, since each service provider must support revocation checking to be PKIX compliant. Sophisticated applications should set this flag to false when it is not practical to use a PKIX service provider's default revocation checking mechanism or when an alternative revocation checking mechanism is to be substituted (by also calling theaddCertPathChecker
orsetCertPathCheckers
methods).Note that when a
PKIXRevocationChecker
is passed in as a parameter via theaddCertPathChecker
orsetCertPathCheckers
methods, it will be used to check revocation irrespective of the setting of the RevocationEnabled flag.- Parameters:
-
val
- the new value of the RevocationEnabled flag
-
isRevocationEnabled
public boolean isRevocationEnabled()Checks the RevocationEnabled flag. If this flag is true, the default revocation checking mechanism of the underlying PKIX service provider will be used, unless aPKIXRevocationChecker
is passed in as aCertPathChecker
. If this flag is false, the default revocation checking mechanism will be disabled (not used). See thesetRevocationEnabled
method for more details on setting the value of this flag.- Returns:
- the current value of the RevocationEnabled flag
-
setExplicitPolicyRequired
public void setExplicitPolicyRequired(boolean val) Sets the ExplicitPolicyRequired flag. If this flag is true, an acceptable policy needs to be explicitly identified in every certificate. By default, the ExplicitPolicyRequired flag is false.- Parameters:
-
val
-true
if explicit policy is to be required,false
otherwise
-
isExplicitPolicyRequired
public boolean isExplicitPolicyRequired()Checks if explicit policy is required. If this flag is true, an acceptable policy needs to be explicitly identified in every certificate. By default, the ExplicitPolicyRequired flag is false.- Returns:
-
true
if explicit policy is required,false
otherwise
-
setPolicyMappingInhibited
public void setPolicyMappingInhibited(boolean val) Sets the PolicyMappingInhibited flag. If this flag is true, policy mapping is inhibited. By default, policy mapping is not inhibited (the flag is false).- Parameters:
-
val
-true
if policy mapping is to be inhibited,false
otherwise
-
isPolicyMappingInhibited
public boolean isPolicyMappingInhibited()Checks if policy mapping is inhibited. If this flag is true, policy mapping is inhibited. By default, policy mapping is not inhibited (the flag is false).- Returns:
- true if policy mapping is inhibited, false otherwise
-
setAnyPolicyInhibited
public void setAnyPolicyInhibited(boolean val) Sets state to determine if the any policy OID should be processed if it is included in a certificate. By default, the any policy OID is not inhibited (isAnyPolicyInhibited()
returnsfalse
).- Parameters:
-
val
-true
if the any policy OID is to be inhibited,false
otherwise
-
isAnyPolicyInhibited
public boolean isAnyPolicyInhibited()Checks whether the any policy OID should be processed if it is included in a certificate.- Returns:
-
true
if the any policy OID is inhibited,false
otherwise
-
setPolicyQualifiersRejected
public void setPolicyQualifiersRejected(boolean qualifiersRejected) Sets the PolicyQualifiersRejected flag. If this flag is true, certificates that include policy qualifiers in a certificate policies extension that is marked critical are rejected. If the flag is false, certificates are not rejected on this basis.When a
PKIXParameters
object is created, this flag is set to true. This setting reflects the most common (and simplest) strategy for processing policy qualifiers. Applications that want to use a more sophisticated policy must set this flag to false.Note that the PKIX certification path validation algorithm specifies that any policy qualifier in a certificate policies extension that is marked critical must be processed and validated. Otherwise the certification path must be rejected. If the policyQualifiersRejected flag is set to false, it is up to the application to validate all policy qualifiers in this manner in order to be PKIX compliant.
- Parameters:
-
qualifiersRejected
- the new value of the PolicyQualifiersRejected flag - See Also:
-
getPolicyQualifiersRejected
public boolean getPolicyQualifiersRejected()Gets the PolicyQualifiersRejected flag. If this flag is true, certificates that include policy qualifiers in a certificate policies extension that is marked critical are rejected. If the flag is false, certificates are not rejected on this basis.When a
PKIXParameters
object is created, this flag is set to true. This setting reflects the most common (and simplest) strategy for processing policy qualifiers. Applications that want to use a more sophisticated policy must set this flag to false.- Returns:
- the current value of the PolicyQualifiersRejected flag
- See Also:
-
getDate
Returns the time for which the validity of the certification path should be determined. Ifnull
, the current time is used.Note that the
Date
returned is copied to protect against subsequent modifications.- Returns:
-
the
Date
, ornull
if not set - See Also:
-
setDate
Sets the time for which the validity of the certification path should be determined. Ifnull
, the current time is used.Note that the
Date
supplied here is copied to protect against subsequent modifications.- Parameters:
-
date
- theDate
, ornull
for the current time - See Also:
-
setCertPathCheckers
Sets aList
of additional certification path checkers. If the specifiedList
contains an object that is not aPKIXCertPathChecker
, it is ignored.Each
PKIXCertPathChecker
specified implements additional checks on a certificate. Typically, these are checks to process and verify private extensions contained in certificates. EachPKIXCertPathChecker
should be instantiated with any initialization parameters needed to execute the check.This method allows sophisticated applications to extend a PKIX
CertPathValidator
orCertPathBuilder
. Each of the specifiedPKIXCertPathChecker
s will be called, in turn, by a PKIXCertPathValidator
orCertPathBuilder
for each certificate processed or validated.Regardless of whether these additional
PKIXCertPathChecker
s are set, a PKIXCertPathValidator
orCertPathBuilder
must perform all of the required PKIX checks on each certificate. The one exception to this rule is if the RevocationEnabled flag is set to false (see thesetRevocationEnabled
method).Note that the
List
supplied here is copied and eachPKIXCertPathChecker
in the list is cloned to protect against subsequent modifications.- 参数:
-
checkers
- 一个List
,其中包含PKIXCertPathChecker
。可能为null
,在这种情况下将不使用任何额外的检查器。 - 抛出:
-
ClassCastException
- 如果列表中的任何元素不是java.security.cert.PKIXCertPathChecker
类型 - 参见:
-
getCertPathCheckers
返回证书路径检查器的List
。返回的List
是不可变的,List
中的每个PKIXCertPathChecker
都会被克隆以防止后续修改。- 返回:
-
一个不可变的
List
,包含PKIXCertPathChecker
(可能为空,但不为null
) - 参见:
-
addCertPathChecker
向证书路径检查器列表添加一个PKIXCertPathChecker
。有关更多详细信息,请参阅setCertPathCheckers
方法。请注意,
PKIXCertPathChecker
会被克隆以防止后续修改。- 参数:
-
checker
- 要添加到检查列表中的PKIXCertPathChecker
。如果为null
,则会被忽略(不会添加到列表中)。
-
getSigProvider
返回签名提供程序的名称,如果未设置则返回null
。- 返回:
-
签名提供程序的名称(或
null
) - 参见:
-
setSigProvider
设置签名提供程序的名称。在创建Signature
对象时,将优先使用指定的提供程序。如果为null
或未设置,则将使用支持该算法的第一个找到的提供程序。- 参数:
-
sigProvider
- 签名提供程序的名称(或null
) - 参见:
-
getTargetCertConstraints
返回目标证书的所需约束。约束将作为CertSelector
的实例返回。如果为null
,则未定义任何约束。请注意,返回的
CertSelector
会被克隆以防止后续修改。- 返回:
-
指定目标证书约束的
CertSelector
(或null
) - 参见:
-
setTargetCertConstraints
设置目标证书的所需约束。约束将作为CertSelector
的实例指定。如果为null
,则未定义任何约束。请注意,指定的
CertSelector
会被克隆以防止后续修改。- 参数:
-
selector
- 指定目标证书约束的CertSelector
(或null
) - 参见:
-
clone
复制此PKIXParameters
对象。对副本的更改不会影响原始对象,反之亦然。- 指定者:
-
clone
在接口CertPathParameters
- 覆盖:
-
clone
在类Object
- 返回:
-
此
PKIXParameters
对象的副本 - 参见:
-
toString
返回描述参数的格式化字符串。
-