Search in sources :

Example 6 with AuthoritiesBean

use of org.akaza.openclinica.domain.user.AuthoritiesBean in project OpenClinica by OpenClinica.

the class AccountController method buildUserAccount.

private UserAccountBean buildUserAccount(String studyOid, String studySubjectOid, String fName, String lName, String mobile, String accessCode, UserAccountBean ownerUserAccount, String pUserName, String email) throws Exception {
    UserAccountBean createdUserAccountBean = new UserAccountBean();
    createdUserAccountBean.setName(pUserName);
    createdUserAccountBean.setFirstName(fName);
    createdUserAccountBean.setLastName(lName);
    createdUserAccountBean.setEmail(INPUT_EMAIL);
    createdUserAccountBean.setInstitutionalAffiliation(INPUT_INSTITUTION);
    createdUserAccountBean.setLastVisitDate(null);
    createdUserAccountBean.setActiveStudyId(getStudy(studyOid).getId());
    createdUserAccountBean.setPasswdTimestamp(null);
    createdUserAccountBean.setPasswdChallengeQuestion("");
    createdUserAccountBean.setPasswdChallengeAnswer("");
    createdUserAccountBean.setOwner(ownerUserAccount);
    createdUserAccountBean.setRunWebservices(false);
    createdUserAccountBean.setPhone(mobile);
    createdUserAccountBean.setAccessCode(accessCode);
    createdUserAccountBean.setPasswd("5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8");
    createdUserAccountBean.setEmail(email);
    // Since 3.8, openclinica participate needs to be able to use api from openclinica using api_key
    // Copied from UserAccountController.java
    String apiKey = null;
    do {
        apiKey = getRandom32ChApiKey();
    } while (isApiKeyExist(apiKey));
    createdUserAccountBean.setEnableApiKey(true);
    createdUserAccountBean.setApiKey(apiKey);
    Role r = Role.RESEARCHASSISTANT2;
    createdUserAccountBean = addActiveStudyRole(createdUserAccountBean, getStudy(studyOid).getId(), r, ownerUserAccount);
    UserType type = UserType.get(2);
    createdUserAccountBean.addUserType(type);
    authoritiesDao = (AuthoritiesDao) SpringServletAccess.getApplicationContext(context).getBean("authoritiesDao");
    authoritiesDao.saveOrUpdate(new AuthoritiesBean(createdUserAccountBean.getName()));
    return createdUserAccountBean;
}
Also used : Role(org.akaza.openclinica.bean.core.Role) AuthoritiesBean(org.akaza.openclinica.domain.user.AuthoritiesBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserType(org.akaza.openclinica.bean.core.UserType)

Aggregations

AuthoritiesBean (org.akaza.openclinica.domain.user.AuthoritiesBean)6 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)3 Role (org.akaza.openclinica.bean.core.Role)2 UserType (org.akaza.openclinica.bean.core.UserType)2 HibernateException (org.hibernate.HibernateException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)1 Validator (org.akaza.openclinica.control.form.Validator)1 SecurityManager (org.akaza.openclinica.core.SecurityManager)1 AuthoritiesDao (org.akaza.openclinica.dao.hibernate.AuthoritiesDao)1 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)1