* @param user
* @return a new JSUser object
*/
private JSUser createJSUser(User user)
{
JSUser _newUser = new JSUser();
Subject subject = user.getSubject();
// get the user principal
Set principals = subject.getPrincipals();
Iterator list = principals.iterator();
while (list.hasNext())
{
BasePrincipal principal = (BasePrincipal) list.next();
String path = principal.getFullPath();
if (path.startsWith("/role/"))
{
JSRole _tempRole = (JSRole) this.getObjectBehindPath(roleMap,
principal.getName());
if (_tempRole != null)
{
_newUser.addRole(_tempRole);
}
} else
{
if (path.startsWith("/group/"))
{
JSGroup _tempGroup = (JSGroup) this.getObjectBehindPath(
groupMap, principal.getName());
if (_tempGroup != null)
{
_newUser.addGroup(_tempGroup);
}
} else if (path.startsWith("/user/"))
_newUser.setPrincipal(principal);
}
}
// System.out.println("User Public Credentials");
Set credentials = subject.getPublicCredentials();
list = credentials.iterator();
while (list.hasNext())
{
Object credential = list.next();
addJSUserCredentials(true, _newUser, credential);
}
// System.out.println("User Private Credentials");
credentials = subject.getPrivateCredentials();
list = credentials.iterator();
while (list.hasNext())
{
Object credential = list.next();
addJSUserCredentials(false, _newUser, credential);
}
Preferences preferences = user.getPreferences();
_newUser.setPreferences(preferences);
preferences = user.getUserAttributes();
_newUser.setUserInfo(preferences);
//TODO: HJB, fix preferences...userinfo doesn't return values in prefs_property_value (in fact preferences.keys() is []
return _newUser;
}