if(!profileauthproxy.getEndEntityProfileAuthorization(admin, endentityprofileid,EndEntityProfileAuthorizationProxy.CREATE_RIGHTS)){
if(!profileauthproxy.getEndEntityProfileAuthorization(admin, endentityprofileid,EndEntityProfileAuthorizationProxy.CREATE_RIGHTS, LogEntry.MODULE_RA)){
    public void addUser(Admin admin, String username, String password, String dn, String subjectaltname, String email, boolean clearpwd, int endentityprofileid, int certificateprofileid,                          boolean administrator, boolean keyrecoverable, int tokentype, int hardwaretokenissuerid)                         throws AuthorizationDeniedException, UserDoesntFullfillEndEntityProfile, RemoteException {        debug(">addUser("+username+", password, "+dn+", "+email+")");        if(globalconfiguration.getEnableEndEntityProfileLimitations()){          // Check if user fulfills it's profile.          EndEntityProfile profile = raadminsession.getEndEntityProfile(admin,endentityprofileid);          try{            profile.doesUserFullfillEndEntityProfile(username, password, dn, subjectaltname, email, certificateprofileid, clearpwd,                                                     administrator, keyrecoverable, tokentype, hardwaretokenissuerid);          }catch( UserDoesntFullfillEndEntityProfile udfp){             logsession.log(admin, 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(!profileauthproxy.getEndEntityProfileAuthorization(admin, endentityprofileid,EndEntityProfileAuthorizationProxy.CREATE_RIGHTS)){              logsession.log(admin, 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.");              }          }                   try{            UserDataPK pk = new UserDataPK(username);            UserDataLocal data1=null;            data1 = home.create(username, password, dn);            if(subjectaltname != null )                data1.setSubjectAltName(subjectaltname);                         if(email != null)                data1.setSubjectEmail(email);                        data1.setType(makeType(administrator, keyrecoverable));            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);              }            }            logsession.log(admin, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_INFO_ADDEDENDENTITY,"");         }catch (Exception e) {            logsession.log(admin, LogEntry.MODULE_RA, new java.util.Date(),username, null, LogEntry.EVENT_ERROR_ADDEDENDENTITY,"");             throw new EJBException(e.getMessage());        }        debug("<addUser("+username+", password, "+dn+", "+email+")");    } // addUser