DBBroker broker = null;
try {
broker = factory.getBrokerPool().get(user);
final Account u = factory.getBrokerPool().getSecurityManager().getAccount(name);
if (u == null) {
throw new EXistException("account '" + name + "' does not exist");
}
final HashMap<String, Object> tab = new HashMap<String, Object>();
tab.put("uid", user.getId());
tab.put("name", u.getName());
final Vector<String> groups = new Vector<String>();
final String[] groupNames = u.getGroups();
for(final String groupName : groupNames) {
groups.addElement(groupName);
}
tab.put("groups", groups);
final Group dg = u.getDefaultGroup();
if(dg != null) {
tab.put("default-group-id", dg.getId());
tab.put("default-group-realmId", dg.getRealmId());
tab.put("default-group-name", dg.getName());
}
tab.put("enabled", Boolean.toString(u.isEnabled()));
tab.put("umask", u.getUserMask());
final Map<String, String> metadata = new HashMap<String, String>();
for(final SchemaType key : u.getMetadataKeys()) {
metadata.put(key.getNamespace(), u.getMetadataValue(key));
}
tab.put("metadata", metadata);
return tab;