Package org.ejbca.core.model.ra.raadmin

Examples of org.ejbca.core.model.ra.raadmin.EndEntityProfile


    @Override
    public EndEntityProfile getEndEntityProfile(final Admin admin, final String profilename) {
        if (LOG.isTraceEnabled()) {
            LOG.trace(">getEndEntityProfile(" + profilename + ")");
        }
        EndEntityProfile returnval = null;
        if (profilename.equals(EMPTY_ENDENTITYPROFILENAME)) {
            returnval = new EndEntityProfile(true);
        } else {
          final Integer id = profileCache.getNameIdMapCache(entityManager).get(profilename);
          if (id != null) {
            returnval = getEndEntityProfile(admin, id);
          }
View Full Code Here


    @Override
    public EndEntityProfile getEndEntityProfile(final Admin admin, final int id) {
        if (LOG.isTraceEnabled()) {
            LOG.trace(">getEndEntityProfile(" + id + ")");
        }
        EndEntityProfile returnval = null;
        if (id == SecConst.EMPTY_ENDENTITYPROFILE) {
            returnval = new EndEntityProfile(true);
        } else {
        // We need to clone the profile, otherwise the cache contents will be modifyable from the outside
          final EndEntityProfile eep = profileCache.getProfileCache(entityManager).get(Integer.valueOf(id));
        try {
          if (eep != null) {
            returnval = (EndEntityProfile)eep.clone();
          }
        } catch (CloneNotSupportedException e) {
          LOG.error("Should never happen: ", e);
          throw new RuntimeException(e);
        }
View Full Code Here

    public void setUp() throws Exception {
        super.setUp()
        userData = new UserDataVO("userName","CN=userName,O=linagora",-1688117755,"",
            "user@linagora.com",1,3,1,2,0,new ExtendedInformation());
        profile = new EndEntityProfile();
        profile.addField(EndEntityProfile.USERNAME);//0
        profile.addField(EndEntityProfile.PASSWORD);//1
        profile.addField(EndEntityProfile.CLEARTEXTPASSWORD);//2
        profile.addField(EndEntityProfile.KEYRECOVERABLE);//28
        profile.addField(EndEntityProfile.SENDNOTIFICATION);//35
View Full Code Here

        log.debug("userdata.getStatus(): "+userdata.getStatus());
        log.debug("savekeys: "+savekeys);
        boolean loadkeys = (userdata.getStatus() == UserDataConstants.STATUS_KEYRECOVERY) && usekeyrecovery;
        log.debug("loadkeys: "+loadkeys);
        int endEntityProfileId = userdata.getEndEntityProfileId();
        EndEntityProfile endEntityProfile = endEntityProfileSession.getEndEntityProfile(admin, endEntityProfileId);
        boolean reusecertificate = endEntityProfile.getReUseKeyRecoveredCertificate();
        log.debug("reusecertificate: "+reusecertificate);

        try {
          GenerateToken tgen = new GenerateToken(authenticationSession, userAdminSession, caAdminSession, keyRecoverySession, signSession);
          java.security.KeyStore pkcs12 = tgen.generateOrKeyRecoverToken(admin, username, password, caid, keyspec, keyalg, false, loadkeys, savekeys, reusecertificate, endEntityProfileId);
View Full Code Here

    Admin admin = ejbhelper.getAdmin();
    TreeMap<String,Integer> ret = new TreeMap<String,Integer>();
        final IPatternLogger logger = TransactionLogger.getPatternLogger();
        logAdminName(admin,logger);
    try {
      EndEntityProfile profile = endEntityProfileSession.getEndEntityProfile(admin, entityProfileId);
      if (profile != null) {       
        String value = profile.getValue(EndEntityProfile.AVAILCERTPROFILES,0);
        if (value != null) {
          String[] availablecertprofilesId = value.split(EndEntityProfile.SPLITCHAR);       
          for (String id : availablecertprofilesId) {
            int i = Integer.parseInt(id);
            ret.put(certificateProfileSession.getCertificateProfileName(admin,i), i);
View Full Code Here

    Admin admin = ejbhelper.getAdmin();
    TreeMap<String,Integer> ret = new TreeMap<String,Integer>();
        final IPatternLogger logger = TransactionLogger.getPatternLogger();
        logAdminName(admin,logger);
    try {
      EndEntityProfile profile = endEntityProfileSession.getEndEntityProfile(admin, entityProfileId);
      if (profile != null) {
        Collection<String> cas = profile.getAvailableCAs(); // list of CA ids available in profile
        HashMap<Integer,String> map = caAdminSession.getCAIdToNameMap(admin);
        for (String id : cas ) {
          Integer i = Integer.valueOf(id);
          String name = (String)map.get(i);
          if (name != null) {
View Full Code Here

                                        profileid = newprofileid;
                                    }
                                }
                                if (!error) {
                                    CertificateProfile cprofile = null;
                                    EndEntityProfile eprofile = null;
                                    FileInputStream is = new FileInputStream(infiles[i]);
                                    XMLDecoder decoder = new XMLDecoder( is );
                                    if (entityprofile) {
                                        eprofile = new EndEntityProfile();
                                        eprofile.loadData(decoder.readObject());
                                        // Translate cert profile ids that have changed after import
                                        String availableCertProfiles = "";
                                        String defaultCertProfile = eprofile.getValue(EndEntityProfile.DEFAULTCERTPROFILE,0);
                                      //getLogger().debug("Debug: Org - AVAILCERTPROFILES " + eprofile.getValue(EndEntityProfile.AVAILCERTPROFILES,0) + " DEFAULTCERTPROFILE "+defaultCertProfile);
                                        for (String currentCertProfile : (Collection<String>) eprofile.getAvailableCertificateProfileIds()) {
                                          Integer currentCertProfileId = Integer.parseInt(currentCertProfile);
                                          Integer replacementCertProfileId = certificateProfileIdMapping.get(currentCertProfileId);
                                          if ( replacementCertProfileId != null ) {
                                            if (!replacementCertProfileId.toString().equals(currentCertProfile)) {
                                              getLogger().warn("Replacing cert profile with id "+currentCertProfile+" with " + replacementCertProfileId + ".");
                                            }
                                            availableCertProfiles += (availableCertProfiles.equals("") ? "" : ";" ) + replacementCertProfileId;
                                            if (currentCertProfile.equals(defaultCertProfile)) {
                                              defaultCertProfile = ""+replacementCertProfileId;
                                            }
                                          } else {
                                            if (ejb.getCertificateProfileSession().getCertificateProfile(getAdmin(), currentCertProfileId) != null ||
                                                SecConst.isFixedCertificateProfile(currentCertProfileId)) {
                                                availableCertProfiles += (availableCertProfiles.equals("") ? "" : ";" ) + currentCertProfile;
                                             } else {
                                               getLogger().warn("End Entity Profile '"+profilename+"' references certificate profile " + currentCertProfile + " that does not exist.");
                                                if (currentCertProfile.equals(defaultCertProfile)) {
                                                  defaultCertProfile = "";
                                                }
                                             }
                                          }
                                        }
                                        if (availableCertProfiles.equals("")) {
                                          getLogger().warn("End Entity Profile only references certificate profile(s) that does not exist. Using ENDUSER profile.");
                                            availableCertProfiles = "1"; // At least make sure the default profile is available
                                        }
                                        if (defaultCertProfile.equals("")) {
                                          defaultCertProfile = availableCertProfiles.split(";")[0]// Use first available profile from list as default if original default was missing
                                        }
                                        eprofile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, availableCertProfiles);
                                        eprofile.setValue(EndEntityProfile.DEFAULTCERTPROFILE,0, defaultCertProfile);
                                        // Remove any unknown CA and break if none is left
                                        String defaultCA = eprofile.getValue(EndEntityProfile.DEFAULTCA,0);
                                        String availableCAs = eprofile.getValue(EndEntityProfile.AVAILCAS,0);
                                      //getOutputStream().println("Debug: Org - AVAILCAS " + availableCAs + " DEFAULTCA "+defaultCA);
                                        List<String> cas = Arrays.asList(availableCAs.split(";"));
                                        availableCAs = "";
                                        for ( String currentCA : cas ) {
                                          Integer currentCAInt = Integer.parseInt(currentCA);
                                          // The constant ALLCAS will not be searched for among available CAs
                                          if ( (currentCAInt.intValue() != SecConst.ALLCAS) && (ejb.getCAAdminSession().getCAInfo(getAdmin(), currentCAInt) == null) ) {
                                            getLogger().warn("CA with id " + currentCA + " was not found and will not be used in end entity profile '" + profilename + "'.");
                                                if (defaultCA.equals(currentCA)) {
                                                  defaultCA = "";
                                                }
                                          } else {
                                            availableCAs += (availableCAs.equals("") ? "" : ";" ) + currentCA;
                                          }
                                        }
                                        if (availableCAs.equals("")) {
                                          if (caid == null) {
                                            getLogger().error("No CAs left in end entity profile '" + profilename + "' and no CA specified on command line. Using ALLCAs.");
                                            availableCAs = Integer.toString(SecConst.ALLCAS);
                                          } else {
                                            availableCAs = Integer.toString(caid);
                                            getLogger().warn("No CAs left in end entity profile '" + profilename + "'. Using CA supplied on command line with id '"+caid+"'.");
                                          }
                                        }
                                        if (defaultCA.equals("")) {
                                          defaultCA = availableCAs.split(";")[0]// Use first available
                                          getLogger().warn("Changing default CA in end entity profile '" + profilename + "' to "+defaultCA+".");
                                        }
                                      //getLogger().debug("New - AVAILCAS " + availableCAs + " DEFAULTCA "+defaultCA);
                                        eprofile.setValue(EndEntityProfile.AVAILCAS, 0, availableCAs);
                                        eprofile.setValue(EndEntityProfile.DEFAULTCA, 0, defaultCA);
                                        try{                                       
                                            ejb.getEndEntityProfileSession().addEndEntityProfile(getAdmin(),profileid,profilename,eprofile);
                                            getLogger().info("Added entity profile '"+profilename+"' to database.");
                                        }catch(EndEntityProfileExistsException eepee){ 
                                          getLogger().error("Error adding entity profile '"+profilename+"' to database.");
View Full Code Here

     * and therefore this internal method can be called from another non-read-only method, upgradeProfile().
     * @return EndEntityProfile
     * TODO: Still true with JPA?
     */
    private EndEntityProfile readAndUpgradeProfileInternal() {
        EndEntityProfile returnval = new EndEntityProfile(0);
        HashMap data = getData();
        // If EndEntityProfile-data is upgraded we want to save the new data, so we must get the old version before loading the data
        // and perhaps upgrading
        float oldversion = ((Float) data.get(UpgradeableDataHashMap.VERSION)).floatValue();
        // Load the profile data, this will potentially upgrade the CertificateProfile
        returnval.loadData(data);
        if (Float.compare(oldversion, returnval.getVersion()) != 0) {
          // Save new data versions differ
          setProfile(returnval);
          if (log.isDebugEnabled()) {
              log.debug("Saved upgraded profile, old version="+oldversion+", new version="+returnval.getVersion());           
          }
        }
        return returnval;
    }
View Full Code Here

      boolean loadkeys = (userdata.getStatus() == UserDataConstants.STATUS_KEYRECOVERY) && usekeyrecovery;
      if (log.isDebugEnabled()) {
        log.debug("loadkeys: "+loadkeys);
      }
      int endEntityProfileId = userdata.getEndEntityProfileId();
      EndEntityProfile endEntityProfile = endEntityProfileSession.getEndEntityProfile(admin, endEntityProfileId);
      boolean reusecertificate = endEntityProfile.getReUseKeyRecoveredCertificate();
      if (log.isDebugEnabled()) {
        log.debug("reusecertificate: "+reusecertificate);
      }
      // Generate keystore
      String password = userdata.getPassword();
View Full Code Here

        certProfileSession.addCertificateProfile(admin, "CMPTESTPROFILE", profile);
    } catch (CertificateProfileExistsException e) {
      log.error("Could not create certificate profile.", e);
    }
        int cpId = certProfileSession.getCertificateProfileId(admin, "CMPTESTPROFILE");
        EndEntityProfile eep = new EndEntityProfile(true);
        eep.setValue(EndEntityProfile.DEFAULTCERTPROFILE,0, "" + cpId);
        eep.setValue(EndEntityProfile.AVAILCERTPROFILES,0, "" + cpId);
        eep.addField(DnComponents.COMMONNAME);
        eep.addField(DnComponents.ORGANIZATION);
        eep.addField(DnComponents.COUNTRY);
        eep.addField(DnComponents.RFC822NAME);
        eep.addField(DnComponents.UPN);
        eep.setModifyable(DnComponents.RFC822NAME, 0, true);
        eep.setUse(DnComponents.RFC822NAME, 0, false)// Don't use field from "email" data
        try {
          eeProfileSession.addEndEntityProfile(admin, "CMPTESTPROFILE", eep);
    } catch (EndEntityProfileExistsException e) {
      log.error("Could not create end entity profile.", e);
    }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.raadmin.EndEntityProfile

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.