/** * Gets users for a netgroup * * @param netgroup return users for this netgroup * @return list of users for a given netgroup */ protected List<String> getUsersForNetgroup(String netgroup) throws IOException { List<String> users = new LinkedList<String>(); // returns a string similar to this: // group ( , user, ) ( domain, user1, host.com ) String usersRaw = execShellGetUserForNetgroup(netgroup); // get rid of spaces, makes splitting much easier usersRaw = usersRaw.replaceAll(" +", ""); // remove netgroup name at the beginning of the string usersRaw = usersRaw.replaceFirst( netgroup.replaceFirst("@", "") + "[()]+", ""); // split string into user infos String[] userInfos = usersRaw.split("[()]+"); for(String userInfo : userInfos) { // userInfo: xxx,user,yyy (xxx, yyy can be empty strings) // get rid of everything before first and after last comma String user = userInfo.replaceFirst("[^,]*,", ""); user = user.replaceFirst(",.*$", ""); // voila! got username! users.add(user); } return users; }
/** * Gets users for a netgroup * * @param netgroup return users for this netgroup * @return list of users for a given netgroup */ protected List<String> getUsersForNetgroup(String netgroup) throws IOException { List<String> users = new LinkedList<String>(); // returns a string similar to this: // group ( , user, ) ( domain, user1, host.com ) String usersRaw = execShellGetUserForNetgroup(netgroup); // get rid of spaces, makes splitting much easier usersRaw = usersRaw.replaceAll(" +", ""); // remove netgroup name at the beginning of the string usersRaw = usersRaw.replaceFirst( netgroup.replaceFirst("@", "") + "[()]+", ""); // split string into user infos String[] userInfos = usersRaw.split("[()]+"); for(String userInfo : userInfos) { // userInfo: xxx,user,yyy (xxx, yyy can be empty strings) // get rid of everything before first and after last comma String user = userInfo.replaceFirst("[^,]*,", ""); user = user.replaceFirst(",.*$", ""); // voila! got username! users.add(user); } return users; }
/** * Gets users for a netgroup * * @param netgroup return users for this netgroup * @return list of users for a given netgroup */ protected List<String> getUsersForNetgroup(String netgroup) throws IOException { List<String> users = new LinkedList<String>(); // returns a string similar to this: // group ( , user, ) ( domain, user1, host.com ) String usersRaw = execShellGetUserForNetgroup(netgroup); // get rid of spaces, makes splitting much easier usersRaw = usersRaw.replaceAll(" +", ""); // remove netgroup name at the beginning of the string usersRaw = usersRaw.replaceFirst( netgroup.replaceFirst("@", "") + "[()]+", ""); // split string into user infos String[] userInfos = usersRaw.split("[()]+"); for(String userInfo : userInfos) { // userInfo: xxx,user,yyy (xxx, yyy can be empty strings) // get rid of everything before first and after last comma String user = userInfo.replaceFirst("[^,]*,", ""); user = user.replaceFirst(",.*$", ""); // voila! got username! users.add(user); } return users; }
/** * Gets users for a netgroup * * @param netgroup return users for this netgroup * @return list of users for a given netgroup */ protected List<String> getUsersForNetgroup(String netgroup) throws IOException { List<String> users = new LinkedList<String>(); // returns a string similar to this: // group ( , user, ) ( domain, user1, host.com ) String usersRaw = execShellGetUserForNetgroup(netgroup); // get rid of spaces, makes splitting much easier usersRaw = usersRaw.replaceAll(" +", ""); // remove netgroup name at the beginning of the string usersRaw = usersRaw.replaceFirst( netgroup.replaceFirst("@", "") + "[()]+", ""); // split string into user infos String[] userInfos = usersRaw.split("[()]+"); for(String userInfo : userInfos) { // userInfo: xxx,user,yyy (xxx, yyy can be empty strings) // get rid of everything before first and after last comma String user = userInfo.replaceFirst("[^,]*,", ""); user = user.replaceFirst(",.*$", ""); // voila! got username! users.add(user); } return users; }
/** * Gets users for a netgroup * * @param netgroup return users for this netgroup * @return list of users for a given netgroup */ protected List<String> getUsersForNetgroup(String netgroup) throws IOException { List<String> users = new LinkedList<String>(); // returns a string similar to this: // group ( , user, ) ( domain, user1, host.com ) String usersRaw = execShellGetUserForNetgroup(netgroup); // get rid of spaces, makes splitting much easier usersRaw = usersRaw.replaceAll(" +", ""); // remove netgroup name at the beginning of the string usersRaw = usersRaw.replaceFirst( netgroup.replaceFirst("@", "") + "[()]+", ""); // split string into user infos String[] userInfos = usersRaw.split("[()]+"); for(String userInfo : userInfos) { // userInfo: xxx,user,yyy (xxx, yyy can be empty strings) // get rid of everything before first and after last comma String user = userInfo.replaceFirst("[^,]*,", ""); user = user.replaceFirst(",.*$", ""); // voila! got username! users.add(user); } return users; }