boolean readyForNow = false;
while (!readyForNow) {
// Find the next session that matches with the removal criteria and
// that has not been removed yet.
SamlIdpSession sessionToRemove = null;
for (SamlIdpSession session : samlIdpSessions.getSessions()) {
if (session.getPrincipal().getNameId().equals(samlNameId)) {
if (sessionIndexes == null || sessionIndexes.size() == 0 || sessionIndexes.contains(((SamlIdpSessionImpl) session).getSessionIndex())) {
sessionToRemove = session;
break;
}
}
}
if (sessionToRemove != null) {
if (sessionToRemove.getServiceProviders().size() != 0) {
// For the session that is about to be removed, get the first
// service provider that participates in the session. Remove it
// from the session.
SamlExternalServiceProvider sp = sessionToRemove.getServiceProviders().iterator().next();
sessionToRemove.getServiceProviders().remove(sp);
// If the session participant is not the party that initiated the
// single logout, and it has a single logout service, send a
// single logout request. Otherwise, move on to the next session
// participant (if available) or to the next session.