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