use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_getIssuerAsString.
/**
* java.security.cert.X509CertSelector#getIssuerAsString()
*/
public void test_getIssuerAsString() {
String name1 = "O=First Org.";
String name2 = "O=Second Org.";
X500Principal iss1 = new X500Principal(name1);
X500Principal iss2 = new X500Principal(name2);
X509CertSelector selector = new X509CertSelector();
assertNull("Selector should return null", selector.getIssuerAsString());
selector.setIssuer(iss1);
assertEquals("The returned issuer should be equal to specified", name1, selector.getIssuerAsString());
assertFalse("The returned issuer should differ", name2.equals(selector.getIssuerAsString()));
selector.setIssuer(iss2);
assertEquals("The returned issuer should be equal to specified", name2, selector.getIssuerAsString());
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_getPrivateKeyValid.
/**
* java.security.cert.X509CertSelector#getPrivateKeyValid()
*/
public void test_getPrivateKeyValid() {
Date date1 = new Date(100);
Date date2 = new Date(200);
X509CertSelector selector = new X509CertSelector();
assertNull("Selector should return null", selector.getPrivateKeyValid());
selector.setPrivateKeyValid(date1);
assertTrue("The returned date should be equal to specified", date1.equals(selector.getPrivateKeyValid()));
selector.getPrivateKeyValid().setTime(200);
assertTrue("The returned date should be equal to specified", date1.equals(selector.getPrivateKeyValid()));
assertFalse("The returned date should differ", date2.equals(selector.getPrivateKeyValid()));
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_getBasicConstraints.
/**
* java.security.cert.X509CertSelector#getBasicConstraints()
*/
public void test_getBasicConstraints() {
X509CertSelector selector = new X509CertSelector();
int[] validValues = { 2, 1, 0, 1, 2, 3, 10, 20 };
for (int i = 0; i < validValues.length; i++) {
selector.setBasicConstraints(validValues[i]);
assertEquals(validValues[i], selector.getBasicConstraints());
}
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_getSubjectPublicKey.
/**
* java.security.cert.X509CertSelector#getSubjectPublicKey()
*/
public void test_getSubjectPublicKey() throws Exception {
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
byte[] enc = { // SEQUENCE
0x30, // SEQUENCE
0x0E, // SEQUENCE
0x30, // SEQUENCE
0x07, // OID
0x06, // OID
0x02, // OID
0x03, // OID
0x05, // ANY
0x01, // ANY
0x01, // ANY
0x07, // subjectPublicKey
0x03, // subjectPublicKey
0x03, // subjectPublicKey
0x01, // subjectPublicKey
0x01, // subjectPublicKey
0x06 };
X509CertSelector selector = new X509CertSelector();
selector.setSubjectPublicKey(enc);
PublicKey key = selector.getSubjectPublicKey();
assertEquals("0.3.5", key.getAlgorithm());
assertEquals("X.509", key.getFormat());
assertTrue(Arrays.equals(enc, key.getEncoded()));
assertNotNull(key.toString());
key = new MyPublicKey();
selector.setSubjectPublicKey(key);
PublicKey keyActual = selector.getSubjectPublicKey();
assertEquals(key, keyActual);
assertEquals(key.getAlgorithm(), keyActual.getAlgorithm());
}
use of java.security.cert.X509CertSelector in project robovm by robovm.
the class X509CertSelectorTest method test_setCertificateLjava_security_cert_X509Certificate.
/**
* java.security.cert.X509CertSelector#setCertificate(java.security.cert.Certificate)
*/
public void test_setCertificateLjava_security_cert_X509Certificate() throws Exception {
TestCert cert1 = new TestCert("same certificate");
TestCert cert2 = new TestCert("other certificate");
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(null);
assertTrue("Any certificates should match in the case of null " + "certificateEquals criteria.", selector.match(cert1) && selector.match(cert2));
selector.setCertificate(cert1);
assertTrue("The certificate should match the selection criteria.", selector.match(cert1));
assertFalse("The certificate should not match the selection criteria.", selector.match(cert2));
selector.setCertificate(cert2);
assertTrue("The certificate should match the selection criteria.", selector.match(cert2));
selector.setCertificate(null);
assertNull(selector.getCertificate());
}
Aggregations