private void removeSessions(SamlNameId nameId, String idpEntityId, List<String> sessionIndexes) {
   for (SamlSpSessionImpl session : samlSpSessions.getSessions()) {
     if (session.getPrincipal().getNameId().equals(nameId)
         && session.getIdentityProvider().getEntityId().equals(idpEntityId)) {
       if (sessionIndexes.size() == 0 || sessionIndexes.contains(session.getSessionIndex())) {
         samlSpSessions.removeSession((SamlSpSessionImpl) session);
         samlServiceProviderSpi.get().loggedOut(session);
       }
     }
   }
 }
  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);
  }