// validate that its not an 'blank' rolename -- not allowed
//
String name = rundata.getParameters().getString("username");
if (name == null || name.trim().length() == 0)
{
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_USER_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_INVALID_ENTITY_NAME);
rundata.setRedirectURI(duri.toString());
// save values that user just entered so they don't have to re-enter
if (user != null)
rundata.getUser().setTemp(TEMP_USER, user);
return;
}
//
// create a new user
//
user = JetspeedSecurity.getUserInstance();
rundata.getParameters().setProperties(user);
String password = rundata.getParameters().getString("password");
if (password == null)
password = "";
user.setUserName(JetspeedSecurity.convertUserName(user.getUserName()));
Date now = new Date();
user.setCreateDate(now);
user.setLastLogin(now);
user.setConfirmed(JetspeedResources.CONFIRM_VALUE);
String disabled = rundata.getParameters().getString("disabled");
user.setDisabled( disabled != null );
//
// add the user
///
user.setPassword(password);
JetspeedSecurity.addUser(user);
}
catch (NotUniqueUserException e)
{
// log the error msg
logger.error("Exception", e);
//
// dup key found - display error message - bring back to same screen
//
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_USER_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_ENTITY_ALREADY_EXISTS);
rundata.setRedirectURI(duri.toString());
// save values that user just entered so they don't have to re-enter
if (user != null)
rundata.getUser().setTemp(TEMP_USER, user);
}