use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class TrustAnchorTest method testGetCAPublicKey01.
/**
* Test #1 for <code>getCAPublicKey()</code> method<br>
*
* Assertion: returns most trusted CA public key</code><br>
* Test preconditions: valid name passed to the constructor<br>
* Expected: the same name must be returned by the method<br>
*
*/
public final void testGetCAPublicKey01() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
// sub testcase 1
TrustAnchor ta = new TrustAnchor(validCaNameRfc2253, pk, null);
assertEquals("equals1", pk, ta.getCAPublicKey());
// sub testcase 2
X500Principal x500p = new X500Principal(validCaNameRfc2253);
ta = new TrustAnchor(x500p, pk, null);
assertEquals("equals2", pk, ta.getCAPublicKey());
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class TrustAnchorTest method testTrustAnchorX500PrincipalPublicKeybyteArray04.
/**
* Test #4 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>
* Assertion: <code>NullPointerException</code> if <code>caPrincipal</code>
* or <code>caPublicKey</code> parameter is <code>null</code><br>
* Test preconditions: pass <code>null</code> as mentioned parameter<br>
* Expected: NullPointerException
* @throws InvalidKeySpecException
*/
public final void testTrustAnchorX500PrincipalPublicKeybyteArray04() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
X500Principal x500p = new X500Principal(validCaNameRfc2253);
// sub testcase 1
try {
new TrustAnchor((X500Principal) null, pk, getEncodingPSOnly());
fail("NullPointerException has not been thrown");
} catch (NullPointerException ok) {
}
// sub testcase 2
try {
new TrustAnchor(x500p, null, getEncodingPSOnly());
fail("NullPointerException has not been thrown");
} catch (NullPointerException ok) {
}
// sub testcase 3
try {
new TrustAnchor((X500Principal) null, null, getEncodingPSOnly());
fail("NullPointerException has not been thrown");
} catch (NullPointerException ok) {
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CertSelectorTest method test_setIssuerLjava_lang_String.
/**
* java.security.cert.X509CertSelector#setIssuer(java.lang.String)
*/
public void test_setIssuerLjava_lang_String() throws Exception {
String name1 = "O=First Org.";
String name2 = "O=Second Org.";
X500Principal iss1 = new X500Principal(name1);
X500Principal iss2 = new X500Principal(name2);
TestCert cert1 = new TestCert(iss1);
TestCert cert2 = new TestCert(iss2);
X509CertSelector selector = new X509CertSelector();
selector.setIssuer((String) null);
assertTrue("Any certificates should match " + "in the case of null issuer criteria.", selector.match(cert1) && selector.match(cert2));
selector.setIssuer(name1);
assertTrue("The certificate should match the selection criteria.", selector.match(cert1));
assertFalse("The certificate should not match the selection criteria.", selector.match(cert2));
selector.setIssuer(name2);
assertTrue("The certificate should match the selection criteria.", selector.match(cert2));
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CertSelectorTest method test_setIssuerLB$.
/**
* java.security.cert.X509CertSelector#setIssuer(byte[])
*/
public void test_setIssuerLB$() throws Exception {
byte[] name1 = new byte[] // manually obtained DER encoding of "O=First Org." issuer name;
{ 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 70, 105, 114, 115, 116, 32, 79, 114, 103, 46 };
byte[] name2 = new byte[] // manually obtained DER encoding of "O=Second Org." issuer name;
{ 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46 };
X500Principal iss1 = new X500Principal(name1);
X500Principal iss2 = new X500Principal(name2);
TestCert cert1 = new TestCert(iss1);
TestCert cert2 = new TestCert(iss2);
X509CertSelector selector = new X509CertSelector();
selector.setIssuer((byte[]) null);
assertTrue("Any certificates should match " + "in the case of null issuer criteria.", selector.match(cert1) && selector.match(cert2));
selector.setIssuer(name1);
assertTrue("The certificate should match the selection criteria.", selector.match(cert1));
assertFalse("The certificate should not match the selection criteria.", selector.match(cert2));
selector.setIssuer(name2);
assertTrue("The certificate should match the selection criteria.", selector.match(cert2));
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CertSelectorTest method test_getSubjectAsString.
/**
* java.security.cert.X509CertSelector#getSubjectAsString()
*/
public void test_getSubjectAsString() {
String name1 = "O=First Org.";
String name2 = "O=Second Org.";
X500Principal sub1 = new X500Principal(name1);
X500Principal sub2 = new X500Principal(name2);
X509CertSelector selector = new X509CertSelector();
assertNull("Selector should return null", selector.getSubjectAsString());
selector.setSubject(sub1);
assertEquals("The returned subject should be equal to specified", name1, selector.getSubjectAsString());
assertFalse("The returned subject should differ", name2.equals(selector.getSubjectAsString()));
selector.setSubject(sub2);
assertEquals("The returned subject should be equal to specified", name2, selector.getSubjectAsString());
}
Aggregations