Finds the roles mapped to given user groups.

@param userGroups
The user groups.
@return The roles found.
972419
public Set<Role> findRoles(final Set<Group> userGroups)
    {
        final Set<Role> result = new HashSet<Role>();
        
        for(final RoleMapping mapping : this.getRoleMappings())
        {
            final Object source = mapping.getSource();
            
            if((userGroups != null) && userGroups.contains(source))
            {
                result.add(mapping.getTarget());
            }
        }
        
        return result;
    }
71752
def _get_groups(self):
        
        if self._groups is None:
            self._groups = _LDAPUserGroups(self)

        return self._groups
801197
public Map<String, String> getUsersGroups() {
        Map<String, String> usersGroups = new LinkedHashMap<String, String>();
        for (Map.Entry<String, List<String>> entry : USERS_GROUPS.entrySet()) {
            String key = entry.getKey();
            usersGroups.put(key + " (" + entry.getValue().get(0) + ")", key);
        }
        return usersGroups;
    }
29158
public function getGroups()
	{
		if ( ! $this->userGroups)
		{
			$this->userGroups = $this->groups()->get();
		}

		return $this->userGroups;
	}
691299
private Collection getUserRoles(String userName) throws NamingException {
        log.debug("Obtaining roles for userName: " + userName);

        // filter expression: all roles with uniqueMember matching user DN
        // (uniqueMember=cn=userName,dc=company,dc=com)
        String filter = "(" + roleMemberRDN + "=" + userNameRDN + "=" + userName + "," + userBase + ")";

        //search directory
        NamingEnumeration roleResults = this.search(roleBase,
                                                    filter,
                                                    new String[]{
                                                        roleMemberRDN
                                                    });
        ArrayList results = new ArrayList();
        while (roleResults != null && roleResults.hasMore()) {

            SearchResult roleResult = (SearchResult) roleResults.next();

            String roleResultName = roleResult.getName();
            if ("".equals(roleResultName)) {
                //logger.debug("ignoring empty result");
                continue;
            }
            String roleResultValue = (roleResultName.split("="))[1];
            results.add(roleResultValue);
        }
        return results;
    }
340933
public void setGroups(java.util.Collection<GroupType> groups) {
        if (groups == null) {
            this.groups = null;
            return;
        }

        this.groups = new java.util.ArrayList<GroupType>(groups);
    }
1171565
public List<String> getGroups(String user) throws IOException {
    if (!mCacheEnabled) {
      return mService.getGroups(user);
    }
    try {
      return mCache.get(user);
    } catch (ExecutionException e) {
      throw new IOException(e);
    }
  }
1097775
def get_groups(self, roles):
        """"""
        ret = {}
        for role in roles:
            if role not in self.flatten:
                raise MissingRole(role)
            for b in self.flatten[role]['backends_groups']:
                if b not in ret:
                    ret[b] = []
                ret[b] = ret[b] + self.flatten[role]['backends_groups'][b]
        return ret
451121
public Set<Group> findGroups(final RestletUtilUser user, final boolean inheritOnly)
    {
        final Set<Group> result = new HashSet<Group>();
        Set<Group> stack;
        
        // Recursively find user groups
        for(final Group group : this.getRootGroups())
        {
            stack = new LinkedHashSet<Group>();
            this.addGroupsForUser(user, result, group, stack, inheritOnly);
        }
        
        return result;
    }
385405
def get_user_roles(self, user):
        
        return self.service.get_user_roles(
            user, self.url_prefix, self.auth, self.session, self.session_send_opts)
1187929
private Set<String> getUserRoles(Subject subject) {
        Set<String> userRoles = null;

        // get roles from specified classes
        Set<Principal> principals = subject.getPrincipals();
        if (roleClassNames != null && roleClassNames.size() > 0) {
            for (Principal p : principals) {
                if (roleClassNames.contains(p.getClass().getName())) {
                    if (userRoles == null) userRoles = new HashSet<String>();
                    userRoles.add(p.getName());
                }
            }
        }

        // get roles from specified attributes
        Map<String, Set<String>> attributes =
                SubjectUtils.getAttributes(subject);
        for (String key : attributes.keySet()) {
            if (roleAttributeNames.contains(key)) {
                if (userRoles == null) userRoles = new HashSet<String>();
                userRoles.addAll(attributes.get(key));
            }
        }

        if (userRoles == null) userRoles = Collections.emptySet();
        if (logger.isDebugEnabled()) {
            for (String r : userRoles) {
                logger.debug("found role: {}", r);
            }
        }

        return userRoles;
    }
1057656
public List<ResourceCollection> getByRole(Roles role)
  {
    return role == null ? ImmutableList.<ResourceCollection> of() : getByRole(role.toString());
  }
965287
@Override
    public Set<Node> getUsersForGroup(Node group) {
		Set<Node> users = new TreeSet<>();
		try {
			String query = "(" + groupIdentifyer + "=" + group.getName() + ")";
			SearchResult searchResult;
			Attributes attributes;
			SearchControls controls = new SearchControls();
			controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
			NamingEnumeration<SearchResult> results = ctx.search("", query, controls);
			Node user;
			while (results.hasMore()) {
				searchResult = results.next();
				attributes = searchResult.getAttributes();
				NamingEnumeration<?> members = attributes.get(groupMemberAttribut).getAll();
				while (members.hasMoreElements()) {
					String memberDN = (String) members.nextElement();
					String uid = getIdentifyerValueFromDN(memberDN);
					user = getUser(uid);
					user.setDn(memberDN);
					users.add(user);
				}
			}
		} catch (NamingException ex) {
			handleNamingException(group, ex);
		}
		return users;
	}
160686
public function hasGroups($groups)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($groups)) {
            $groups = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($groups, $this->groups)) === count($groups);
    }
989906
public Set<Group> findGroups(final User user, final boolean inheritOnly)
    {
        final Set<Group> result = new HashSet<Group>();
        List<Group> stack;
        
        // Recursively find user groups
        for(final Group group : this.getRootGroups())
        {
            stack = new ArrayList<Group>();
            this.addGroups(user, result, group, stack, inheritOnly);
        }
        
        return result;
    }
957245
public Iterable<DUser> queryByRoles(java.lang.Object roles) {
    return queryByField(null, DUserMapper.Field.ROLES.getFieldName(), roles);
  }
100498
private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception
   {
      List<Group> groups = new ArrayList<Group>();
      String parentId = parent == null ? "" : parent.getId();

      NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes();

      while (childNodes.hasNext())
      {
         Node groupNode = childNodes.nextNode();
         if (!groupNode.getName().startsWith(JCROrganizationServiceImpl.JOS_MEMBERSHIP))
         {
            Group group = readGroup(groupNode);
            groups.add(group);

            if (recursive)
            {
               groups.addAll(findGroups(session, group, recursive));
            }
         }
      }

      return groups;
   }