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;
}
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);
}
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;
}
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);
}
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;
}
Aggregations