use of java.security.cert.CRL in project robovm by robovm.
the class X509CRLSelector2Test method testSetMinCRLNumberLjava_math_BigInteger.
/**
* setMinCRLNumber(BigInteger minCRL) method testing. Tests if CRLs with any
* crl number value match the selector in the case of null crlNumber
* criteria, if specified minCRL 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 testSetMinCRLNumberLjava_math_BigInteger() {
X509CRLSelector selector = new X509CRLSelector();
BigInteger minCRL = new BigInteger("10000");
CRL crl = new TestCRL(minCRL);
selector.setMinCRLNumber(null);
assertTrue("Any CRL should match in the case of null minCRLNumber.", selector.match(crl));
selector.setMinCRLNumber(minCRL);
assertTrue("The CRL should match the selection criteria.", selector.match(crl));
selector.setMinCRLNumber(new BigInteger("10001"));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl));
}
use of java.security.cert.CRL in project robovm by robovm.
the class X509CRLSelector2Test method testAddIssuerLjavax_security_auth_x500_X500Principal02.
/**
* addIssuer(X500Principal issuer) method testing. Tests if CRLs with
* specified issuers match the selector, and if not specified issuer does
* not match the selector.
*/
public void testAddIssuerLjavax_security_auth_x500_X500Principal02() {
X509CRLSelector selector = new X509CRLSelector();
X500Principal iss1 = new X500Principal("O=First Org.");
X500Principal iss2 = new X500Principal("O=Second Org.");
CRL crl1 = new TestCRL(iss1);
CRL crl2 = new TestCRL(iss2);
selector.addIssuer(iss1);
assertTrue("The CRL should match the selection criteria.", selector.match(crl1));
assertFalse("The CRL should not match the selection criteria.", selector.match(crl2));
selector.addIssuer(iss2);
assertTrue("The CRL should match the selection criteria.", selector.match(crl2));
}
use of java.security.cert.CRL in project robovm by robovm.
the class X509CRLTest method getType.
private void getType(CertificateFactory f) throws Exception {
CRL crlRsa = getCRL(f, CRL_RSA);
assertEquals("X.509", crlRsa.getType());
}
use of java.security.cert.CRL in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory11.
/*
* Test for <code> generateCertificate(InputStream inStream) </code><code>
* generateCertificates(InputStream inStream) </code><code>
* generateCRL(InputStream inStream) </code><code>
* generateCRLs(InputStream inStream) </code>
* methods
* Assertion: throw CertificateException and CRLException when inStream
* contains incompatible datas
*/
public void testCertificateFactory11() throws IOException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate mc = createMC();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(mc);
oos.flush();
oos.close();
Certificate cer;
Collection<?> colCer;
CRL crl;
Collection<?> colCrl;
byte[] arr = os.toByteArray();
ByteArrayInputStream is;
for (int i = 0; i < certFs.length; i++) {
is = new ByteArrayInputStream(arr);
try {
cer = certFs[i].generateCertificate(is);
assertNull("Not null certificate was created", cer);
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCer = certFs[i].generateCertificates(is);
if (colCer != null) {
assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
}
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
crl = certFs[i].generateCRL(is);
assertNull("Not null CRL was created", crl);
} catch (CRLException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCrl = certFs[i].generateCRLs(is);
if (colCrl != null) {
assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
}
} catch (CRLException e) {
}
}
}
use of java.security.cert.CRL in project robovm by robovm.
the class CertificateFactory4Test method test_generateCRLLjava_io_InputStream.
/**
* java.security.cert.CertificateFactory#generateCRL(java.io.InputStream)
*/
public void test_generateCRLLjava_io_InputStream() throws Exception {
CertificateFactory fact = CertificateFactory.getInstance("X.509");
for (int i = 0; i < CRL_URLS.length; i++) {
URL certUrl = new URL(BASE_URL + CRL_URLS[i]);
try {
InputStream is = certUrl.openStream();
CRL crl = fact.generateCRL(is);
assertNotNull("The CRL in \"" + certUrl.toExternalForm() + "\" were not parsed correctly", crl);
} catch (IOException e) {
// the certificate could not be found, skip it
} catch (CRLException e) {
fail("An exception was thrown while parsing \"" + certUrl.toExternalForm() + "\": " + e.getMessage());
}
}
}
Aggregations