Search in sources :

Example 46 with UserAccountBean

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

the class AccountController method getAccessCodeAccount.

private UserAccountBean getAccessCodeAccount(String accessCode) {
    udao = new UserAccountDAO(dataSource);
    UserAccountBean userAccountBean = (UserAccountBean) udao.findByAccessCode(accessCode);
    return userAccountBean;
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 47 with UserAccountBean

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

the class AccountController method getAccount1.

/**
	 * @api {get} /pages/accounts/study/:studyOid/crc/:crcUserName Retrieve a user account - crc
	 * @apiName getAccount1
	 * @apiPermission Module participate - enabled & admin
	 * @apiVersion 3.8.0
	 * @apiParam {String} studyOid Study Oid.
	 * @apiParam {String} crcUserName CRC Username .
	 * @apiGroup User Account
	 * @apiDescription Retrieves the crc user account with the given crcUserName and studyOid
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "studyOid": " S_BL101",
	 *                  "crcUserName": "crc_user"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    HTTP/1.1 200 OK
	 *                    {
	 *                    "lName": "Jackson",
	 *                    "mobile": "",
	 *                    "accessCode": "",
	 *                    "apiKey": "6e8b69f6fb774e899f9a6c349c5adace",
	 *                    "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
	 *                    "email": "abc@yahoo.com",
	 *                    "userName": "crc_user",
	 *                    "studySubjectId": null,
	 *                    "fName": "joe"
	 *                    }
	 */
@RequestMapping(value = "/study/{studyOid}/crc/{crcUserName}", method = RequestMethod.GET)
public ResponseEntity<UserDTO> getAccount1(@PathVariable("studyOid") String studyOid, @PathVariable("crcUserName") String crcUserName) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    uDTO = null;
    System.out.println("I'm in getAccount1");
    StudyBean parentStudy = getParentStudy(studyOid);
    Integer pStudyId = parentStudy.getId();
    String oid = parentStudy.getOid();
    if (isStudyASiteLevelStudy(studyOid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (!mayProceed(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isStudyDoesNotExist(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isCRCUserAccountDoesNotExist(crcUserName))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (doesCRCNotHaveStudyAccessRole(crcUserName, pStudyId))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    UserAccountBean userAccountBean = (UserAccountBean) udao.findByUserName(crcUserName);
    buildUserDTO(userAccountBean);
    return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) ResponseEntity(org.springframework.http.ResponseEntity) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserDTO(org.akaza.openclinica.bean.login.UserDTO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Example 48 with UserAccountBean

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

the class AccountController method isAccessCodeExistInSystem.

private Boolean isAccessCodeExistInSystem(String accessCode) {
    UserAccountBean accessCodeAccountBean = getAccessCodeAccount(accessCode);
    if (accessCodeAccountBean.isActive()) {
        logger.info("***Access Code already Exist in the User Table ***");
        System.out.println("***Access Code already Exist in the User Table ***");
        return true;
    }
    return false;
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Example 49 with UserAccountBean

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

the class AccountController method getAccount2.

/**
	 * @api {get} /pages/accounts/study/:studyOid/accesscode/:accessCode Retrieve a user account - participant
	 * @apiName getAccount2
	 * @apiPermission Module participate - enabled & admin
	 * @apiVersion 3.8.0
	 * @apiParam {String} studyOid Study Oid.
	 * @apiParam {String} accessCode Participant Access code .
	 * @apiGroup User Account
	 * @apiDescription Retrieves the participant user account with the given accessCode and studyOid
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "studyOid": " S_BL101",
	 *                  "accessCode": "yfzqpvDpiJftIZgNDphvxg=="
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    HTTP/1.1 200 OK
	 *                    {
	 *                    "lName": "",
	 *                    "mobile": "jLGQwxkuVpPBLJCtnLdrAw==",
	 *                    "accessCode": "yfzqpvDpiJftIZgNDphvxg==",
	 *                    "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
	 *                    "email": "XzJadh3l3V7uUoPCggbSoIfoNW8IQU3qsvrtHfJH7J0=",
	 *                    "userName": "S_BL101.SS_SUBA101",
	 *                    "studySubjectId": null,
	 *                    "fName": "07hQGfwT6LRXk0rLLYwkviwNdOEycnj4lOjrNMBdesk="
	 *                    }
	 */
@RequestMapping(value = "/study/{studyOid}/accesscode/{accessCode}", method = RequestMethod.GET)
public ResponseEntity<UserDTO> getAccount2(@PathVariable("studyOid") String studyOid, @PathVariable("accessCode") String accessCode) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    uDTO = null;
    System.out.println("I'm in getAccount2");
    accessCode = URLDecoder.decode(accessCode, "UTF-8");
    StudyBean parentStudy = getParentStudy(studyOid);
    String oid = parentStudy.getOid();
    if (isStudyASiteLevelStudy(studyOid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (!mayProceed(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isStudyDoesNotExist(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isAccessCodeIsNull(accessCode))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    UserAccountBean accessCodeAccountBean = getAccessCodeAccount(accessCode);
    if (!accessCodeAccountBean.isActive())
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    // This code should've been in liquibase migration for better readability.
    if (accessCodeAccountBean.getApiKey() == null || accessCodeAccountBean.getApiKey().isEmpty()) {
        String apiKey = null;
        do {
            apiKey = getRandom32ChApiKey();
        } while (isApiKeyExist(apiKey));
        accessCodeAccountBean.setEnableApiKey(true);
        accessCodeAccountBean.setApiKey(apiKey);
        updateUserAccount(accessCodeAccountBean);
    }
    buildUserDTO(accessCodeAccountBean);
    // Client want to trade access_code for api_key, for later usage of our api.
    if (accessCodeAccountBean.isEnableApiKey()) {
        uDTO.setApiKey(accessCodeAccountBean.getApiKey());
    }
    return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) ResponseEntity(org.springframework.http.ResponseEntity) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserDTO(org.akaza.openclinica.bean.login.UserDTO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Example 50 with UserAccountBean

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

the class AccountController method isCRCUserAccountDoesNotExist.

private Boolean isCRCUserAccountDoesNotExist(String crcUserName) {
    UserAccountBean ownerUserAccount = getUserAccount(crcUserName);
    if (!ownerUserAccount.isActive()) {
        logger.info("***  CRC user acount does not Exist in the User Table ***");
        System.out.println("***  CRC user acount does not Exist in the User Table ***");
        return true;
    }
    return false;
}
Also used : 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