Converts an <code>IGroupMember</code> into an <code>IAuthorizationPrincipal</code>.

@return org.apereo.portal.security.IAuthorizationPrincipal
@param groupMember org.apereo.portal.groups.IGroupMember
188157
@Override
    public IAuthorizationPrincipal newPrincipal(IGroupMember groupMember) throws GroupsException {
        String key = groupMember.getKey();
        Class type = groupMember.getType();

        logger.debug("AuthorizationImpl.newPrincipal(): for {} ({})", type, key);

        return newPrincipal(key, type);
    }
881127
public Collection<BoxGroupMembership.Info> getMemberships() {
        final BoxAPIConnection api = this.getAPI();
        final String groupID = this.getID();

        Iterable<BoxGroupMembership.Info> iter = new Iterable<BoxGroupMembership.Info>() {
            public Iterator<BoxGroupMembership.Info> iterator() {
                URL url = MEMBERSHIPS_URL_TEMPLATE.build(api.getBaseURL(), groupID);
                return new BoxGroupMembershipIterator(api, url);
            }
        };

        // We need to iterate all results because this method must return a Collection. This logic should be removed in
        // the next major version, and instead return the Iterable directly.
        Collection<BoxGroupMembership.Info> memberships = new ArrayList<BoxGroupMembership.Info>();
        for (BoxGroupMembership.Info membership : iter) {
            memberships.add(membership);
        }
        return memberships;
    }
611696
private Set<IGroupMember> primGetAllMembers(Set<IGroupMember> rslt) throws GroupsException {
        for (IGroupMember gm : getChildren()) {
            rslt.add(gm);
            if (gm.isGroup()) {
                ((EntityGroupImpl) gm).primGetAllMembers(rslt);
            }
        }
        return rslt;
    }
1034845
public static boolean isAdmin(IAuthorizationPrincipal ap) {
        IGroupMember member = AuthorizationServiceFacade.instance().getGroupMember(ap);
        return isAdmin(member);
    }
481267
@Override
    public Set<Entity> getGroupsForMember(String memberName) {
        Set<Entity> groups = new HashSet<Entity>();
        if (StringUtils.isNotEmpty(memberName)) {
            EntityIdentifier[] identifiers =
                    GroupService.searchForEntities(
                            memberName,
                            GroupService.SearchMethod.DISCRETE,
                            EntityEnum.PERSON.getClazz());
            for (EntityIdentifier entityIdentifier : identifiers) {
                if (entityIdentifier.getType().equals(EntityEnum.PERSON.getClazz())) {
                    IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
                    if (memberName.equalsIgnoreCase(groupMember.getKey())) {
                        Iterator it = GroupService.findParentGroups(groupMember);
                        while (it.hasNext()) {
                            IEntityGroup g = (IEntityGroup) it.next();
                            Entity e =
                                    EntityFactory.createEntity(
                                            g, EntityEnum.getEntityEnum(g.getLeafType(), true));
                            groups.add(e);
                        }
                        return groups;
                    }
                }
            }
        }
        return groups;
    }
415234
public <X> UnbackedAnnotatedMember<X> getUnbackedMember(UnbackedMemberIdentifier<X> identifier) {
        return unbackedAnnotatedMembersById.getCastValue(identifier);
    }
958769
@Override
    public IAuthorizationPrincipal getPrincipal(IPermission permission)
            throws AuthorizationException {
        String principalString = permission.getPrincipal();
        int idx = principalString.indexOf(PRINCIPAL_SEPARATOR);
        Integer typeId = Integer.valueOf(principalString.substring(0, idx));
        Class type = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(typeId);
        String key = principalString.substring(idx + 1);
        return newPrincipal(key, type);
    }
1162430
public List<String> getPrivateAutoScalingMemberIPs(String autoScalingGroupName) {
        Preconditions.checkArgument(autoScalingGroupName != null && !autoScalingGroupName.isEmpty());
        List<String> members = this.getAutoScalingMembers(autoScalingGroupName);
        DescribeInstancesRequest req = new DescribeInstancesRequest();
        req.setInstanceIds(members);
        DescribeInstancesResult result = this.ec2Client.describeInstances(req);
        List<String> list = new ArrayList<>();
        for (Reservation reservation : result.getReservations()) {
            for (Instance instance : reservation.getInstances()) {
                if (instance.getState().getName().equals("running")) {
                    list.add(instance.getPrivateIpAddress());
                }
            }
        }
        return list;
    }
91098
private IAuthorizationPrincipal getAuthorizationPrincipal(HttpServletRequest req) {
        IPerson user = personManager.getPerson(req);
        EntityIdentifier ei = user.getEntityIdentifier();
        IAuthorizationPrincipal rslt =
                AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
        return rslt;
    }
833079
public ExecutionVertex getGroupMember(final int pos) {

		if (pos < 0) {
			throw new IllegalArgumentException("Argument pos must be greater or equal to 0");
		}

		try {
			return this.groupMembers.get(pos);
		} catch (ArrayIndexOutOfBoundsException e) {
			return null;
		}
	}
1156771
public static Iterator findParentGroups(IGroupMember gm) throws GroupsException {
        LOGGER.trace("Invoking findParentGroups for IGroupMember [{}]", gm);
        return instance().ifindParentGroups(gm);
    }
