"Imported CA",
description,
    public void upgradeFromOldCAKeyStore(Admin admin, String caname, byte[] p12file, char[] keystorepass,                                         char[] privkeypass, String privatekeyalias){        try{            // check authorization            if(admin.getAdminType() !=  Admin.TYPE_CACOMMANDLINE_USER)              getAuthorizationSession().isAuthorizedNoLog(admin,"/super_administrator");            // load keystore            java.security.KeyStore keystore=KeyStore.getInstance("PKCS12", "BC");            keystore.load(new java.io.ByteArrayInputStream(p12file),keystorepass);            Certificate[] certchain = KeyTools.getCertChain(keystore, privatekeyalias);            if (certchain.length < 1) {                log.error("Cannot load certificate chain with alias "+privatekeyalias);                throw new Exception("Cannot load certificate chain with alias "+privatekeyalias);            }            ArrayList certificatechain = new ArrayList();            for(int i=0;i< certchain.length;i++){                certificatechain.add(certchain[i]);            }            X509Certificate cacertificate = (X509Certificate) certchain[0];            PrivateKey p12privatekey = (PrivateKey) keystore.getKey( privatekeyalias, privkeypass);            PublicKey p12publickey = cacertificate.getPublicKey();            CAToken catoken = new SoftCAToken();            ((SoftCAToken) catoken).importKeysFromP12(p12privatekey, p12publickey);            // Create a X509CA            int signedby = CAInfo.SELFSIGNED;            int certprof = SecConst.CERTPROFILE_FIXED_ROOTCA;            if(certchain.length > 1){                signedby = CAInfo.SIGNEDBYEXTERNALCA;                certprof = SecConst.CERTPROFILE_FIXED_SUBCA;            }            // Create and active OSCP CA Service.            ArrayList extendedcaservices = new ArrayList();			extendedcaservices.add(			  new OCSPCAServiceInfo(ExtendedCAServiceInfo.STATUS_ACTIVE,			                        "CN=OCSPSignerCertificate, " + cacertificate.getSubjectDN().toString(),			                        "",			                        2048,			                        OCSPCAServiceInfo.KEYALGORITHM_RSA));			int validity = (int)((cacertificate.getNotAfter().getTime() - cacertificate.getNotBefore().getTime()) / (24*3600*1000));            X509CAInfo cainfo = new X509CAInfo(cacertificate.getSubjectDN().toString(),                                               caname, SecConst.CA_ACTIVE,                                               "", certprof,                                               validity,                                               cacertificate.getNotAfter(), // Expiretime                                               CAInfo.CATYPE_X509,                                               signedby,                                               certificatechain,                                               catoken.getCATokenInfo(),                                               "Imported CA",                                               -1, null, // revokationreason, revokationdate                                               "", // PolicyId                                               24, // CRLPeriod                                               new ArrayList(),                                               true, // Authority Key Identifier                                               false, // Authority Key Identifier Critical                                               true, // CRL Number                                               false, // CRL Number Critical                                               true, // Finish User			                                   extendedcaservices);            X509CA ca = new X509CA(cainfo);            ca.setCAToken(catoken);            ca.setCertificateChain(certificatechain);            // Store CA in database.            cadatahome.create(cainfo.getSubjectDN(), cainfo.getName(), SecConst.CA_ACTIVE, ca);            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_INFO_CACREATED,"CA imported successfully from old P12 file, status: " + ca.getStatus());        }catch(Exception e){            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_ERROR_CACREATED,"An error occured when trying to import CA from old P12 file", e);            throw new EJBException(e);        }    } // upgradeFromOldCAKeyStore