public function insertOrUpdateClassAce($objectIdentity, $sid, $mask, $strategy = null)
    {
        $this->enforceObjectIdentity($objectIdentity);
        $this->enforceSecurityIdentity($sid);
        $mask = $this->resolveMask($mask, $objectIdentity);

        $acl = $this->getAcl($objectIdentity);

        $found = false;

        foreach ($acl->getClassAces() as $index => $ace) {
            if ($ace->getSecurityIdentity()->equals($sid)) {
                $acl->updateClassAce($index, $mask, $strategy);
                $found = true;
                break;
            }
        }

        if (false === $found) {
            $acl->insertClassAce($sid, $mask, 0, true, $strategy);
        }

        $this->securityContext->getACLProvider()->updateAcl($acl);

        return $this;
    }