data1 = home.create(pk.toString(), password, dn, caid);
data1 = home.create(pk.toString(), newpassword, dn, caid);
    public void addUser(Admin admin, String username, String password, String subjectdn, String subjectaltname, String email, boolean clearpwd, int endentityprofileid, int certificateprofileid,                        int type, int tokentype, int hardwaretokenissuerid, int caid)                         throws AuthorizationDeniedException, UserDoesntFullfillEndEntityProfile {        // String used in SQL so strip it        String dn = CertTools.stringToBCDNString(StringTools.strip(subjectdn));        debug(">addUser("+username+", password, "+dn+", "+email+")");        if(getGlobalConfiguration(admin).getEnableEndEntityProfileLimitations()){          // Check if user fulfills it's profile.          EndEntityProfile profile = raadminsession.getEndEntityProfile(admin,endentityprofileid);          try{            profile.doesUserFullfillEndEntityProfile(username, password, dn, subjectaltname, email, certificateprofileid, clearpwd,                                                    (type & SecConst.USER_ADMINISTRATOR) != 0, (type & SecConst.USER_KEYRECOVERABLE) != 0, (type & SecConst.USER_SENDNOTIFICATION) != 0,                                                    tokentype, hardwaretokenissuerid, caid);          }catch( UserDoesntFullfillEndEntityProfile udfp){            logsession.log(admin, caid, LogEntry.MODULE_RA,  new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"Userdata didn'nt fullfill end entity profile. " + udfp.getMessage() );            throw new UserDoesntFullfillEndEntityProfile(udfp.getMessage());          }            // Check if administrator is authorized to add user.            if(!authorizedToEndEntityProfile(admin, endentityprofileid, AvailableAccessRules.CREATE_RIGHTS)){              logsession.log(admin, caid, LogEntry.MODULE_RA,  new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"Administrator not authorized.");              throw new AuthorizationDeniedException("Administrator not authorized to create user.");            }                     }        // Check if administrator is authorized to add user to CA.        if(!authorizedToCA(admin, caid)){          logsession.log(admin, caid, LogEntry.MODULE_RA,  new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"Administrator not authorized to add user to CA.");          throw new AuthorizationDeniedException("Administrator not authorized to create user with given CA.");        }                         try{            UserDataPK pk = new UserDataPK(username);            UserDataLocal data1=null;            data1 = home.create(pk.toString(), password, dn, caid);            if(subjectaltname != null )                data1.setSubjectAltName(subjectaltname);            if(email != null)                data1.setSubjectEmail(email);            data1.setType(type);            data1.setEndEntityProfileId(endentityprofileid);            data1.setCertificateProfileId(certificateprofileid);            data1.setTokenType(tokentype);            data1.setHardTokenIssuerId(hardwaretokenissuerid);            if(clearpwd){              try {                if (password == null){                  data1.setClearPassword("");                }                else{                  data1.setOpenPassword(password);                }              } catch (java.security.NoSuchAlgorithmException nsae)              {                debug("NoSuchAlgorithmException while setting password for user "+username);                throw new EJBException(nsae);              }            }            if((type & SecConst.USER_SENDNOTIFICATION) != 0)              sendNotification(admin, username, password, dn, subjectaltname, email, caid);            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_INFO_ADDEDENDENTITY,"");        }catch (Exception e) {            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"");            error("AddUser:",e);            throw new EJBException(e);        }        debug("<addUser("+username+", password, "+dn+", "+email+")");    } // addUser