public Map<GroupPrincipal, String> listGroups() { Map<GroupPrincipal, String> result = new HashMap<GroupPrincipal, String>(); for (String name : users.keySet()) { if (name.startsWith(GROUP_PREFIX)) { result.put(new GroupPrincipal(name.substring(GROUP_PREFIX.length())), users.get(name)); } } return result; }
@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; } }
public void handleRoles(Subject subject,Set<Principal> principals,String discriminator) { Group group = new GroupPrincipal(discriminator); for(Principal p:principals) { if(p instanceof RolePrincipal) { group.addMember(p); } else { subject.getPrincipals().add(p); } } subject.getPrincipals().add(group); } };
@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<GroupPrincipal> listGroups(String userName) { List<GroupPrincipal> result = new ArrayList<GroupPrincipal>(); String userInfo = (String)users.get(userName); if (userInfo != null) { String[] infos = userInfo.split(","); for (int i = 1; i < infos.length; i++) { String name = infos[i]; if (name.startsWith(GROUP_PREFIX)) { result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length()))); } } } return result; }
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; }
public void handleRoles(Subject subject,Set<Principal> principals,String discriminator) { Group group = new GroupPrincipal(discriminator); for(Principal p:principals) { if(p instanceof RolePrincipal) { group.addMember(p); } else { subject.getPrincipals().add(p); } } subject.getPrincipals().add(group); } };
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<GroupPrincipal> listGroups(String userName) { List<GroupPrincipal> result = new ArrayList<>(); String userInfo = users.get(userName); if (userInfo != null) { String[] infos = userInfo.split(","); for (int i = 1; i < infos.length; i++) { String name = infos[i]; if (name.startsWith(GROUP_PREFIX)) { result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length()))); } } } return result; }
/** * 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(); }
private List<GroupPrincipal> listGroups(String userName) { List<GroupPrincipal> result = new ArrayList<>(); String userInfo = users.get(userName); if (userInfo != null) { String[] infos = userInfo.split(","); for (int i = 1; i < infos.length; i++) { String name = infos[i]; if (name.startsWith(GROUP_PREFIX)) { result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length()))); } } } return result; }
/** * 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(); }
private List<GroupPrincipal> listGroups(String userName) { List<GroupPrincipal> result = new ArrayList<>(); String userInfo = users.get(userName); if (userInfo != null) { String[] infos = userInfo.split(","); for (int i = 1; i < infos.length; i++) { String name = infos[i]; if (name.startsWith(GROUP_PREFIX)) { result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length()))); } } } return result; }
@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); } }
private List<GroupPrincipal> listGroups(String userName) { List<GroupPrincipal> result = new ArrayList<>(); String userInfo = users.get(userName); if (userInfo != null) { String[] infos = userInfo.split(","); for (int i = 1; i < infos.length; i++) { String name = infos[i]; if (name.startsWith(GROUP_PREFIX)) { result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length()))); } } } return result; }
@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); } }
public Map<GroupPrincipal, String> listGroups() { Map<GroupPrincipal, String> result = new HashMap<>(); for (String name : users.keySet()) { if (name.startsWith(GROUP_PREFIX)) { result.put(new GroupPrincipal(name.substring(GROUP_PREFIX.length())), users.get(name)); } } return result; }
@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); } }
public Map<GroupPrincipal, String> listGroups() { Map<GroupPrincipal, String> result = new HashMap<>(); for (String name : users.keySet()) { if (name.startsWith(GROUP_PREFIX)) { result.put(new GroupPrincipal(name.substring(GROUP_PREFIX.length())), users.get(name)); } } return result; }
@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); }