X509CRL x509crl = CertTools.getCRLfromByteArray(crl);
Set<? extends X509CRLEntry> revset = x509crl.getRevokedCertificates();
if (revset != null) {
Iterator<? extends X509CRLEntry> iter = revset.iterator();
while (iter.hasNext()) {
X509CRLEntry ce = iter.next();
assertTrue(ce.getSerialNumber().compareTo(cert.getSerialNumber()) != 0);
}
} // If no revoked certificates exist at all, this test passed...
certificateStoreSession.revokeCertificate(admin, cert, null, RevokedCertInfo.REVOCATION_REASON_CERTIFICATEHOLD, null);
// Sleep 1 second so we don't issue the next CRL at the exact same time
// as the revocation
Thread.sleep(1000);
// Create a new delta CRL again...
crl = crlStoreSession.runDeltaCRL(admin, ca, -1, -1);
// Check that our newly signed certificate IS present in a new Delta CRL
// crl = storeremote.getLastCRL(admin, cadn, true);
assertNotNull("Could not get CRL", crl);
x509crl = CertTools.getCRLfromByteArray(crl);
revset = x509crl.getRevokedCertificates();
assertNotNull("revset can not be null", revset);
Iterator<? extends X509CRLEntry> iter = revset.iterator();
boolean found = false;
while (iter.hasNext()) {
X509CRLEntry ce = iter.next();
if (ce.getSerialNumber().compareTo(cert.getSerialNumber()) == 0) {
found = true;
// TODO: verify the reason code
}
}
assertTrue(found);
// Unrevoke the certificate that we just revoked
certificateStoreSession.revokeCertificate(admin, cert, null, RevokedCertInfo.NOT_REVOKED, null);
// Create a new Delta CRL again...
crlStoreSession.runDeltaCRL(admin, ca, -1, -1);
// Check that our newly signed certificate IS NOT present in the new
// CRL.
crl = createCrlSession.getLastCRL(admin, ca.getSubjectDN(), true);
assertNotNull("Could not get CRL", crl);
x509crl = CertTools.getCRLfromByteArray(crl);
revset = x509crl.getRevokedCertificates();
if (revset != null) {
iter = revset.iterator();
found = false;
while (iter.hasNext()) {
X509CRLEntry ce = (X509CRLEntry) iter.next();
if (ce.getSerialNumber().compareTo(cert.getSerialNumber()) == 0) {
found = true;
}
}
assertFalse(found);
} // If no revoked certificates exist at all, this test passed...
// Check that when we revoke a certificate it will be present on the
// delta CRL
// When we create a new full CRL it will be present there, and not on
// the next delta CRL
certificateStoreSession.revokeCertificate(admin, cert, null, RevokedCertInfo.REVOCATION_REASON_CACOMPROMISE, null);
// Sleep 1 second so we don't issue the next CRL at the exact same time
// as the revocation
Thread.sleep(1000);
// Create a new delta CRL again...
crl = crlStoreSession.runDeltaCRL(admin, ca, -1, -1);
// Check that our newly signed certificate IS present in a new Delta CRL
// crl = storeremote.getLastCRL(admin, cadn, true);
assertNotNull("Could not get CRL", crl);
x509crl = CertTools.getCRLfromByteArray(crl);
revset = x509crl.getRevokedCertificates();
assertNotNull(revset);
iter = revset.iterator();
found = false;
// log.debug(x509crl.getThisUpdate());
while (iter.hasNext()) {
X509CRLEntry ce = (X509CRLEntry) iter.next();
// log.debug(ce);
if (ce.getSerialNumber().compareTo(cert.getSerialNumber()) == 0) {
found = true;
// TODO: verify the reason code
}
}
assertTrue(found);
// Sleep 1 second so we don't issue the next CRL at the exact same time
// as the revocation
Thread.sleep(1000);
// Create a new Full CRL
crlStoreSession.run(admin, ca);
// Check that our newly signed certificate IS present in a new Full CRL
crl = createCrlSession.getLastCRL(admin, ca.getSubjectDN(), false);
assertNotNull("Could not get CRL", crl);
x509crl = CertTools.getCRLfromByteArray(crl);
revset = x509crl.getRevokedCertificates();
assertNotNull(revset);
iter = revset.iterator();
found = false;
// log.debug(x509crl.getThisUpdate());
// log.debug(x509crl.getThisUpdate().getTime());
while (iter.hasNext()) {
X509CRLEntry ce = (X509CRLEntry) iter.next();
// log.debug(ce);
if (ce.getSerialNumber().compareTo(cert.getSerialNumber()) == 0) {
found = true;
// TODO: verify the reason code
}
}
assertTrue(found);
// Sleep 1 second so we don't issue the next CRL at the exact same time
// as the revocation
Thread.sleep(1000);
// Create a new Delta CRL again...
crlStoreSession.runDeltaCRL(admin, ca, -1, -1);
// Check that our newly signed certificate IS NOT present in the new
// Delta CRL.
crl = createCrlSession.getLastCRL(admin, ca.getSubjectDN(), true);
assertNotNull("Could not get CRL", crl);
x509crl = CertTools.getCRLfromByteArray(crl);
revset = x509crl.getRevokedCertificates();
// log.debug(x509crl.getThisUpdate());
if (revset != null) {
iter = revset.iterator();
found = false;
while (iter.hasNext()) {
X509CRLEntry ce = (X509CRLEntry) iter.next();
// log.debug(ce);
// log.debug(ce.getRevocationDate().getTime());
if (ce.getSerialNumber().compareTo(cert.getSerialNumber()) == 0) {
found = true;
}
}
assertFalse(found);
} // If no revoked certificates exist at all, this test passed...