本文整理汇总了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()));
}
示例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);
}
示例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));
}