/** * Refresh the netgroup cache */ @Override public void cacheGroupsRefresh() throws IOException { List<String> groups = NetgroupCache.getNetgroupNames(); NetgroupCache.clear(); cacheGroupsAdd(groups); }
/** * Add a group to cache, only netgroups are cached * * @param groups list of group names to add to cache */ @Override public void cacheGroupsAdd(List<String> groups) throws IOException { for(String group: groups) { if(group.length() == 0) { // better safe than sorry (should never happen) } else if(group.charAt(0) == '@') { if(!NetgroupCache.isCached(group)) { NetgroupCache.add(group, getUsersForNetgroup(group)); } } else { // unix group, not caching } } }
/** * Get unix groups (parent) and netgroups for given user * * @param user get groups and netgroups for this user * @return groups and netgroups for user */ @Override public List<String> getGroups(String user) throws IOException { // parent get unix groups List<String> groups = new LinkedList<String>(super.getGroups(user)); NetgroupCache.getNetgroups(user, groups); return groups; }