Package org.ejbca.core.model.ca.certificateprofiles

Examples of org.ejbca.core.model.ca.certificateprofiles.CertificateProfileExistsException


            throws CertificateProfileExistsException {
        if (isCertificateProfileNameFixed(profilename)) {
            final String msg = INTRES.getLocalizedMessage("store.errorcertprofilefixed", profilename);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_ERROR_CERTPROFILE,
                    msg);
            throw new CertificateProfileExistsException(msg);
        }

        if (isFreeCertificateProfileId(profileid)) {
            if (CertificateProfileData.findByProfileName(entityManager, profilename) == null) {
                try {
                    entityManager.persist(new CertificateProfileData(Integer.valueOf(profileid), profilename, profile));
                    flushProfileCache();
                    final String msg = INTRES.getLocalizedMessage("store.addedcertprofile", profilename);
                    logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null,
                            LogConstants.EVENT_INFO_CERTPROFILE, msg);
                } catch (Exception e) {
                    final String msg = INTRES.getLocalizedMessage("store.errorcreatecertprofile", profilename);
                    logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null,
                            LogConstants.EVENT_ERROR_CERTPROFILE, msg);
                }
            } else {
              final String msg = INTRES.getLocalizedMessage("store.errorcertprofileexists", profilename);
                throw new CertificateProfileExistsException(msg);
            }
        }
    }
View Full Code Here


        CertificateProfile profile = null;
        if (isCertificateProfileNameFixed(newprofilename)) {
            final String msg = INTRES.getLocalizedMessage("store.errorcertprofilefixed", newprofilename);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_ERROR_CERTPROFILE,
                    msg);
            throw new CertificateProfileExistsException(msg);
        }
        try {
            profile = (CertificateProfile) getCertificateProfile(admin, orgprofilename).clone();
            boolean issuperadmin = false;
            issuperadmin = authSession.isAuthorizedNoLog(admin, "/super_administrator");
            if (!issuperadmin && profile.isApplicableToAnyCA()) {
                // Not superadministrator, do not use ANYCA;
                profile.setAvailableCAs(authorizedCaIds);
            }
            if (CertificateProfileData.findByProfileName(entityManager, newprofilename) == null) {
                entityManager.persist(new CertificateProfileData(findFreeCertificateProfileId(), newprofilename, profile));
                flushProfileCache();
                final String msg = INTRES.getLocalizedMessage("store.addedprofilewithtempl", newprofilename, orgprofilename);
                logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_INFO_CERTPROFILE, msg);
            } else {
                final String msg = INTRES.getLocalizedMessage("store.erroraddprofilewithtempl", newprofilename, orgprofilename);
                logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null,
                        LogConstants.EVENT_ERROR_CERTPROFILE, msg);
                throw new CertificateProfileExistsException();
            }
        } catch (CloneNotSupportedException f) {
            throw new EJBException(f); // If this happens it's a programming error. Throw an exception!
        }
    }
View Full Code Here

            throws CertificateProfileExistsException {
        if (isCertificateProfileNameFixed(newprofilename)) {
            final String msg = INTRES.getLocalizedMessage("store.errorcertprofilefixed", newprofilename);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_ERROR_CERTPROFILE,
                    msg);
            throw new CertificateProfileExistsException(msg);
        }
        if (isCertificateProfileNameFixed(oldprofilename)) {
            final String msg = INTRES.getLocalizedMessage("store.errorcertprofilefixed", oldprofilename);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_ERROR_CERTPROFILE,
                    msg);
            throw new CertificateProfileExistsException(msg);
        }
        if (CertificateProfileData.findByProfileName(entityManager, newprofilename) == null) {
            final CertificateProfileData pdl = CertificateProfileData.findByProfileName(entityManager, oldprofilename);
            if (pdl == null) {
                final String msg = INTRES.getLocalizedMessage("store.errorrenameprofile", oldprofilename, newprofilename);
                logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null,
                        LogConstants.EVENT_ERROR_CERTPROFILE, msg);
            } else {
                pdl.setCertificateProfileName(newprofilename);
                flushProfileCache();
                final String msg = INTRES.getLocalizedMessage("store.renamedprofile", oldprofilename, newprofilename);
                logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_INFO_CERTPROFILE, msg);
            }
        } else {
            final String msg = INTRES.getLocalizedMessage("store.errorcertprofileexists", newprofilename);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_CA, new Date(), null, null, LogConstants.EVENT_ERROR_CERTPROFILE, msg);
            throw new CertificateProfileExistsException();
        }
    }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.certificateprofiles.CertificateProfileExistsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.