LogoutRequestType logOutRequest = (LogoutRequestType) request.getSAML2Object();
String issuer = logOutRequest.getIssuer().getValue();
try
{
SAML2Response saml2Response = new SAML2Response();
SAML2Request saml2Request = new SAML2Request();
ServletContext servletCtx = httpContext.getServletContext();
IdentityServer server = (IdentityServer)servletCtx.getAttribute("IDENTITY_SERVER");
if(server == null)
throw new ProcessingException("Identity Server not found");
String originalIssuer = (relayState == null) ? issuer : relayState;
String participant = this.getParticipant(server, sessionID, originalIssuer);
if(participant == null || participant.equals(originalIssuer))
{
//All log out is done
session.invalidate();
server.stack().pop(sessionID);
generateSuccessStatusResponseType(logOutRequest.getID(),
request, response, originalIssuer);
}
else
{
//Put the participant in transit mode
server.stack().registerTransitParticipant(sessionID, participant);
if(relayState == null)
relayState = originalIssuer;
//send logout request to participant with relaystate to orig
response.setRelayState(originalIssuer);
response.setDestination(participant);
LogoutRequestType lort = saml2Request.createLogoutRequest(request.getIssuer().getValue());
response.setResultingDocument(saml2Request.convert(lort));
}
}
catch(ParserConfigurationException pe)
{
throw new ProcessingException(pe);