ActionForward forward = checkSubmit(request, mapping, form);
if (forward != null) {
return forward;
}
WebUser webUser = SessionUtils.getWebUser(session);
Subject newSubject = new Subject();
newSubject.setName(webUser.getUsername());
newSubject.setFirstName(userForm.getFirstName());
newSubject.setLastName(userForm.getLastName());
newSubject.setDepartment(userForm.getDepartment());
newSubject.setEmailAddress(userForm.getEmailAddress());
newSubject.setPhoneNumber(userForm.getPhoneNumber());
newSubject.setSmsAddress(userForm.getSmsAddress());
newSubject.setFactive(true);
newSubject.setFsystem(false);
// the new user has no prefs, but we still want to pick up the defaults
Configuration userPrefs = (Configuration) getServlet().getServletContext().getAttribute(
Constants.DEF_USER_PREFS);
newSubject.setUserConfiguration(userPrefs);
// password was saved off when the user logged in
String password = (String) session.getAttribute(Constants.PASSWORD_SES_ATTR);
session.removeAttribute(Constants.PASSWORD_SES_ATTR);
Subject superuser = subjectManager.getOverlord();
// create the subject, but don't add a principal since LDAP will handle authentication
log.trace("registering new LDAP-authenticated subject [" + newSubject.getName() + "]");
subjectManager.createSubject(superuser, newSubject);
// nuke the temporary session and establish a new
// one for this subject.. must be done before pulling the
// new subject in order to do it with his own credentials
subjectManager.logout(RequestUtils.getSessionId(request).intValue());
newSubject = subjectManager.loginLocal(newSubject.getName(), password);
// we also need to create up a new web user
webUser = new WebUser(newSubject);
SessionUtils.setWebUser(session, webUser);
session.setAttribute(Constants.USER_OPERATIONS_ATTR, new HashMap()); // user has no permissions yet
HashMap parms = new HashMap(1);
parms.put(Constants.USER_PARAM, newSubject.getId());