當前位置: 首頁>>代碼示例>>Java>>正文


Java PKIXParameters.setTrustAnchors方法代碼示例

本文整理匯總了Java中java.security.cert.PKIXParameters.setTrustAnchors方法的典型用法代碼示例。如果您正苦於以下問題:Java PKIXParameters.setTrustAnchors方法的具體用法?Java PKIXParameters.setTrustAnchors怎麽用?Java PKIXParameters.setTrustAnchors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.cert.PKIXParameters的用法示例。


在下文中一共展示了PKIXParameters.setTrustAnchors方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSetTrustAnchors04

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test #4 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>ClassCastException</code> -
 * if any of the elements in the set are not of type
 * <code>java.security.cert.TrustAnchor</code>
 * @throws InvalidAlgorithmParameterException
 */
public final void testSetTrustAnchors04() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    PKIXParameters p = new PKIXParameters(taSet);
    Set s = new HashSet(p.getTrustAnchors());
    s.add(new Object());
    try {
        p.setTrustAnchors(s);
        fail("ClassCastException expected");
    } catch (ClassCastException e) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:PKIXParametersTest.java

示例2: testSetTrustAnchors05

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test #5 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>Set</code> is copied to protect against
 * subsequent modifications
 * @throws InvalidAlgorithmParameterException
 * @throws KeyStoreException
 */
public final void testSetTrustAnchors05() throws Exception {
    // use several trusted certs in this test
    KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
    if (ks == null) {
        fail(getName() + ": not performed (could not create test KeyStore)");
    }

    PKIXParameters p = new PKIXParameters(ks);
    // prepare new Set
    HashSet newSet = new HashSet(p.getTrustAnchors());
    HashSet newSetCopy = (HashSet)newSet.clone();
    // set new Set
    p.setTrustAnchors(newSetCopy);
    // modify set - remove one element
    assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
    // check that set maintained internally has
    // not been changed by the above modification
    assertEquals("isCopied", newSet, p.getTrustAnchors());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:PKIXParameters_ImplTest.java

示例3: testSetTrustAnchors01

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test #1 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: Sets the <code>Set</code> of most-trusted CAs 
 * @throws InvalidAlgorithmParameterException
 */
public final void testSetTrustAnchors01() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    Set taSet1 = TestUtils.getTrustAnchorSet();
    PKIXParameters p = new PKIXParameters(taSet);
    p.setTrustAnchors(taSet1);
    assertFalse(p.getTrustAnchors().isEmpty());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:PKIXParametersTest.java

示例4: testSetTrustAnchors02

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test #2 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>InvalidAlgorithmParameterException</code> -
 * if the specified <code>Set</code> is empty
 * (<code>trustAnchors.isEmpty() == true</code>)
 * @throws InvalidAlgorithmParameterException
 */
public final void testSetTrustAnchors02() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    PKIXParameters p = new PKIXParameters(taSet);
    try {
        // use empty set
        p.setTrustAnchors(new HashSet());
        fail("InvalidAlgorithmParameterException expected");
    } catch (InvalidAlgorithmParameterException e) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:PKIXParametersTest.java

示例5: testSetTrustAnchors03

import java.security.cert.PKIXParameters; //導入方法依賴的package包/類
/**
 * Test #3 for <code>setTrustAnchors(Set)</code> method<br>
 * Assertion: <code>NullPointerException</code> -
 * if the specified <code>Set</code> is <code>null</code>)
 */
public final void testSetTrustAnchors03() throws Exception {
    Set taSet = TestUtils.getTrustAnchorSet();
    if (taSet == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor set)");
    }

    PKIXParameters p = new PKIXParameters(taSet);
    try {
        // use null
        p.setTrustAnchors(null);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:PKIXParametersTest.java


注:本文中的java.security.cert.PKIXParameters.setTrustAnchors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。