AppserverIo\Appserver\ServletEngine\Security\SimpleGroup::isMember PHP Method

isMember() public method

This method does a recursive search, so if a principal belongs to a group which is a member of this group, true is returned. A special check is made to see if the member is an instance of AnybodyPrincipal or NobodyPrincipal since these classes do not hash to meaningful values.
public isMember ( AppserverIo\Psr\Security\PrincipalInterface $principal ) : boolean
$principal AppserverIo\Psr\Security\PrincipalInterface The principal to query membership for
return boolean TRUE if the principal is a member of this group, FALSE otherwise
    public function isMember(PrincipalInterface $principal)
    {
        // first see if there is a key with the member name
        $isMember = $this->members->exists($principal->getName());
        if ($isMember === false) {
            // check the AnybodyPrincipal & NobodyPrincipal special cases
            $isMember = $principal instanceof AnybodyPrincipal;
            if ($isMember === false) {
                if ($principal instanceof NobodyPrincipal) {
                    return false;
                }
            }
        }
        if ($isMember === false) {
            // check any groups for membership
            foreach ($this->members as $group) {
                if ($group instanceof GroupInterface) {
                    $isMember = $group->isMember($principal);
                }
            }
        }
        return $isMember;
    }