當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。