use of java.security.cert.X509CRLSelector in project robovm by robovm.
the class X509CRLSelector2Test method testSetMaxCRLNumberLjava_math_BigInteger.
/**
* setMaxCRLNumber(BigInteger maxCRL) method testing. Tests if CRLs with any
* crl number value match the selector in the case of null crlNumber
* criteria, if specified maxCRL value matches the selector, and if CRL with
* inappropriate crlNumber value does not match the selector.
*/
@AndroidOnly("Uses specific class: " + "org.apache.harmony.security.asn1.ASN1OctetString.")
public void testSetMaxCRLNumberLjava_math_BigInteger() {
X509CRLSelector selector = new X509CRLSelector();
BigInteger maxCRL = new BigInteger("10000");
TestCRL crl = new TestCRL(maxCRL);
selector.setMaxCRLNumber(null);
assertTrue("Any CRL should match in the case of null minCRLNumber.", selector.match(crl));
selector.setMaxCRLNumber(maxCRL);
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
selector.setMaxCRLNumber(new BigInteger("9999"));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl));
}
use of java.security.cert.X509CRLSelector in project robovm by robovm.
the class X509CRLSelector2Test method testSetDateAndTimeLjava_util_Date.
/**
* setDateAndTime(Date dateAndTime) method testing. Tests if CRLs with any
* update dates match the selector in the case of null dateAndTime criteria,
* if correct dates match and incorrect do not match the selector.
*/
public void testSetDateAndTimeLjava_util_Date() {
X509CRLSelector selector = new X509CRLSelector();
TestCRL crl = new TestCRL(new Date(200), new Date(300));
selector.setDateAndTime(null);
assertTrue("Any CRL should match in the case of null dateAndTime.", selector.match(crl));
selector.setDateAndTime(new Date(200));
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
selector.setDateAndTime(new Date(250));
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
selector.setDateAndTime(new Date(300));
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
selector.setDateAndTime(new Date(150));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl));
selector.setDateAndTime(new Date(350));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl));
}
use of java.security.cert.X509CRLSelector in project robovm by robovm.
the class X509CRLSelector2Test method testSetIssuerNamesLjava_util_Collection02.
/**
* setIssuerNames(Collection <?> names) method testing. Tests if CRLs with
* any issuers match the selector in the case of null issuerNames criteria,
* if specified issuers match the selector, if not specified issuer does not
* match the selector, and if the internal collection of issuer names is
* copied during initialization.
*/
@SuppressWarnings("unchecked")
public void testSetIssuerNamesLjava_util_Collection02() {
X509CRLSelector selector = new X509CRLSelector();
String iss1 = "O=First Org.";
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 };
String iss3 = "O=Third Org.";
TestCRL crl1 = new TestCRL(new X500Principal(iss1));
TestCRL crl2 = new TestCRL(new X500Principal(iss2));
TestCRL crl3 = new TestCRL(new X500Principal(iss3));
try {
selector.setIssuerNames(null);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("Any CRL issuers should match in the case of null issuers.", selector.match(crl1) && selector.match(crl2));
ArrayList issuers = new ArrayList(2);
issuers.add(iss1);
issuers.add(iss2);
try {
selector.setIssuerNames(issuers);
} catch (IOException e) {
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
assertTrue("The CRL should match the selection criteria.", selector.match(crl1) && selector.match(crl2));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl3));
issuers.add(iss3);
assertFalse("The internal issuer collection is not protected " + "against the modifications.", selector.match(crl3));
}
use of java.security.cert.X509CRLSelector in project robovm by robovm.
the class X509CRLSelector2Test method testSetCertificateCheckingLjava_X509Certificate.
/**
* setCertificateChecking(X509Certificate) method testing.
*/
public void testSetCertificateCheckingLjava_X509Certificate() throws CertificateException {
X509CRLSelector selector = new X509CRLSelector();
CertificateFactory certFact = CertificateFactory.getInstance("X509");
X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(TestUtils.getX509Certificate_v3()));
TestCRL crl = new TestCRL();
selector.setCertificateChecking(cert);
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
assertEquals(cert, selector.getCertificateChecking());
selector.setCertificateChecking(null);
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
assertNull(selector.getCertificateChecking());
}
use of java.security.cert.X509CRLSelector in project robovm by robovm.
the class X509CRLSelector2Test method testGetDateAndTime.
/**
* getDateAndTime() method testing. Tests if the method return null in the
* case of not specified dateAndTime criteria, and if the returned value
* corresponds to the specified one.
*/
public void testGetDateAndTime() {
X509CRLSelector selector = new X509CRLSelector();
assertNull("Initially the dateAndTime criteria should be null.", selector.getDateAndTime());
Date date = new Date(200);
selector.setDateAndTime(date);
assertTrue("The result should be equal to specified.", date.equals(selector.getDateAndTime()));
}
Aggregations