private function validateIdentity(Sharing $constraint, $identityClass, array $roles, Collection $permissions): void
    {
        $res = $this->validateClass($constraint, $identityClass, $constraint->identityClass);

        if ($res && !$this->sharingManager->hasIdentityConfig($identityClass)) {
            $res = false;
            $this->context->buildViolation($constraint->classNotManagedMessage)
                ->atPath($constraint->identityClass)
                ->setParameter('%class_property%', $constraint->identityClass)
                ->setParameter('%class%', $identityClass)
                ->addViolation()
            ;
        }

        if ($res) {
            $config = $this->sharingManager->getIdentityConfig($identityClass);
            $this->validateRoles($constraint, $config, $roles);
            $this->validatePermissions($constraint, $config, $permissions);
        }
    }