public void sendSingleLogoutRequestToIDP(
      SamlSpSessionImpl session, HttpServletResponse httpResponse) {
    SamlExternalIdentityProvider idp = session.getIdentityProvider();
    LogoutRequestType logoutRequest;
    logoutRequest =
        samlMessageFactory.createLogoutRequest(
            session.getPrincipal().getNameId(), session.getSessionIndex());

    samlDialogue.setExternalProvider(idp);
    samlSpLogoutDialogue.setSession(session);

    samlMessageSender.sendRequest(idp, SamlProfile.SINGLE_LOGOUT, logoutRequest, httpResponse);
  }
  public void processIDPRequest(
      HttpServletRequest httpRequest, HttpServletResponse httpResponse, RequestAbstractType request)
      throws InvalidRequestException {
    if (!(request instanceof LogoutRequestType)) {
      throw new InvalidRequestException("Request should be a single logout request.");
    }

    LogoutRequestType logoutRequest = (LogoutRequestType) request;
    SamlExternalIdentityProvider idp =
        (SamlExternalIdentityProvider) samlDialogue.getExternalProvider();

    NameIDType nameIdJaxb = logoutRequest.getNameID();
    SamlNameId samlNameId =
        new SamlNameIdImpl(
            nameIdJaxb.getValue(), nameIdJaxb.getFormat(), nameIdJaxb.getNameQualifier());
    removeSessions(samlNameId, idp.getEntityId(), logoutRequest.getSessionIndex());

    StatusResponseType statusResponse =
        samlMessageFactory.createStatusResponse(SamlConstants.STATUS_SUCCESS, null);

    samlMessageSender.sendResponse(idp, statusResponse, SamlProfile.SINGLE_LOGOUT, httpResponse);

    dialogue.setFinished(true);
  }