// Getting the http request
ActionRequestImpl reqImpl = (ActionRequestImpl) req;
HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
PortletSession ses = req.getPortletSession();
String companyId = PortalUtil.getCompanyId(req);
String firstName = ParamUtil.getString(req, "first_name");
String middleName = ParamUtil.getString(req, "middle_name");
String lastName = ParamUtil.getString(req, "last_name");
String nickName = ParamUtil.getString(req, "nick_name");
String userId = ParamUtil.get(req, "user_id", "");
boolean autoUserId = ParamUtil.get(req, "auto_user_id", false);
String emailAddress =
ParamUtil.getString(req, "email_address").toLowerCase();
boolean autoPassword = ParamUtil.get(req, "auto_password", false);
String password1 = ParamUtil.getString(req, "password_1");
String password2 = ParamUtil.getString(req, "password_2");
boolean passwordReset = ParamUtil.get(
req, "password_reset",
GetterUtil.getBoolean(PropsUtil.get(
PropsUtil.PASSWORDS_CHANGE_ON_FIRST_USE)));
boolean male = ParamUtil.get(req, "male", true);
int bdMonth = ParamUtil.get(
req, "birthday_month", Calendar.JANUARY);
int bdDay = ParamUtil.get(req, "birthday_day", 1);
int bdYear = ParamUtil.get(req, "birthday_year", 1970);
Locale locale = null;
if (req.getRemoteUser() == null) {
locale = (Locale)ses.getAttribute(
Globals.LOCALE_KEY, PortletSession.APPLICATION_SCOPE);
}
else {
User defaultUser =
UserLocalManagerUtil.getDefaultUser(companyId);
locale = defaultUser.getLocale();
}
Captcha captcha = null;
if (GetterUtil.getBoolean(
PropsUtil.get(PropsUtil.CAPTCHA_CHALLENGE)) &&
(config.getPortletName().equals(PortletKeys.MY_ACCOUNT))) {
captcha = (Captcha)ses.getAttribute(
WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);
Boolean validResponse = captcha.validateResponse(
ParamUtil.getString(req, "captcha_response"));
if ((validResponse == null) ||
(validResponse.equals(Boolean.FALSE))) {
ses.removeAttribute(
WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);
throw new CaptchaException();
}
}
UserManagerUtil.addUser(
companyId, autoUserId, userId, autoPassword, password1,
password2, passwordReset, firstName, middleName, lastName,
nickName, male,
new GregorianCalendar(bdYear, bdMonth, bdDay).getTime(),
emailAddress, locale);
if (captcha != null) {
captcha.disposeChallenge();
ses.removeAttribute(
WebKeys.CAPTCHA, PortletSession.APPLICATION_SCOPE);
}
// Session messages