use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class TrustAnchorTest method testGetCA01.
/**
* Test #1 for <code>getCA()</code> method<br>
*
* Assertion: returns most trusted CA<br>
* Test preconditions: valid CA or CA name passed to the constructor<br>
* Expected: the same CA ot the CA with the same name must be returned
* by the method<br>
* @throws InvalidKeySpecException
*/
public final void testGetCA01() throws Exception {
PublicKey pk = new TestKeyPair(keyAlg).getPublic();
// sub testcase 1
TrustAnchor ta = new TrustAnchor(validCaNameRfc2253, pk, null);
X500Principal ca = ta.getCA();
assertEquals("equals1", validCaNameRfc2253, ca.getName());
// sub testcase 2
X500Principal x500p = new X500Principal(validCaNameRfc2253);
ta = new TrustAnchor(x500p, pk, null);
assertEquals("equals2", x500p, ta.getCA());
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CRLSelector2Test method testAddIssuerNameLjava_lang_String03.
/**
* addIssuerName(String name) method testing. Tests if CRLs with specified
* issuers match the selector, and if not specified issuer does not match
* the selector.
*/
public void testAddIssuerNameLjava_lang_String03() {
X509CRLSelector selector = new X509CRLSelector();
String iss1 = "O=First Org.";
String iss2 = "O=Second Org.";
TestCRL crl1 = new TestCRL(new X500Principal(iss1));
TestCRL crl2 = new TestCRL(new X500Principal(iss2));
try {
selector.addIssuerName(iss1);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("The CRL should match the selection criteria.", selector.match(crl1));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl2));
try {
selector.addIssuerName(iss2);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("The CRL should match the selection criteria.", selector.match(crl2));
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CRLSelector2Test method testAddIssuerName$B.
/**
* addIssuerName(byte[] name) method testing. Tests if CRLs with specified
* issuers match the selector, and if not specified issuer does not match
* the selector.
*/
public void testAddIssuerName$B() {
X509CRLSelector selector = new X509CRLSelector();
byte[] iss1 = 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[] iss2 = 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 };
TestCRL crl1 = new TestCRL(new X500Principal(iss1));
TestCRL crl2 = new TestCRL(new X500Principal(iss2));
try {
selector.addIssuerName(iss1);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("The CRL should match the selection criteria.", selector.match(crl1));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl2));
try {
selector.addIssuerName(iss2);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("The CRL should match the selection criteria.", selector.match(crl2));
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CRLSelector2Test method testClone.
/**
* clone() method testing. Tests if the selector is cloned correctly: the
* crl which matche to the initial selector should match to the clone and
* the change of clone should not cause the change of initial selector.
*/
@AndroidOnly("Uses specific classes: " + "org.apache.harmony.security.asn1.ASN1OctetString, " + "org.apache.harmony.security.asn1.ASN1Integer.")
public void testClone() {
X509CRLSelector selector = new X509CRLSelector();
X500Principal iss1 = new X500Principal("O=First Org.");
X500Principal iss2 = new X500Principal("O=Second Org.");
X500Principal iss3 = new X500Principal("O=Third Org.");
BigInteger minCRL = new BigInteger("10000");
BigInteger maxCRL = new BigInteger("10000");
Date date = new Date(200);
selector.addIssuer(iss1);
selector.addIssuer(iss2);
selector.setMinCRLNumber(minCRL);
selector.setMaxCRLNumber(maxCRL);
selector.setDateAndTime(date);
X509CRLSelector clone = (X509CRLSelector) selector.clone();
TestCRL crl = new TestCRL(iss1);
crl.setCrlNumber(minCRL);
crl.setUpdateDates(new Date(200), new Date(200));
assertTrue("The specified CRL should match the clone selector.", selector.match(crl));
clone.addIssuer(iss3);
assertFalse("The changes of the clone selector should not cause " + "the changes of initial object", selector.getIssuerNames().size() == 3);
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CRLTest method testGetIssuerX500Principal.
/**
* java.security.cert.X509CRL#getIssuerX500Principal()
*/
public void testGetIssuerX500Principal() {
// return valid encoding
TBTCRL crl = new TBTCRL() {
public byte[] getEncoded() {
return TestUtils.getX509CRL_v1();
}
};
assertEquals(new X500Principal("CN=Z"), crl.getIssuerX500Principal());
}
Aggregations