use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_setSubjectKeyIdentifierLB$.
/**
* java.security.cert.X509CertSelector#setSubjectKeyIdentifier(byte[])
*/
public void test_setSubjectKeyIdentifierLB$() throws Exception {
// random value
byte[] skid1 = new byte[] { 1, 2, 3, 4, 5 };
// random value
byte[] skid2 = new byte[] { 5, 4, 3, 2, 1 };
TestCert cert1 = new TestCert(skid1);
TestCert cert2 = new TestCert(skid2);
X509CertSelector selector = new X509CertSelector();
selector.setSubjectKeyIdentifier(null);
assertTrue("Any certificate should match in the case of null " + "serialNumber criteria.", selector.match(cert1) && selector.match(cert2));
selector.setSubjectKeyIdentifier(skid1);
assertTrue("The certificate should match the selection criteria.", selector.match(cert1));
assertFalse("The certificate should not match the selection criteria.", selector.match(cert2));
selector.setSubjectKeyIdentifier(skid2);
skid2[0]++;
assertTrue("The certificate should match the selection criteria.", selector.match(cert2));
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_addPathToNameLintLbyte_array.
/**
* java.security.cert.X509CertSelector#addPathToName(int, byte[])
*/
public void test_addPathToNameLintLbyte_array() throws IOException {
// Regression for HARMONY-2487
int[] types = { GeneralName.OTHER_NAME, GeneralName.RFC822_NAME, GeneralName.DNS_NAME, GeneralName.X400_ADDR, GeneralName.DIR_NAME, GeneralName.EDIP_NAME, GeneralName.UR_ID, GeneralName.IP_ADDR, GeneralName.REG_ID };
for (int i = 0; i < types.length; i++) {
try {
new X509CertSelector().addPathToName(types[i], (byte[]) null);
fail("No expected NullPointerException for type: " + types[i]);
} catch (NullPointerException expected) {
}
}
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_setPrivateKeyValidLjava_util_Date.
/**
* java.security.cert.X509CertSelector#setPrivateKeyValid(java.util.Date)
*/
public void test_setPrivateKeyValidLjava_util_Date() throws Exception {
Date date1 = new Date(100000000);
Date date2 = new Date(200000000);
Date date3 = new Date(300000000);
Date date4 = new Date(150000000);
Date date5 = new Date(250000000);
TestCert cert1 = new TestCert(date1, date2);
TestCert cert2 = new TestCert(date2, date3);
X509CertSelector selector = new X509CertSelector();
selector.setPrivateKeyValid(null);
assertTrue("Any certificate should match in the case of null " + "privateKeyValid criteria.", selector.match(cert1) && selector.match(cert2));
selector.setPrivateKeyValid(date4);
assertTrue("The certificate should match the selection criteria.", selector.match(cert1));
assertFalse("The certificate should not match the selection criteria.", selector.match(cert2));
selector.setPrivateKeyValid(date5);
date5.setTime(date4.getTime());
assertTrue("The certificate should match the selection criteria.", selector.match(cert2));
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_setKeyUsageZ.
/**
* java.security.cert.X509CertSelector#setKeyUsage(boolean)
*/
public void test_setKeyUsageZ() throws Exception {
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));
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_addSubjectAlternativeNameLintLjava_lang_String.
/**
* java.security.cert.X509CertSelector#addSubjectAlternativeName(int, String)
*/
public void test_addSubjectAlternativeNameLintLjava_lang_String() {
// Regression for HARMONY-727
int[] types = { GeneralName.OTHER_NAME, // GeneralName.RFC822_NAME,
GeneralName.DNS_NAME, GeneralName.X400_ADDR, GeneralName.DIR_NAME, GeneralName.EDIP_NAME, GeneralName.UR_ID, GeneralName.IP_ADDR, GeneralName.REG_ID };
for (int i = 0; i < types.length; i++) {
try {
new X509CertSelector().addSubjectAlternativeName(types[i], "-0xDFRF");
fail("IOException expected for type: " + types[i]);
} catch (IOException expected) {
}
}
}
Aggregations