@Override
protected Object doExecute(BackingEngine engine) throws Exception {
List<UserPrincipal> users = engine.listUsers();
ShellTable table = new ShellTable();
table.column("User Name");
table.column("Group");
table.column("Role");
for (UserPrincipal user : users) {
List<String> reportedRoles = new ArrayList<String>();
String userName = user.getName();
for (GroupPrincipal group : engine.listGroups(user)) {
reportedRoles.addAll(displayGroupRoles(engine, userName, group, table));
}
for (RolePrincipal role : engine.listRoles(user)) {
String roleName = role.getName();
if (reportedRoles.contains(roleName)) {
continue;
}
reportedRoles.add(roleName);
table.addRow().addContent(userName, "", roleName);
}
if (reportedRoles.size() == 0) {
table.addRow().addContent(userName, "", "");
}
}
table.print(System.out, !noFormat);
return null;
}