public class CertStore
extends Object
| java.lang.Object | |
| java.security.cert.CertStore | |
用于从存储库中检索 Certificate和 CRL的类。
这个类使用基于提供者的架构。 要创建CertStore ,请调用其中一个静态getInstance方法,传递所需的类型CertStore ,任何适用的初始化参数以及可选的所需提供者的名称。
一旦 CertStore被创建,它可以被用来获取 Certificate S和 CRL通过调用以S getCertificates种 getCRLs方法。
与提供对私钥和可信证书缓存的访问的KeyStore不同, CertStore旨在提供对潜在巨大的不可信证书和CRL存储库的访问。 例如, CertStore的LDAP实现使用LDAP服务属性中定义的LDAP协议和架构提供对存储在一个或多个目录中的证书和CRL的访问。
Android提供以下 CertStore类型:
| Name | Supported (API Levels) |
|---|---|
| Collection | 1+ |
并发访问
所有公共方法的CertStore对象必须是线程安全的。 也就是说,多个线程可以同时在单个CertStore对象(或多个对象)上调用这些方法,而不会产生不良影响。 例如,这允许CertPathBuilder搜索CRL,同时搜索更多证书。
这个类的静态方法也保证是线程安全的。 多线程可能会同时调用此类中定义的静态方法,而不会产生不良影响。
Protected constructors |
|
|---|---|
CertStore(CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params) 创建给定类型的 |
|
公共方法(Public methods) |
|
|---|---|
final Collection<? extends CRL> |
getCRLs(CRLSelector selector) 返回与指定选择器匹配的 |
final CertStoreParameters |
getCertStoreParameters() 返回用于初始化此 |
final Collection<? extends Certificate> |
getCertificates(CertSelector selector) 返回与指定选择器匹配的 |
static final String |
getDefaultType() 返回Java安全性属性文件中指定的默认 |
static CertStore |
getInstance(String type, CertStoreParameters params) 返回一个 |
static CertStore |
getInstance(String type, CertStoreParameters params, Provider provider) 返回实现指定的 |
static CertStore |
getInstance(String type, CertStoreParameters params, String provider) 返回实现指定的 |
final Provider |
getProvider() 返回此 |
final String |
getType() 返回这个 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
CertStore (CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params)
创建给定类型的 CertStore对象,并将给定的提供者实现(SPI对象)封装在其中。
| 参数(Parameters) | |
|---|---|
storeSpi |
CertStoreSpi: the provider implementation |
provider |
Provider: the provider |
type |
String: the type |
params |
CertStoreParameters: the initialization parameters (may be null) |
Collection<? extends CRL> getCRLs (CRLSelector selector)
返回与指定选择器匹配的Collection个CRL 。 如果没有CRL与选择器匹配,则返回一个空的Collection 。
对于某些CertStore类型,生成的Collection可能不包含匹配选择器的所有 CRL 。 例如,LDAP CertStore可能不会搜索目录中的所有条目。 相反,它可能只是搜索可能包含它正在寻找的CRL的条目。
一些CertStore实现(尤其是LDAP CertStore )可能会抛出CertStoreException除非提供了包含可用于查找CRL的特定条件的非空CRLSelector 。 发行人名称和/或要检查的证书特别有用。
| 参数(Parameters) | |
|---|---|
selector |
CRLSelector: A CRLSelector used to select which CRLs should be returned. Specify null to return all CRLs (if supported). |
| 返回(Returns) | |
|---|---|
Collection<? extends CRL> |
A Collection of CRLs that match the specified selector (never null) |
| 抛出异常(Throws) | |
|---|---|
CertStoreException |
if an exception occurs |
CertStoreParameters getCertStoreParameters ()
返回用于初始化此CertStore的参数。 请注意, CertStoreParameters对象在返回之前被克隆。
| 返回(Returns) | |
|---|---|
CertStoreParameters |
the parameters used to initialize this CertStore (may be null) |
Collection<? extends Certificate> getCertificates (CertSelector selector)
返回与指定选择器匹配的Collection个Certificate 。 如果没有Certificate与选择器匹配,则会返回一个空的Collection 。
对于某些CertStore类型,生成的Collection可能不包含匹配选择器的所有 Certificate 。 例如,LDAP CertStore可能不会搜索目录中的所有条目。 相反,它可能只是搜索可能包含正在查找的Certificate的条目。
一些CertStore实现(特别是LDAP CertStore )可能会抛出CertStoreException除非提供了包含可用于查找证书的特定条件的非空CertSelector 。 发行人和/或主题名称是特别有用的标准。
| 参数(Parameters) | |
|---|---|
selector |
CertSelector: A CertSelector used to select which Certificates should be returned. Specify null to return all Certificates (if supported). |
| 返回(Returns) | |
|---|---|
Collection<? extends Certificate> |
A Collection of Certificates that match the specified selector (never null) |
| 抛出异常(Throws) | |
|---|---|
CertStoreException |
if an exception occurs |
String getDefaultType ()
返回Java安全属性文件中指定的默认CertStore类型,如果不存在此类属性,则返回字符串“LDAP”。 Java安全属性文件位于名为<JAVA_HOME> /lib/security/java.security的文件中。 <JAVA_HOME>引用java.home系统属性的值,并指定安装JRE的目录。
当调用 getInstance方法之一时,不希望使用硬编码类型的应用程序可以使用默认的 CertStore类型,并且希望在用户未指定自己的情况下提供默认的 CertStore类型。
通过将“certstore.type”安全属性(在Java安全属性文件中)的值设置为 CertStore类型,可以更改默认的 CertStore类型。
| 返回(Returns) | |
|---|---|
String |
the default CertStore type as specified in the Java security properties file, or the string "LDAP" if no such property exists. |
CertStore getInstance (String type, CertStoreParameters params)
返回一个 CertStore对象,该对象实现指定的 CertStore类型并使用指定的参数进行初始化。
该方法遍历注册安全提供程序的列表,从最优先的提供程序开始。 返回封装来自支持指定类型的第一个Provider的CertStoreSpi实现的新CertStore对象。
请注意,注册供应商列表可能通过 Security.getProviders()方法检索。
返回的CertStore将使用指定的CertStoreParameters初始化。 所需的参数类型可能因不同类型的CertStore s而异。 请注意,指定的CertStoreParameters对象已被克隆。
| 参数(Parameters) | |
|---|---|
type |
String: the name of the requested CertStore type. See the CertStore section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard types. |
params |
CertStoreParameters: the initialization parameters (may be null). |
| 返回(Returns) | |
|---|---|
CertStore |
a CertStore object that implements the specified CertStore type. |
| 抛出异常(Throws) | |
|---|---|
NoSuchAlgorithmException |
if no Provider supports a CertStoreSpi implementation for the specified type. |
InvalidAlgorithmParameterException |
if the specified initialization parameters are inappropriate for this CertStore. |
也可以看看:
CertStore getInstance (String type, CertStoreParameters params, Provider provider)
返回实现指定的 CertStore类型的 CertStore对象。
返回封装指定Provider对象的CertStoreSpi实现的新CertStore对象。 请注意,指定的Provider对象不必在提供程序列表中注册。
返回的CertStore将使用指定的CertStoreParameters初始化。 所需参数的类型可能因不同类型的CertStore而异。 请注意,指定的CertStoreParameters对象已被克隆。
| 参数(Parameters) | |
|---|---|
type |
String: the requested CertStore type. See the CertStore section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard types. |
params |
CertStoreParameters: the initialization parameters (may be null). |
provider |
Provider: the provider. |
| 返回(Returns) | |
|---|---|
CertStore |
a CertStore object that implements the specified type. |
| 抛出异常(Throws) | |
|---|---|
NoSuchAlgorithmException |
if a CertStoreSpi implementation for the specified type is not available from the specified Provider object. |
InvalidAlgorithmParameterException |
if the specified initialization parameters are inappropriate for this CertStore |
IllegalArgumentException |
if the provider is null. |
也可以看看:
CertStore getInstance (String type, CertStoreParameters params, String provider)
返回实现指定的 CertStore类型的 CertStore对象。
返回封装指定提供程序的CertStoreSpi实现的新CertStore对象。 指定的提供者必须在安全提供者列表中注册。
请注意,注册供应商列表可能通过 Security.getProviders()方法检索。
返回的CertStore将使用指定的CertStoreParameters初始化。 所需的参数类型可能因不同类型的CertStore s而异。 请注意,指定的CertStoreParameters对象已被克隆。
| 参数(Parameters) | |
|---|---|
type |
String: the requested CertStore type. See the CertStore section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard types. |
params |
CertStoreParameters: the initialization parameters (may be null). |
provider |
String: the name of the provider. |
| 返回(Returns) | |
|---|---|
CertStore |
a CertStore object that implements the specified type. |
| 抛出异常(Throws) | |
|---|---|
NoSuchAlgorithmException |
if a CertStoreSpi implementation for the specified type is not available from the specified provider. |
InvalidAlgorithmParameterException |
if the specified initialization parameters are inappropriate for this CertStore. |
NoSuchProviderException |
if the specified provider is not registered in the security provider list. |
IllegalArgumentException |
if the provider is null or empty. |
也可以看看:
Provider getProvider ()
返回此 CertStore的提供者。
| 返回(Returns) | |
|---|---|
Provider |
the provider of this CertStore |
String getType ()
返回这个 CertStore的类型。
| 返回(Returns) | |
|---|---|
String |
the type of this CertStore |