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


Java X509CertSelector.setAuthorityKeyIdentifier方法代码示例

本文整理汇总了Java中java.security.cert.X509CertSelector.setAuthorityKeyIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertSelector.setAuthorityKeyIdentifier方法的具体用法?Java X509CertSelector.setAuthorityKeyIdentifier怎么用?Java X509CertSelector.setAuthorityKeyIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.X509CertSelector的用法示例。


在下文中一共展示了X509CertSelector.setAuthorityKeyIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_getAuthorityKeyIdentifier

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#getAuthorityKeyIdentifier()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getAuthorityKeyIdentifier",
    args = {}
)
public void test_getAuthorityKeyIdentifier() {
    byte[] akid1 = new byte[] { 4, 5, 1, 2, 3, 4, 5 }; // random value
    byte[] akid2 = new byte[] { 4, 5, 5, 4, 3, 2, 1 }; // random value
    X509CertSelector selector = new X509CertSelector();

    assertNull("Selector should return null", selector
            .getAuthorityKeyIdentifier());
    selector.setAuthorityKeyIdentifier(akid1);
    assertTrue("The returned keyID should be equal to specified", Arrays
            .equals(akid1, selector.getAuthorityKeyIdentifier()));
    assertTrue("The returned keyID should be equal to specified", Arrays
            .equals(akid1, selector.getAuthorityKeyIdentifier()));
    assertFalse("The returned keyID should differ", Arrays.equals(akid2,
            selector.getAuthorityKeyIdentifier()));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:X509CertSelectorTest.java

示例2: testAuthorityKeyIdentifier

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
private void testAuthorityKeyIdentifier() throws IOException {
    System.out.println("X.509 Certificate Match on authorityKeyIdentifier");
    // bad match
    X509CertSelector selector = new X509CertSelector();
    byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    AuthorityKeyIdentifierExtension a = new AuthorityKeyIdentifierExtension(new KeyIdentifier(b), null, null);
    selector.setAuthorityKeyIdentifier(a.getExtensionValue());
    checkMatch(selector, cert, false);

    // good match
    DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.35"));
    byte[] encoded = in.getOctetString();
    selector.setAuthorityKeyIdentifier(encoded);
    checkMatch(selector, cert, true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:X509CertSelectorTest.java

示例3: X509CertSelector

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#setAuthorityKeyIdentifier(byte[])
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setAuthorityKeyIdentifier",
    args = {byte[].class}
)
public void test_setAuthorityKeyIdentifierLB$() throws CertificateException {
    X509CertSelector selector = new X509CertSelector();

    byte[] akid1 = new byte[] { 1, 2, 3, 4, 5 }; // random value
    byte[] akid2 = new byte[] { 5, 4, 3, 2, 1 }; // random value
    TestCert cert1 = new TestCert(akid1);
    TestCert cert2 = new TestCert(akid2);

    selector.setAuthorityKeyIdentifier(null);
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert1));
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert2));
    assertNull(selector.getAuthorityKeyIdentifier());

    selector.setAuthorityKeyIdentifier(akid1);
    assertTrue("The certificate should not match the selection criteria.",
            selector.match(cert1));
    assertFalse("The certificate should not match the selection criteria.",
            selector.match(cert2));
    selector.setAuthorityKeyIdentifier(akid2);
    assertFalse("The certificate should not match the selection criteria.",
            selector.match(cert1));
    assertTrue("The certificate should not match the selection criteria.",
            selector.match(cert2));

    akid2[0]++;
    assertTrue("The certificate should match the selection criteria.",
            selector.match(cert2));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:40,代码来源:X509CertSelectorTest.java


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