public class CertStore extends Object
Certificate s和CRL s的类。
这个类使用基于提供者的架构。 要创建一个CertStore ,请调用静态getInstance方法之一,传递所需的类型为CertStore ,任何适用的初始化参数和可选的所需提供商的名称。
一旦CertStore已经创建,它可以被用来获取Certificate S和CRL通过调用以S getCertificates种getCRLs方法。
不像KeyStore ,它提供了访问私钥和可信证书的高速缓存, CertStore旨在提供访问不受信任的证书和CRL的潜在的巨大的资源库。 例如,一个LDAP实现CertStore可以访问存储在使用LDAP协议和如在RFC服务属性中定义的模式的一个或多个目录证书和CRL。
Java平台的每个实现都需要支持以下标准CertStore类型:
Collection 并发访问
CertStore对象的所有公共方法必须是线程安全的。 也就是说,多个线程可以在没有不良影响的单个CertStore对象(或多个)上同时调用这些方法。 例如,这允许CertPathBuilder搜索CRL,同时搜索其他证书。
该类的静态方法也保证线程安全。 多个线程可以同时调用此类中定义的静态方法,而不会产生不良影响。
| Modifier | Constructor and Description |
|---|---|
protected |
CertStore(CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params)
创建给定类型的
CertStore对象,并封装给定的提供者实现(SPI对象)。
|
| Modifier and Type | Method and Description |
|---|---|
Collection<? extends Certificate> |
getCertificates(CertSelector selector)
返回
Collection的
Certificate指定选择器匹配秒。
|
CertStoreParameters |
getCertStoreParameters()
返回用于初始化
CertStore 。
|
Collection<? extends CRL> |
getCRLs(CRLSelector selector)
返回
Collection的
CRL指定选择器匹配秒。
|
static String |
getDefaultType()
返回由
certstore.type安全属性指定的默认
CertStore类型,如果不存在此属性,则返回字符串“LDAP”。
|
static CertStore |
getInstance(String type, CertStoreParameters params)
返回一个
CertStore对象实现指定
CertStore类型和与指定的参数进行初始化。
|
static CertStore |
getInstance(String type, CertStoreParameters params, Provider provider)
返回一个
CertStore指定的
CertStore类型的
CertStore对象。
|
static CertStore |
getInstance(String type, CertStoreParameters params, String provider)
返回实现指定的
CertStore类型的
CertStore对象。
|
Provider |
getProvider()
返回此
CertStore的提供者。
|
String |
getType()
返回此类型
CertStore 。
|
protected CertStore(CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params)
CertStore对象,并将给定的提供者实现(SPI对象)封装在其中。
storeSpi - 提供者实现
provider - 提供商
type - 类型
params - 初始化参数(可能为
null )
public final Collection<? extends Certificate> getCertificates(CertSelector selector) throws CertStoreException
Collection的Certificate指定选择器匹配秒。
如果没有Certificate匹配选择器,将返回一个空的Collection 。
对于一些CertStore类型,结果Collection可能不包含与选择器匹配的所有 Certificate 。 例如,LDAP CertStore可能不会搜索目录中的所有条目。 相反,它可能只是搜索可能包含它正在寻找的Certificate的条目。
一些CertStore实现(特别是LDAP CertStore多个)可能抛出CertStoreException除非一个非空CertSelector被提供,其包括可用于查找证书的具体标准。 发行人和/或主题名称是特别有用的标准。
selector - A CertSelector用于选择哪些Certificate应该返回。
指定null以返回所有Certificate s(如果支持)。
Collection的
Certificate指定选择器匹配的S(从未
null )
CertStoreException - 如果发生异常
public final Collection<? extends CRL> getCRLs(CRLSelector selector) throws CertStoreException
Collection的CRL指定选择器匹配秒。
如果没有CRL匹配选择器,将返回一个空的Collection 。
对于一些CertStore类型,结果Collection可能不包含与选择器匹配的所有 CRL 。 例如,LDAP CertStore可能不会搜索目录中的所有条目。 相反,它可能只是搜索可能包含它正在寻找的CRL的条目。
一些CertStore实现(特别是LDAP CertStore )可以抛出CertStoreException ,除非提供了包括可用于查找CRL的特定标准的非空CRLSelector 。 发行人名称和/或要检查的证书特别有用。
selector - A CRLSelector用于选择应该返回哪个CRL 。
指定null返回全部CRL s(如果支持)。
Collection的
CRL s匹配指定的选择器(从不
null )
CertStoreException - 如果发生异常
public static CertStore getInstance(String type, CertStoreParameters params) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException
CertStore对象实现指定CertStore类型和与指定的参数进行初始化。
此方法遍历已注册的安全提供程序列表,从最优选的提供程序开始。 返回从支持指定类型的第一个Provider中封装CertStoreSpi实现的新CertStore对象。
请注意,可以通过Security.getProviders()方法检索已注册提供商的列表。
该CertStore返回的初始化与指定的CertStoreParameters 。 所需参数的类型可能因不同类型的CertStore而异。 请注意,指定的CertStoreParameters对象被克隆。
type - type的名称CertStore类型。
看到的的CertStore部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准类型的信息。
params - 初始化参数(可能为
null )。
CertStore对象实现了指定的
CertStore类型。
NoSuchAlgorithmException - 如果没有提供者支持指定类型的CertStoreSpi实现。
InvalidAlgorithmParameterException - 如果指定的初始化参数不适用于此
CertStore 。
Provider
public static CertStore getInstance(String type, CertStoreParameters params, String provider) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException
CertStore类型的CertStore对象。
返回从指定提供程序封装CertStoreSpi实现的新CertStore对象。 指定的提供者必须在安全提供程序列表中注册。
请注意,注册提供商的列表可以通过Security.getProviders()方法检索 。
该CertStore返回的初始化与指定的CertStoreParameters 。 所需的参数类型可能因不同类型的CertStore而异。 请注意,指定的CertStoreParameters对象被克隆。
type - 请求的CertStore类型。
看到的的CertStore部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准类型的信息。
params - 初始化参数(可能为
null )。
provider - 提供者的名称。
CertStore指定类型的
CertStore对象。
NoSuchAlgorithmException - 如果指定类型的CertStoreSpi实现不可用于指定的提供程序。
InvalidAlgorithmParameterException - 如果指定的初始化参数不适合此
CertStore 。
NoSuchProviderException - 如果指定的提供程序未在安全提供程序列表中注册。
IllegalArgumentException - 如果
provider为空或为空。
Provider
public static CertStore getInstance(String type, CertStoreParameters params, Provider provider) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
CertStore指定的CertStore类型的CertStore对象。
返回从指定的Provider对象封装CertStoreSpi实现的新CertStore对象。 请注意,指定的Provider对象不必在提供者列表中注册。
该CertStore返回的初始化与指定的CertStoreParameters 。 所需的参数类型可能因不同类型的CertStore而异。 请注意,指定的CertStoreParameters对象被克隆。
type - 请求的CertStore类型。
看到的的CertStore部分Java Cryptography Architecture Standard Algorithm Name Documentation有关标准类型的信息。
params - 初始化参数(可能为
null )。
provider - 提供商。
CertStore指定类型的
CertStore对象。
NoSuchAlgorithmException - 如果指定类型的CertStoreSpi实现从指定的Provider对象中不可用。
InvalidAlgorithmParameterException - 如果指定的初始化参数不适用于此
CertStore
IllegalArgumentException - 如果
provider为空。
Provider
public final CertStoreParameters getCertStoreParameters()
CertStore 。
请注意, CertStoreParameters对象在返回之前被克隆。
CertStore (可能是
null )
public final String getType()
CertStore 。
CertStore
public final Provider getProvider()
CertStore的提供者。
CertStore的提供者
public static final String getDefaultType()
certstore.type安全属性指定的默认CertStore类型,如果没有此类属性,则返回字符串“LDAP”。
当调用getInstance方法之一时,默认的CertStore类型可以被不想使用硬编码类型的getInstance程序使用,并且要提供默认的CertStore类型,以防用户没有指定自己的类型。
通过将certstore.type安全属性的值设置为CertStore类型,可以更改默认值CertStore类型。
CertStore类型由
certstore.type安全属性,或字符串“LDAP”,如果没有这样的属性存在。
security properties
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.