if((type & SecConst.USER_SENDNOTIFICATION) != 0) { NotificationCreator  notificationcreator = new NotificationCreator(profile.getNotificationSender(), profile.getNotificationSubject(), profile.getNotificationMessage()); sendNotification(admin, notificationcreator, username, newpassword, dn, subjectaltname, email, caid);
if ((type & SecConst.USER_SENDNOTIFICATION) != 0) { sendNotification(admin, profile, username, newpassword, dn, subjectaltname, email, 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, DuplicateKeyException {        // String used in SQL so strip it        String dn = CertTools.stringToBCDNString(subjectdn);        dn = StringTools.strip(dn);        String newpassword = password;        debug(">addUser("+username+", password, "+dn+", "+email+")");        EndEntityProfile profile = raadminsession.getEndEntityProfile(admin,endentityprofileid);		if(profile.useAutoGeneratedPasswd() && password == null){			// special case used to signal regeneraton of password			newpassword = profile.getAutoGeneratedPasswd();		}        if(getGlobalConfiguration(admin).getEnableEndEntityProfileLimitations()){          // Check if user fulfills it's profile.          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 did not 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{            UserDataLocal data1 = home.create(username, newpassword, 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 (newpassword == null){                  data1.setClearPassword("");                }                else{                  data1.setOpenPassword(newpassword);                }              } catch (java.security.NoSuchAlgorithmException nsae)              {                debug("NoSuchAlgorithmException while setting password for user "+username);                throw new EJBException(nsae);              }            }            if((type & SecConst.USER_SENDNOTIFICATION) != 0) {                 NotificationCreator  notificationcreator = new NotificationCreator(profile.getNotificationSender(),        		                                                                                                    profile.getNotificationSubject(),                                                                                                                    profile.getNotificationMessage());                sendNotification(admin, notificationcreator, username, newpassword, dn, subjectaltname, email, caid);            }            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_INFO_ADDEDENDENTITY,"");        } catch (DuplicateKeyException e) {            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"Entity already exists.");            throw e;        } catch (Exception e) {            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,e.getMessage());            error("AddUser:",e);            throw new EJBException(e);        }        debug("<addUser("+username+", password, "+dn+", "+email+")");    } // addUser