logsession.log(admin, caid, LogEntry.MODULE_CA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_CREATECRL,"");
logsession.log(admin, caid, LogEntry.MODULE_CA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_CREATECRL,e.getMessage());
    public void run(Admin admin, String issuerdn) throws RemoteException {        debug(">run()");        int caid = issuerdn.hashCode();        try {                   ICAAdminSessionLocal caadmin = caadminHome.create();            ICertificateStoreSessionLocal store = storeHome.create();                        CAInfo cainfo = caadmin.getCAInfo(admin, issuerdn.hashCode());            int crlperiod = cainfo.getCRLPeriod();            // Find all revoked certificates            Collection revcerts = store.listRevokedCertificates(admin, issuerdn);            debug("Found "+revcerts.size()+" revoked certificates.");            // Go through them and create a CRL, at the same time archive expired certificates            Date now = new Date();            // crlperiod is hours = crlperiod*60*60*1000 milliseconds            now.setTime(now.getTime() - (crlperiod * 60 * 60 * 1000));            Vector certs = new Vector();            Iterator iter = revcerts.iterator();            while (iter.hasNext()) {                CertificateDataPK pk = new CertificateDataPK((String)iter.next());                CertificateDataLocal data = certHome.findByPrimaryKey(pk);                // We want to include certificates that was revoked after the last CRL was issued, but before this one                // so the revoked certs are included in ONE CRL at least.                if ( (data.getStatus() == CertificateData.CERT_REVOKED) &&                    (data.getExpireDate() < now.getTime()) )                {                        data.setStatus(CertificateData.CERT_ARCHIVED);                } else                {                    if (data.getRevocationDate() == -1)                        data.setRevocationDate((new Date()).getTime());                    RevokedCertInfo certinfo = new RevokedCertInfo(new BigInteger(data.getSerialNumber()),new Date(data.getRevocationDate()), data.getRevocationReason());                    certs.add(certinfo);                }            }            ISignSessionLocal sign = signHome.create();            X509CRL crl = (X509CRL) sign.createCRL(admin, caid, certs);            //FileOutputStream fos = new FileOutputStream("srvtestcrl.der");            //fos.write(crl.getEncoded());            //fos.close();        } catch (Exception e) {                        logsession.log(admin, caid, LogEntry.MODULE_CA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_CREATECRL,"");                            throw new EJBException(e);        }        debug("<run()");    }