@Override protected Object doExecute(BackingEngine engine) throws Exception { System.out.println(String.format(GROUP_LIST_FORMAT, "Group", "Roles")); for (GroupPrincipal group : engine.listGroups().keySet()) { System.out.println(String.format(GROUP_LIST_FORMAT, group.getName(), engine.listGroups().get(group))); } return null; } }
@Override protected Object doExecute(BackingEngine engine) throws Exception { System.out.println(String.format(GROUP_LIST_FORMAT, "Group", "Roles")); for (GroupPrincipal group : engine.listGroups().keySet()) { System.out.println(String.format(GROUP_LIST_FORMAT, group.getName(), engine.listGroups().get(group))); } return null; } }
private List<String> displayGroupRoles(BackingEngine engine, String userName, GroupPrincipal group, ShellTable table) { List<String> names = new ArrayList<>(); List<RolePrincipal> roles = engine.listRoles(group); if (roles != null && roles.size() >= 1) { for (RolePrincipal role : roles) { String roleName = role.getName(); names.add(roleName); table.addRow().addContent(userName, group.getName(), roleName); } } return names; }
private List<String> displayGroupRoles(BackingEngine engine, String userName, GroupPrincipal group, ShellTable table) { List<String> names = new ArrayList<>(); List<RolePrincipal> roles = engine.listRoles(group); if (roles != null && roles.size() >= 1) { for (RolePrincipal role : roles) { String roleName = role.getName(); names.add(roleName); table.addRow().addContent(userName, group.getName(), roleName); } } return names; }
/** * Delete a User. */ public void deleteUser(String username, boolean withoutGroupDeletionOnLastUser) { // delete all its groups first, for garbage collection of the groups for (GroupPrincipal gp : listGroups(username)) { deleteGroup(username, gp.getName(), withoutGroupDeletionOnLastUser); } users.remove(username); saveUserProperties(); }
/** * Add a role to a User. */ public void addRole(String username, String role) { String userInfos = users.get(username); if (userInfos != null) { for (RolePrincipal rp : listRoles(username)) { if (role.equals(rp.getName())) { return; } } for (GroupPrincipal gp : listGroups(username)) { if (role.equals(GROUP_PREFIX + gp.getName())) { return; } } String newUserInfos = userInfos + "," + role; users.put(username, newUserInfos); } saveUserProperties(); }
@Override public void deleteUser(String username) { // delete all its groups first, for garbage collection of the groups for (GroupPrincipal gp : listGroups(username)) { deleteGroup(username, gp.getName()); } users.remove(username); try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot remove users file,", ex); } }
@Override public void deleteUser(String username) { // delete all its groups first, for garbage collection of the groups for (GroupPrincipal gp : listGroups(username)) { deleteGroup(username, gp.getName()); } users.remove(username); try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot remove users file,", ex); } }
@Override public void deleteUser(String username) { // delete all its groups first, for garbage collection of the groups for (GroupPrincipal gp : listGroups(username)) { deleteGroup(username, gp.getName()); } users.remove(username); try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot remove users file,", ex); } }
@Override public void deleteGroup(String username, String group) { deleteRole(username, GROUP_PREFIX + group); // garbage collection, clean up the groups if needed for (UserPrincipal user : listUsers()) { for (GroupPrincipal g : listGroups(user)) { if (group.equals(g.getName())) { // there is another user of this group, nothing to clean up return; } } } // nobody is using this group any more, remove it deleteUser(GROUP_PREFIX + group); }
@Override public void deleteGroup(String username, String group) { deleteRole(username, GROUP_PREFIX + group); // garbage collection, clean up the groups if needed for (UserPrincipal user : listUsers()) { for (GroupPrincipal g : listGroups(user)) { if (group.equals(g.getName())) { // there is another user of this group, nothing to clean up return; } } } // nobody is using this group any more, remote it deleteUser(GROUP_PREFIX + group); }
@Override public void deleteUser(String username) { // delete all its groups first, for garbage collection of the groups for (GroupPrincipal gp : listGroups(username)) { deleteGroup(username, gp.getName()); } users.remove(username); try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot remove users file,", ex); } }
@Override public void deleteGroup(String username, String group) { deleteRole(username, GROUP_PREFIX + group); // garbage collection, clean up the groups if needed for (UserPrincipal user : listUsers()) { for (GroupPrincipal g : listGroups(user)) { if (group.equals(g.getName())) { // there is another user of this group, nothing to clean up return; } } } // nobody is using this group any more, remote it deleteUser(GROUP_PREFIX + group); }
@Override public void deleteGroup(String username, String group) { deleteRole(username, GROUP_PREFIX + group); // garbage collection, clean up the groups if needed for (UserPrincipal user : listUsers()) { for (GroupPrincipal g : listGroups(user)) { if (group.equals(g.getName())) { // there is another user of this group, nothing to clean up return; } } } // nobody is using this group any more, remove it deleteUser(GROUP_PREFIX + group); }
@Override public void deleteGroup(String username, String group, boolean withoutGroupDeletionOnLastUser) { deleteRole(username, GROUP_PREFIX + group); // garbage collection, clean up the groups if needed for (UserPrincipal user : listUsers()) { for (GroupPrincipal g : listGroups(user)) { if (group.equals(g.getName())) { // there is another user of this group, nothing to clean up return; } } } if (!withoutGroupDeletionOnLastUser) { // nobody is using this group any more, remote it deleteUser(GROUP_PREFIX + group, withoutGroupDeletionOnLastUser); } }
@Override public void addRole(String username, String role) { String userInfos = users.get(username); if (userInfos != null) { for (RolePrincipal rp : listRoles(username)) { if (role.equals(rp.getName())) { return; } } for (GroupPrincipal gp : listGroups(username)) { if (role.equals(GROUP_PREFIX + gp.getName())) { return; } } String newUserInfos = userInfos + "," + role; users.put(username, newUserInfos); } try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot update users file,", ex); } }
@Override public void addRole(String username, String role) { String userInfos = users.get(username); if (userInfos != null) { for (RolePrincipal rp : listRoles(username)) { if (role.equals(rp.getName())) { return; } } for (GroupPrincipal gp : listGroups(username)) { if (role.equals(GROUP_PREFIX + gp.getName())) { return; } } String newUserInfos = userInfos + "," + role; users.put(username, newUserInfos); } try { users.save(); } catch (Exception ex) { LOGGER.error("Cannot update users file,", ex); } }