use of org.akaza.openclinica.dao.hibernate.ConfigurationDao in project OpenClinica by OpenClinica.
the class UpdateProfileServlet method confirmProfile.
private void confirmProfile(UserAccountBean userBean1, UserAccountDAO udao) throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("firstName", Validator.NO_BLANKS);
v.addValidation("lastName", Validator.NO_BLANKS);
v.addValidation("email", Validator.IS_A_EMAIL);
if (!userBean1.isLdapUser()) {
v.addValidation("passwdChallengeQuestion", Validator.NO_BLANKS);
v.addValidation("passwdChallengeAnswer", Validator.NO_BLANKS);
// old password
v.addValidation("oldPasswd", Validator.NO_BLANKS);
String password = fp.getString("passwd").trim();
ConfigurationDao configurationDao = SpringServletAccess.getApplicationContext(context).getBean(ConfigurationDao.class);
org.akaza.openclinica.core.SecurityManager sm = (org.akaza.openclinica.core.SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager");
String newDigestPass = sm.encrytPassword(password, getUserDetails());
List<String> pwdErrors = new ArrayList<String>();
if (!StringUtils.isBlank(password)) {
// new password
v.addValidation("passwd", Validator.IS_A_PASSWORD);
// confirm
v.addValidation("passwd1", Validator.CHECK_SAME, "passwd");
// password
PasswordRequirementsDao passwordRequirementsDao = new PasswordRequirementsDao(configurationDao);
Locale locale = LocaleResolver.getLocale(request);
ResourceBundle resexception = ResourceBundleProvider.getExceptionsBundle(locale);
pwdErrors = PasswordValidator.validatePassword(passwordRequirementsDao, udao, userBean1.getId(), password, newDigestPass, resexception);
}
v.addValidation("phone", Validator.NO_BLANKS);
errors = v.validate();
for (String err : pwdErrors) {
v.addError(errors, "passwd", err);
}
userBean1.setFirstName(fp.getString("firstName"));
userBean1.setLastName(fp.getString("lastName"));
userBean1.setEmail(fp.getString("email"));
userBean1.setInstitutionalAffiliation(fp.getString("institutionalAffiliation"));
userBean1.setPasswdChallengeQuestion(fp.getString("passwdChallengeQuestion"));
userBean1.setPasswdChallengeAnswer(fp.getString("passwdChallengeAnswer"));
userBean1.setPhone(fp.getString("phone"));
userBean1.setActiveStudyId(fp.getInt("activeStudyId"));
StudyDAO sdao = new StudyDAO(this.sm.getDataSource());
StudyBean newActiveStudy = (StudyBean) sdao.findByPK(userBean1.getActiveStudyId());
request.setAttribute("newActiveStudy", newActiveStudy);
if (errors.isEmpty()) {
logger.info("no errors");
session.setAttribute("userBean1", userBean1);
String oldPass = fp.getString("oldPasswd").trim();
if (!userBean1.isLdapUser() && !sm.isPasswordValid(ub.getPasswd(), oldPass, getUserDetails())) {
Validator.addError(errors, "oldPasswd", resexception.getString("wrong_old_password"));
request.setAttribute("formMessages", errors);
// addPageMessage("Wrong old password. Please try again.");
forwardPage(Page.UPDATE_PROFILE);
} else {
if (!StringUtils.isBlank(fp.getString("passwd"))) {
userBean1.setPasswd(newDigestPass);
userBean1.setPasswdTimestamp(new Date());
}
session.setAttribute("userBean1", userBean1);
forwardPage(Page.UPDATE_PROFILE_CONFIRM);
}
} else {
logger.info("has validation errors");
session.setAttribute("userBean1", userBean1);
request.setAttribute("formMessages", errors);
forwardPage(Page.UPDATE_PROFILE);
}
}
}
use of org.akaza.openclinica.dao.hibernate.ConfigurationDao in project OpenClinica by OpenClinica.
the class SQLInitServlet method init.
@Override
public void init() throws ServletException {
context = getServletContext();
CoreResources cr = (CoreResources) SpringServletAccess.getApplicationContext(context).getBean("coreResources");
params = cr.getDATAINFO();
entParams = cr.getDATAINFO();
// params = (Properties) SpringServletAccess.getApplicationContext(context).getBean("dataInfo");
// entParams = (Properties) SpringServletAccess.getApplicationContext(context).getBean("enterpriseInfo");
ConfigurationDao configurationDao = SpringServletAccess.getApplicationContext(context).getBean(ConfigurationDao.class);
Role.COORDINATOR.setDescription(getField("coordinator"));
Role.STUDYDIRECTOR.setDescription(getField("director"));
Role.INVESTIGATOR.setDescription(getField("investigator"));
Role.RESEARCHASSISTANT.setDescription(getField("ra"));
Role.RESEARCHASSISTANT2.setDescription(getField("ra2"));
Role.MONITOR.setDescription(getField("monitor"));
Page.INITIAL_DATA_ENTRY_NW.getFileName();
//The crf/original/CRF Template will be created if not exist.
String theDir = getField("filePath");
String dir1 = "crf" + File.separator;
String dir2 = "original" + File.separator;
String dirRules = "rules";
// Creating rules directory if not exist mantis issue 6584.
if (!(new File(theDir)).isDirectory() || !(new File(dirRules)).isDirectory()) {
(new File(theDir + dirRules)).mkdirs();
}
if (!(new File(theDir)).isDirectory() || !(new File(dir1)).isDirectory() || !(new File(dir2)).isDirectory()) {
(new File(theDir + dir1 + dir2)).mkdirs();
copyTemplate(theDir + dir1 + dir2 + DownloadVersionSpreadSheetServlet.CRF_VERSION_TEMPLATE);
}
theDir = theDir + dir1 + dir2;
File excelFile = new File(theDir + DownloadVersionSpreadSheetServlet.CRF_VERSION_TEMPLATE);
if (!excelFile.isFile()) {
copyTemplate(theDir);
}
// 'passwd_expiration_time' and 'change_passwd_required' are now defined in the database
// Here the values in the datainfo.properites file (if any) are overridden.
overridePropertyFromDatabase(configurationDao, "pwd.expiration.days", params, "passwd_expiration_time");
overridePropertyFromDatabase(configurationDao, "pwd.change.required", params, "change_passwd_required");
}
Aggregations