83294
public IPersonAttributesGroupDefinition createPagsDefinition(
            IPerson person, IEntityGroup parent, String groupName, String description) {

        // What's the target of the upcoming permissions check?
        String target =
                parent != null
                        ? parent.getEntityIdentifier().getKey()
                        : IPermission
                                .ALL_GROUPS_TARGET; // Must have blanket permission to create one
        // w/o a parent

        // Verify permission
        if (!hasPermission(person, IPermission.CREATE_GROUP_ACTIVITY, target)) {
            throw new RuntimeAuthorizationException(
                    person, IPermission.CREATE_GROUP_ACTIVITY, target);
        }

        // VALIDATION STEP:  The group name & description are allowable
        if (StringUtils.isBlank(groupName)) {
            throw new IllegalArgumentException("Specified groupName is blank:  " + groupName);
        }
        if (!GROUP_NAME_VALIDATOR_PATTERN.matcher(groupName).matches()) {
            throw new IllegalArgumentException(
                    "Specified groupName is too long, too short, or contains invalid characters:  "
                            + groupName);
        }
        if (!StringUtils.isBlank(description)) { // Blank description is allowable
            if (!GROUP_DESC_VALIDATOR_PATTERN.matcher(description).matches()) {
                throw new IllegalArgumentException(
                        "Specified description is too long or contains invalid characters:  "
                                + description);
            }
        }

        // VALIDATION STEP:  We don't have a group by that name already
        EntityIdentifier[] people =
                GroupService.searchForGroups(
                        groupName, IGroupConstants.SearchMethod.DISCRETE_CI, IPerson.class);
        EntityIdentifier[] portlets =
                GroupService.searchForGroups(
                        groupName,
                        IGroupConstants.SearchMethod.DISCRETE_CI,
                        IPortletDefinition.class);
        if (people.length != 0 || portlets.length != 0) {
            throw new IllegalArgumentException("Specified groupName already in use:  " + groupName);
        }

        IPersonAttributesGroupDefinition rslt =
                pagsGroupDefDao.createPersonAttributesGroupDefinition(groupName, description);
        if (parent != null) {
            // Should refactor this switch to instead choose a service and invoke a method on it
            switch (parent.getServiceName().toString()) {
                case SERVICE_NAME_LOCAL:
                    IEntityGroup member =
                            GroupService.findGroup(
                                    rslt.getCompositeEntityIdentifierForGroup().getKey());
                    if (member == null) {
                        String msg =
                                "The specified group was created, but is not present in the store:  "
                                        + rslt.getName();
                        throw new RuntimeException(msg);
                    }
                    parent.addChild(member);
                    parent.updateMembers();
                    break;
                case SERVICE_NAME_PAGS:
                    IPersonAttributesGroupDefinition parentDef =
                            getPagsGroupDefByName(parent.getName());
                    Set<IPersonAttributesGroupDefinition> members =
                            new HashSet<>(parentDef.getMembers());
                    members.add(rslt);
                    parentDef.setMembers(members);
                    pagsGroupDefDao.updatePersonAttributesGroupDefinition(parentDef);
                    break;
                default:
                    String msg =
                            "The specified group service does not support adding members:  "
                                    + parent.getServiceName();
                    throw new UnsupportedOperationException(msg);
            }
        }

        return rslt;
    }
605746
public Token<DelegationTokenIdentifier> createDelegationToken(String renewer) throws IOException {
    Text renewerText = new Text();
    if (renewer != null) {
      renewerText.set(renewer);
    }

    DelegationTokenIdentifier tokenIdentifier =
        requireNonNull(createTokenIdentifier(renewerText), "Token identifier");

    Token<DelegationTokenIdentifier> token = new Token<>(tokenIdentifier, secretManager);
    token.setKind(getKind());
    token.setService(service);
    logger.atFine().log("Created token %s with token identifier %s", token, tokenIdentifier);
    return token;
  }
420632
@SuppressWarnings("unchecked")
    @Override
	public <T extends ApiUser> List<T> getUsersInGroup(String groupId) {
	    Collection<User> sfsUsers = getZone().getUsersInGroup(groupId);
	    List<T> anwser = new ArrayList<>();
	    for(User sfsUser : sfsUsers)
	        if(sfsUser.containsProperty(APIKey.USER))
	            anwser.add((T) sfsUser.getProperty(APIKey.USER));
	    return anwser;
	}
1331055
public void updateGroupMembers(GroupForm groupForm, IPerson updater) {

        if (!canEditGroup(updater, groupForm.getKey())) {
            throw new RuntimeAuthorizationException(
                    updater, IPermission.EDIT_GROUP_ACTIVITY, groupForm.getKey());
        }

        if (log.isDebugEnabled()) {
            log.debug("Updating group members for group form [" + groupForm.toString() + "]");
        }

        // find the current version of this group entity
        IEntityGroup group = GroupService.findGroup(groupForm.getKey());

        // clear the current group membership list
        for (IGroupMember child : group.getChildren()) {
            group.removeChild(child);
        }

        // add all the group membership information from the group form
        // to the group
        for (JsonEntityBean child : groupForm.getMembers()) {
            EntityEnum type = EntityEnum.getEntityEnum(child.getEntityTypeAsString());
            if (type.isGroup()) {
                IEntityGroup member = GroupService.findGroup(child.getId());
                group.addChild(member);
            } else {
                IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz());
                group.addChild(member);
            }
        }

        // save the group, updating both its basic information and group
        // membership
        group.updateMembers();
    }
1009678
@Override
    protected IEntityGroup primFindGroup(String localKey) throws GroupsException {
        IEntityGroup group = groupFactory.find(localKey);
        if (group != null) {
            group.setLocalGroupService(this);
        }
        return group;
    }
20750
public OrganizationMember getMember(int orgId, int userId) {
		return getResourceFactory().getApiResource(
				"/org/" + orgId + "/member/" + userId).get(
				OrganizationMember.class);
	}