throws RegistrationException
{
try
{
// create the user
User user = userManager.addUser(userName);
PasswordCredential pwc = userManager.getPasswordCredential(user);
pwc.setPassword(null, password);
userManager.storePasswordCredential(pwc);
// assign roles to user
if (roles == null || roles.isEmpty())
{
roles = this.defaultRoles;
}
if (roles != null)
{
Iterator roleList = roles.iterator();
while (roleList.hasNext())
{
String role = (String)roleList.next();
if (role.trim().length() > 0)
roleManager.addRoleToUser(userName, role);
}
}
// assign groups to user
if (groups == null || groups.isEmpty())
{
groups = this.defaultGroups;
}
if (groups != null)
{
Iterator groupsList = groups.iterator();
while (groupsList.hasNext())
{
String group = (String)groupsList.next();
if (group.trim().length() > 0)
{
groupManager.addUserToGroup(userName, group);
}
}
}
// assign user attributes to user
if (userInfo != null)
{
SecurityAttributes userAttrs = user.getSecurityAttributes();
Iterator info = userInfo.entrySet().iterator();
while (info.hasNext())
{
Map.Entry entry = (Map.Entry) info.next();
userAttrs.getAttribute((String) entry.getKey(), true).setStringValue((String) entry.getValue());
}
}
// assign profiling rules to user
if (rules == null || rules.isEmpty())
{
rules = this.defaultRules;
}
if (rules != null)
{
Iterator ruleEntries = rules.entrySet().iterator();
while (ruleEntries.hasNext())
{
Map.Entry entry = (Map.Entry)ruleEntries.next();
ProfilingRule rule = profiler.getRule((String)entry.getValue());
if (rule != null)
{
profiler.setRuleForPrincipal(user, rule, (String)entry.getKey());
}
}
}
// get template folders
if (folderTemplate == null)
{
folderTemplate = this.folderTemplate;
}
String userFolderPath = null;
if ((subsite == null) && (serverName != null))
{
userFolderPath = invokeGetUserFolderPath(user, locale, serverName);
}
else if (subsite != null)
{
userFolderPath = subsite + Folder.USER_FOLDER + userName;
}
else
{
userFolderPath = Folder.USER_FOLDER + userName;
}
// This next chunk of code is the fancy way to force the creation of the user
// template pages to be created with subject equal to the new user
// otherwise it would be created as guest, and guest does not have enough privs.
final String innerFolderTemplate = folderTemplate;
final String innerUserFolderPath = userFolderPath;
final PageManager innerPageManager = pageManager;
final String innerUserName = userName;
final User innerUser = user;
User powerUser = userManager.getUser(this.adminUser);
JetspeedException pe = (JetspeedException) JSSubject.doAsPrivileged(userManager.getSubject(powerUser), new PrivilegedAction()
{
public Object run()
{
try