当前位置: 首页>>代码示例>>Java>>正文


Java PKIXParameters.addCertStore方法代码示例

本文整理汇总了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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:PKIXParametersTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:PKIXParametersTest.java

示例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);
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:43,代码来源:NistCertPathTest.java


注:本文中的java.security.cert.PKIXParameters.addCertStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。