private function setAccess($accessType, $userId, $allowed)
    {
        if ($userId instanceof AVUser)
        {
            $userId = $userId->getObjectId();
        }
        if ($userId instanceof AVRole)
        {
            $userId = "role:" . $userId->getName();
        }
        if (!is_string($userId))
        {
            throw new AVException("Invalid target for access control.");
        }
        if (!isset($this->permissionsById[$userId]))
        {
            if (!$allowed)
            {
                return;
            }
            $this->permissionsById[$userId] = array();
        }
        if ($allowed)
        {
            $this->permissionsById[$userId][$accessType] = true;
        } else
        {
            unset($this->permissionsById[$userId][$accessType]);
            if (empty($this->permissionsById[$userId]))
            {
                unset($this->permissionsById[$userId]);
            }
        }
    }