当前位置: 首页>>代码示例>>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;未经允许,请勿转载。