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


Java X509CertSelector.setKeyUsage方法代碼示例

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


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

示例1: test_getKeyUsage

import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
 * @tests java.security.cert.X509CertSelector#getKeyUsage()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getKeyUsage",
    args = {}
)
public void test_getKeyUsage() {
    boolean[] ku = new boolean[] { true, false, true, false, true, false,
            true, false, true };
    X509CertSelector selector = new X509CertSelector();

    assertNull("Selector should return null", selector.getKeyUsage());
    selector.setKeyUsage(ku);
    assertTrue("The returned date should be equal to specified", Arrays
            .equals(ku, selector.getKeyUsage()));
    boolean[] result = selector.getKeyUsage();
    result[0] = !result[0];
    assertTrue("The returned keyUsage should be equal to specified", Arrays
            .equals(ku, selector.getKeyUsage()));
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:24,代碼來源:X509CertSelectorTest.java

示例2: testKeyUsage

import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
private void testKeyUsage() {
    System.out.println("X.509 Certificate Match on keyUsage");
    // bad match
    X509CertSelector selector = new X509CertSelector();
    boolean[] keyUsage = { true, false, true, false, true, false, true, false };
    selector.setKeyUsage(keyUsage);
    System.out.println("Selector = " + selector.toString());
    checkMatch(selector, cert, false);

    // good match
    selector.setKeyUsage(cert.getKeyUsage());
    System.out.println("Selector = " + selector.toString());
    checkMatch(selector, cert, true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:X509CertSelectorTest.java

示例3: test_setKeyUsageZ

import java.security.cert.X509CertSelector; //導入方法依賴的package包/類
/**
 * @tests java.security.cert.X509CertSelector#setKeyUsage(boolean)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setKeyUsage",
    args = {boolean[].class}
)
public void test_setKeyUsageZ() throws CertificateException {
    boolean[] ku1 = new boolean[] { true, true, true, true, true, true,
            true, true, true };
    // decipherOnly is disallowed
    boolean[] ku2 = new boolean[] { true, true, true, true, true, true,
            true, true, false };
    TestCert cert1 = new TestCert(ku1);
    TestCert cert2 = new TestCert(ku2);
    TestCert cert3 = new TestCert((boolean[]) null);

    X509CertSelector selector = new X509CertSelector();

    selector.setKeyUsage(null);
    assertTrue("Any certificate should match in the case of null "
            + "keyUsage criteria.", selector.match(cert1)
            && selector.match(cert2));
    selector.setKeyUsage(ku1);
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert1));
    assertFalse("The certificate should not match the selection criteria.",
            selector.match(cert2));
    assertTrue("The certificate which does not have a keyUsage extension "
            + "implicitly allows all keyUsage values.", selector
            .match(cert3));
    selector.setKeyUsage(ku2);
    ku2[0] = !ku2[0];
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert2));
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:39,代碼來源:X509CertSelectorTest.java


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