if(users!=null)
{_it = users.iterator();
while (_it.hasNext())
{
JSUser jsuser = (JSUser)_it.next();
try
{
User user = null;
if (userManager.userExists(jsuser.getName()))
{
user = userManager.getUser(jsuser.getName());
}
if ((this.getSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING)) || (user == null))
{
if (user == null) //create new one
{
String password = recreatePassword(jsuser.getPassword());
logMe("add User "+ jsuser.getName() + " with password " + password);
userManager.importUser(jsuser.getName(), password,(passwordEncoding == PASSTHRU_REQUIRED));
logMe("add User done ");
user = userManager.getUser(jsuser.getName());
}
try
{
userManager.setPasswordEnabled(jsuser.getName(), jsuser.getPwEnabled());
userManager.setPasswordUpdateRequired(jsuser.getName(), jsuser.getPwRequiredUpdate());
java.sql.Date d = jsuser.getPwExpirationDate();
if (d != null)
userManager.setPasswordExpiration(jsuser.getName(), d);
}
catch (Exception e)
{
// most likely caused by protected users (like "guest")
logMe("setting userinfo for "+ jsuser.getName() + " failed because of " + e.getLocalizedMessage());
}
//credentials
Subject subject = user.getSubject();
ArrayList listTemp = jsuser.getPrivateCredentials();
if ((listTemp != null) && (listTemp.size()>0))
{
Iterator _itTemp = listTemp.iterator();
while (_itTemp.hasNext())
{
subject.getPrivateCredentials().add(_itTemp.next());
}
}
listTemp = jsuser.getPublicCredentials();
if ((listTemp != null) && (listTemp.size()>0))
{
Iterator _itTemp = listTemp.iterator();
while (_itTemp.hasNext())
{
subject.getPublicCredentials().add(_itTemp.next());
}
}
JSUserGroups jsUserGroups = jsuser.getGroupString();
if (jsUserGroups != null)
listTemp = this.getTokens(jsUserGroups.toString());
else
listTemp = null;
if ((listTemp != null) && (listTemp.size()>0))
{
Iterator _itTemp = listTemp.iterator();
while (_itTemp.hasNext())
{
groupManager.addUserToGroup(jsuser.getName(), (String)_itTemp.next());
}
}
JSUserRoles jsUserRoles = jsuser.getRoleString();
if (jsUserRoles != null)
listTemp = this.getTokens(jsUserRoles.toString());
else
listTemp = null;
if ((listTemp != null) && (listTemp.size()>0))
{
Iterator _itTemp = listTemp.iterator();
while (_itTemp.hasNext())
{
roleManager.addRoleToUser(jsuser.getName(), (String)_itTemp.next());
}
}
JSUserAttributes attributes = jsuser.getUserInfo();
if (attributes != null)
{
Preferences userAttributes = user.getUserAttributes();
HashMap map = attributes.getMyMap();
if (map != null)
{
Iterator _itTemp = map.keySet().iterator();
while (_itTemp.hasNext())
{
String userAttrName = (String)_itTemp.next();
// if ( userAttributes.get(userAttrName, "").equals("")
String userAttrValue = (String)map.get(userAttrName);
userAttributes.put(userAttrName, userAttrValue);
}
}
}
JSNVPElements jsNVP = jsuser.getPreferences();
if ((jsNVP != null) && (jsNVP.getMyMap() != null))
{
Preferences preferences = user.getPreferences();
Iterator _itTemp = jsNVP.getMyMap().keySet().iterator();
while (_itTemp.hasNext())
{
String prefKey = (String)_itTemp.next();
String prefValue = (String)(jsNVP.getMyMap().get(prefKey));
preferences.put(prefKey,prefValue);
}
}
this.userMap.put(jsuser.getName(), getUserPrincipal(user));
}
} catch (Exception e)
{
e.printStackTrace();