List list = new ArrayList();
list.add(rootCert);
list.add(interCert);
list.add(finalCert);
CollectionCertStoreParameters ccsp = new CollectionCertStoreParameters(list);
CertStore store = CertStore.getInstance("Collection", ccsp, "BC");
Iterator certs = store.getCertificates(null).iterator();
if (!certs.next().equals(rootCert))
{
fail("root ordering wrong");
}
if (!certs.next().equals(interCert))
{
fail("mid ordering wrong");
}
if (!certs.next().equals(finalCert))
{
fail("final ordering wrong");
}
list = new ArrayList();
list.add(finalCert);
list.add(interCert);
list.add(rootCert);
ccsp = new CollectionCertStoreParameters(list);
store = CertStore.getInstance("Collection", ccsp, "BC");
certs = store.getCertificates(null).iterator();
if (!certs.next().equals(finalCert))
{
fail("reverse final ordering wrong");
}
if (!certs.next().equals(interCert))
{
fail("reverse mid ordering wrong");
}
if (!certs.next().equals(rootCert))
{
fail("reverse root ordering wrong");
}
X509CRL rootCrl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(
CertPathTest.rootCrlBin));
X509CRL interCrl = (X509CRL)cf
.generateCRL(new ByteArrayInputStream(
CertPathTest.interCrlBin));
list = new ArrayList();
list.add(finalCert);
list.add(rootCrl);
list.add(interCrl);
ccsp = new CollectionCertStoreParameters(list);
store = CertStore.getInstance("Collection", ccsp, "BC");
Iterator crls = store.getCRLs(null).iterator();
if (!crls.next().equals(rootCrl))
{
fail("root crl ordering wrong");
}
if (!crls.next().equals(interCrl))
{
fail("mid crl ordering wrong");
}
list = new ArrayList();
list.add(finalCert);
list.add(interCrl);
list.add(rootCrl);
ccsp = new CollectionCertStoreParameters(list);
store = CertStore.getInstance("Collection", ccsp, "BC");
crls = store.getCRLs(null).iterator();
if (!crls.next().equals(interCrl))
{
fail("reverse mid crl ordering wrong");
}