本文整理汇总了Java中java.security.cert.PKIXParameters.addCertStore方法的典型用法代码示例。如果您正苦于以下问题:Java PKIXParameters.addCertStore方法的具体用法?Java PKIXParameters.addCertStore怎么用?Java PKIXParameters.addCertStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.cert.PKIXParameters
的用法示例。
在下文中一共展示了PKIXParameters.addCertStore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddCertStore01
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #1 for <code>addCertStore(CertStore)</code> method<br>
* Assertion: adds a <code>CertStore</code> to the end of the
* list of <code>CertStores</code>
* @throws InvalidAlgorithmParameterException
* @throws NoSuchAlgorithmException
*/
public final void testAddCertStore01() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
p.addCertStore(CertStore.getInstance("Collection",
new CollectionCertStoreParameters()));
assertFalse(p.getCertStores().isEmpty());
}
示例2: testAddCertStore02
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
/**
* Test #2 for <code>addCertStore(CertStore)</code> method<br>
* Assertion: if <code>null</code>, the store is ignored (not added to list)
* @throws InvalidAlgorithmParameterException
*/
public final void testAddCertStore02() throws Exception {
Set taSet = TestUtils.getTrustAnchorSet();
if (taSet == null) {
fail(getName() + ": not performed (could not create test TrustAnchor set)");
}
PKIXParameters p = new PKIXParameters(taSet);
p.addCertStore(null);
assertTrue(p.getCertStores().isEmpty());
}
示例3: doTest
import java.security.cert.PKIXParameters; //导入方法依赖的package包/类
private PKIXCertPathValidatorResult doTest(
String trustAnchor,
String[] certs,
String[] crls,
Set policies)
throws Exception
{
Set trustedSet = Collections.singleton(getTrustAnchor(trustAnchor));
List certsAndCrls = new ArrayList();
X509Certificate endCert = loadCert(certs[certs.length - 1]);
for (int i = 0; i != certs.length - 1; i++)
{
certsAndCrls.add(loadCert(certs[i]));
}
certsAndCrls.add(endCert);
CertPath certPath = CertificateFactory.getInstance("X.509","BC").generateCertPath(certsAndCrls);
for (int i = 0; i != crls.length; i++)
{
certsAndCrls.add(loadCrl(crls[i]));
}
CertStore store = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certsAndCrls), "BC");
CertPathValidator validator = CertPathValidator.getInstance("PKIX","BC");
PKIXParameters params = new PKIXParameters(trustedSet);
params.addCertStore(store);
params.setRevocationEnabled(true);
params.setDate(new GregorianCalendar(2010, 1, 1).getTime());
if (policies != null)
{
params.setExplicitPolicyRequired(true);
params.setInitialPolicies(policies);
}
return (PKIXCertPathValidatorResult)validator.validate(certPath, params);
}