public function prepareLogoutRequest(User $user, $sessionIndex = null)
    {
        $request = $this->createLogoutRequest();

        $request->setNameID(
            new NameID(
                $user->getUserName(),
                SamlConstants::NAME_ID_FORMAT_UNSPECIFIED
            )
        );

        if (!is_null($sessionIndex)) {
            $request->setSessionIndex($sessionIndex);
        }

        $request->setDestination(
            $this->getMetadata()->getFirstIdpSsoDescriptor()->getFirstSingleLogoutService()->getLocation()
        );

        $request->setRelayState(Helper::generateID());

        $this->signMessage($request);

        return $request;
    }