use of com.sun.identity.saml2.protocol.LogoutRequest in project OpenAM by OpenRock.
the class SPSingleLogoutServiceSOAP method onMessage.
/**
* Process the incoming SOAP message containing the LogoutRequest and
* generates outgoing SOAP message containing the LogoutResponse on SP side.
* @param message incoming SOAP message.
* @param request HTTP servlet request.
* @param response HTTP servlet response.
* @param realm realm of the hosted SP.
* @param spEntityID Entity ID of the hosted SP.
* @return SOAP message containing the outgoing LogoutResponse.
*/
public SOAPMessage onMessage(SOAPMessage message, HttpServletRequest request, HttpServletResponse response, String realm, String spEntityID) {
SAML2Utils.debug.message("SPSLOServiceSOAP.onMessage: starting");
LogoutRequest logoutReq = null;
String tmpStr = request.getParameter("isLBReq");
boolean isLBReq = (tmpStr == null || !tmpStr.equals("false"));
try {
Element reqElem = SOAPCommunicator.getInstance().getSamlpElement(message, "LogoutRequest");
logoutReq = ProtocolFactory.getInstance().createLogoutRequest(reqElem);
// delay the signature validation until it finds the session
} catch (SAML2Exception se) {
SAML2Utils.debug.error("SPSingleLogoutServiceSOAP.onMessage: " + "unable to get LogoutRequest from message", se);
return SOAPCommunicator.getInstance().createSOAPFault(SAML2Constants.CLIENT_FAULT, "errorLogoutRequest", se.getMessage());
}
if (logoutReq == null) {
SAML2Utils.debug.error("SPSLOServiceSOAP.onMessage: null request");
return SOAPCommunicator.getInstance().createSOAPFault(SAML2Constants.CLIENT_FAULT, "nullLogoutRequest", null);
}
// process LogoutRequestElement
LogoutResponse loRes = SPSingleLogout.processLogoutRequest(logoutReq, spEntityID, realm, request, response, isLBReq, SAML2Constants.SOAP, false);
if (loRes == null) {
SAML2Utils.debug.error("SPSLOSOAP.onMessage: null LogoutResponse");
return SOAPCommunicator.getInstance().createSOAPFault(SAML2Constants.SERVER_FAULT, "errorLogoutResponse", null);
}
SOAPMessage msg = null;
try {
LogoutUtil.signSLOResponse(loRes, realm, spEntityID, SAML2Constants.SP_ROLE, logoutReq.getIssuer().getValue());
msg = SOAPCommunicator.getInstance().createSOAPMessage(loRes.toXMLString(true, true), false);
} catch (SAML2Exception se) {
SAML2Utils.debug.error("SPSingleLogoutServiceSOAP.onMessage: " + "Unable to create SOAP message:", se);
return SOAPCommunicator.getInstance().createSOAPFault(SAML2Constants.SERVER_FAULT, "errorLogoutResponseSOAP", se.getMessage());
} catch (SOAPException ex) {
SAML2Utils.debug.error("SPSingleLogoutServiceSOAP.onMessage: " + "Unable to create SOAP message:", ex);
return SOAPCommunicator.getInstance().createSOAPFault(SAML2Constants.SERVER_FAULT, "errorLogoutResponseSOAP", ex.getMessage());
}
return msg;
}
use of com.sun.identity.saml2.protocol.LogoutRequest in project OpenAM by OpenRock.
the class SAML2PostAuthenticationPlugin method createLogoutRequest.
private LogoutRequest createLogoutRequest(String metaAlias, String realm, String idpEntityId, EndpointType logoutEndpoint, NameID nameId, String sessionIndex) throws SAML2Exception, SessionException {
// generate unique request ID
final String requestID = SAML2Utils.generateID();
if ((requestID == null) || (requestID.length() == 0)) {
DEBUG.warning("SAML2 PAP :: Unable to perform single logout, unable to generate request ID - {}", SAML2Utils.bundle.getString("cannotGenerateID"));
throw new SAML2Exception(SAML2Utils.BUNDLE_NAME, "cannotGenerateID", new Object[0]);
}
final String spEntityID = META_MANAGER.getEntityByMetaAlias(metaAlias);
final Issuer issuer = SAML2Utils.createIssuer(spEntityID);
final LogoutRequest logoutReq = ProtocolFactory.getInstance().createLogoutRequest();
logoutReq.setID(requestID);
logoutReq.setVersion(SAML2Constants.VERSION_2_0);
logoutReq.setIssueInstant(new Date());
logoutReq.setIssuer(issuer);
if (sessionIndex != null) {
logoutReq.setSessionIndex(Collections.singletonList(sessionIndex));
}
String location = logoutEndpoint.getLocation();
logoutReq.setDestination(XMLUtils.escapeSpecialCharacters(location));
LogoutUtil.setNameIDForSLORequest(logoutReq, nameId, realm, spEntityID, SAML2Constants.SP_ROLE, idpEntityId);
return logoutReq;
}
Aggregations