Search in sources :

Example 66 with UserAccountBean

use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.

the class OpenClinicaSecurityContextLogoutHandler method auditLogout.

void auditLogout(String username) {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    UserAccountBean userAccount = (UserAccountBean) getUserAccountDao().findByUserName(username);
    AuditUserLoginBean auditUserLogin = new AuditUserLoginBean();
    auditUserLogin.setUserName(username);
    auditUserLogin.setLoginStatus(LoginStatus.SUCCESSFUL_LOGOUT);
    auditUserLogin.setLoginAttemptDate(new Date());
    auditUserLogin.setUserAccountId(userAccount != null ? userAccount.getId() : null);
    getAuditUserLoginDao().saveOrUpdate(auditUserLogin);
}
Also used : Locale(java.util.Locale) AuditUserLoginBean(org.akaza.openclinica.domain.technicaladmin.AuditUserLoginBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Date(java.util.Date)

Example 67 with UserAccountBean

use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.

the class OpenClinicaSessionRegistryImpl method auditLogout.

void auditLogout(String username) {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    UserAccountBean userAccount = (UserAccountBean) getUserAccountDao().findByUserName(username);
    AuditUserLoginBean auditUserLogin = new AuditUserLoginBean();
    auditUserLogin.setUserName(username);
    auditUserLogin.setLoginStatus(LoginStatus.SUCCESSFUL_LOGOUT);
    auditUserLogin.setLoginAttemptDate(new Date());
    auditUserLogin.setUserAccountId(userAccount != null ? userAccount.getId() : null);
    getAuditUserLoginDao().saveOrUpdate(auditUserLogin);
}
Also used : Locale(java.util.Locale) AuditUserLoginBean(org.akaza.openclinica.domain.technicaladmin.AuditUserLoginBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Date(java.util.Date)

Example 68 with UserAccountBean

use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.

the class SetUpUserInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
    Locale locale = ResourceBundleProvider.localeMap.get(Thread.currentThread());
    if (locale == null) {
        ResourceBundleProvider.updateLocale(httpServletRequest.getLocale());
    }
    //Set up the user account bean: check the Session first
    HttpSession currentSession = httpServletRequest.getSession();
    UserAccountBean userBean = (UserAccountBean) currentSession.getAttribute("userBean");
    String userName = "";
    boolean userBeanIsInvalid;
    UserAccountDAO userAccountDAO = new UserAccountDAO(dataSource);
    if (userBean == null) {
        userName = httpServletRequest.getRemoteUser();
        userBeanIsInvalid = "".equalsIgnoreCase(userName);
        if (!userBeanIsInvalid) {
            userBean = (UserAccountBean) userAccountDAO.findByUserName(userName);
            userBeanIsInvalid = (userBean == null);
            if (!userBeanIsInvalid) {
                currentSession.setAttribute(USER_BEAN_NAME, userBean);
            }
        }
    }
    //The user bean could still be null at this point
    if (userBean == null) {
        userBean = new UserAccountBean();
        userBean.setName("unknown");
        currentSession.setAttribute(USER_BEAN_NAME, userBean);
    }
    userBean = userBean.getId() > 0 ? (UserAccountBean) userAccountDAO.findByPK(userBean.getId()) : userBean;
    SetUpStudyRole setupStudy = new SetUpStudyRole(dataSource);
    setupStudy.setUp(currentSession, userBean);
    return true;
}
Also used : Locale(java.util.Locale) HttpSession(javax.servlet.http.HttpSession) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 69 with UserAccountBean

use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.

the class SubmitDataServletTest method test_SubmitDataServlet_MayViewData.

// Scenario
// Data Entry Person (site) can access Subject    
public void test_SubmitDataServlet_MayViewData() {
    UserAccountBean ub = new UserAccountBean();
    //StudyUserRoleBean currentRole = new StudyUserRoleBean();
    //currentRole.setRole(Role.COORDINATOR);
    StudyUserRoleBean studyUserRoleBeanMock = mock(StudyUserRoleBean.class);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT);
    boolean result1 = SubmitDataServlet.mayViewData(ub, studyUserRoleBeanMock);
    assertEquals(true, result1);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT2);
    boolean result2 = SubmitDataServlet.mayViewData(ub, studyUserRoleBeanMock);
    assertEquals(true, result2);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.ADMIN);
    boolean result3 = SubmitDataServlet.mayViewData(ub, studyUserRoleBeanMock);
    assertEquals(false, result3);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.INVALID);
    boolean result4 = SubmitDataServlet.mayViewData(ub, studyUserRoleBeanMock);
    assertEquals(false, result4);
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Example 70 with UserAccountBean

use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.

the class SubmitDataServletTest method test_SubmitDataServlet_MaySubmitData.

// Scenario
// Data Entry Person (site) can access Notes & Discrepancies
public void test_SubmitDataServlet_MaySubmitData() {
    UserAccountBean ub = new UserAccountBean();
    //StudyUserRoleBean currentRole = new StudyUserRoleBean();
    //currentRole.setRole(Role.COORDINATOR);
    StudyUserRoleBean studyUserRoleBeanMock = mock(StudyUserRoleBean.class);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT);
    boolean result1 = SubmitDataServlet.maySubmitData(ub, studyUserRoleBeanMock);
    assertEquals(true, result1);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT2);
    boolean result2 = SubmitDataServlet.maySubmitData(ub, studyUserRoleBeanMock);
    assertEquals(true, result2);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.ADMIN);
    boolean result3 = SubmitDataServlet.maySubmitData(ub, studyUserRoleBeanMock);
    assertEquals(false, result3);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.INVALID);
    boolean result4 = SubmitDataServlet.maySubmitData(ub, studyUserRoleBeanMock);
    assertEquals(false, result4);
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Aggregations

UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)152 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)64 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)56 ArrayList (java.util.ArrayList)52 HashMap (java.util.HashMap)38 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)36 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)35 Date (java.util.Date)32 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)32 Locale (java.util.Locale)30 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)18 Iterator (java.util.Iterator)16 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)16 ResponseEntity (org.springframework.http.ResponseEntity)16 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)15 Validator (org.akaza.openclinica.control.form.Validator)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Role (org.akaza.openclinica.bean.core.Role)11 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)10 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)10