// create selfsigned certificate
Certificate cacertificate = null;
log.debug("CAAdminSessionBean : " + cainfo.getSubjectDN());
UserDataVO cadata = new UserDataVO("nobody", cainfo.getSubjectDN(), cainfo.getSubjectDN().hashCode(), caAltName, null, 0, 0, 0, cainfo
.getCertificateProfileId(), null, null, 0, 0, null);
cacertificate = ca.generateCertificate(cadata, catoken.getPublicKey(SecConst.CAKEYPURPOSE_CERTSIGN), -1, cainfo.getValidity(), certprofile,
sequence);
log.debug("CAAdminSessionBean : " + CertTools.getSubjectDN(cacertificate));
// Build Certificate Chain
certificatechain = new ArrayList<Certificate>();
certificatechain.add(cacertificate);
// set status to active
castatus = SecConst.CA_ACTIVE;
} catch (CATokenOfflineException e) {
String msg = intres.getLocalizedMessage("error.catokenoffline", cainfo.getName());
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CACREATED, msg, e);
throw e;
} catch (Exception fe) {
String msg = intres.getLocalizedMessage("caadmin.errorcreateca", cainfo.getName());
logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_CACREATED, msg, fe);
throw new EJBException(fe);
}
}
if (cainfo.getSignedBy() == CAInfo.SIGNEDBYEXTERNALCA) {
certificatechain = new ArrayList<Certificate>();
// set status to waiting certificate response.
castatus = SecConst.CA_WAITING_CERTIFICATE_RESPONSE;
}
if (cainfo.getSignedBy() > CAInfo.SPECIALCAIDBORDER || cainfo.getSignedBy() < 0) {
// Create CA signed by other internal CA.
try {
CAData signcadata = CAData.findByIdOrThrow(entityManager, Integer.valueOf(cainfo.getSignedBy()));
CA signca = signcadata.getCA();
// Check that the signer is valid
checkSignerValidity(admin, signcadata);
// Create CA certificate
Certificate cacertificate = null;
UserDataVO cadata = new UserDataVO("nobody", cainfo.getSubjectDN(), cainfo.getSubjectDN().hashCode(), caAltName, null, 0, 0, 0, cainfo
.getCertificateProfileId(), null, null, 0, 0, null);
cacertificate = signca.generateCertificate(cadata, catoken.getPublicKey(SecConst.CAKEYPURPOSE_CERTSIGN), -1, cainfo.getValidity(), certprofile,
sequence);