if ( (ca.getStatus() != SecConst.CA_ACTIVE) && (ca.getStatus() != SecConst.CA_WAITING_CERTIFICATE_RESPONSE) ) {
String msg = intres.getLocalizedMessage("signsession.canotactive", ca.getSubjectDN());
logSession.log(admin, ca.getCAId(), LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CREATECERTIFICATE, msg);
throw new CATokenOfflineException(msg);
}
final X509CRL crl;
final String certSubjectDN = CertTools.getSubjectDN(ca.getCACertificate());
int fullnumber = crlSession.getLastCRLNumber(admin, certSubjectDN, false);
int deltanumber = crlSession.getLastCRLNumber(admin, certSubjectDN, true);
// nextCrlNumber: The highest number of last CRL (full or delta) and increased by 1 (both full CRLs and deltaCRLs share the same series of CRL Number)
int nextCrlNumber = ( (fullnumber > deltanumber) ? fullnumber : deltanumber ) +1;
boolean deltaCRL = (basecrlnumber > -1);
if (deltaCRL) {
// Workaround if transaction handling fails so that crlNumber for deltaCRL would happen to be the same
if (nextCrlNumber == basecrlnumber) {
nextCrlNumber++;
}
crl = (X509CRL) ca.generateDeltaCRL(certs, nextCrlNumber, basecrlnumber);
} else {
crl = (X509CRL) ca.generateCRL(certs, nextCrlNumber);
}
if (crl != null) {
String msg = intres.getLocalizedMessage("signsession.createdcrl", Integer.valueOf(nextCrlNumber), ca.getName(), ca.getSubjectDN());
logSession.log(admin, ca.getCAId(), LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_INFO_CREATECRL, msg);
// Store CRL in the database
String fingerprint = CertTools.getFingerprintAsString(ca.getCACertificate());
crlBytes = crl.getEncoded();
if (log.isDebugEnabled()) {
log.debug("Storing CRL in certificate store.");
}
crlSession.storeCRL(admin, crlBytes, fingerprint, nextCrlNumber, crl.getIssuerDN().getName(), crl.getThisUpdate(), crl.getNextUpdate(), (deltaCRL ? 1 : -1));
// Store crl in ca CRL publishers.
log.debug("Storing CRL in publishers");
this.publisherSession.storeCRL(admin, ca.getCRLPublishers(), crlBytes, fingerprint, nextCrlNumber, ca.getSubjectDN());
}
} catch (CATokenOfflineException ctoe) {