* @throws ConfigurationException
*/
public boolean process(String samlRequest, HTTPContext httpContext, Set<SAML2Handler> handlers, Lock chainLock)
throws ProcessingException, IOException, ParsingException, ConfigurationException {
SAML2Request saml2Request = new SAML2Request();
SAML2HandlerResponse saml2HandlerResponse = null;
SAML2Object samlObject = null;
SAMLDocumentHolder documentHolder = null;
if (this.postBinding) {
// we got a logout request from IDP
InputStream is = PostBindingUtil.base64DecodeAsStream(samlRequest);
samlObject = saml2Request.getSAML2ObjectFromStream(is);
} else {
InputStream is = RedirectBindingUtil.base64DeflateDecode(samlRequest);
samlObject = saml2Request.getSAML2ObjectFromStream(is);
}
documentHolder = saml2Request.getSamlDocumentHolder();
// Create the request/response
SAML2HandlerRequest saml2HandlerRequest = getSAML2HandlerRequest(documentHolder, httpContext);
saml2HandlerResponse = new DefaultSAML2HandlerResponse();
saml2HandlerResponse.setPostBindingForResponse(postBinding);
SAMLHandlerChainProcessor chainProcessor = new SAMLHandlerChainProcessor(handlers);
// Set some request options
setRequestOptions(saml2HandlerRequest);
chainProcessor.callHandlerChain(samlObject, saml2HandlerRequest, saml2HandlerResponse, httpContext, chainLock);
Document samlResponseDocument = saml2HandlerResponse.getResultingDocument();
String relayState = saml2HandlerResponse.getRelayState();
String destination = saml2HandlerResponse.getDestination();
boolean willSendRequest = saml2HandlerResponse.getSendRequest();
if (destination != null && samlResponseDocument != null) {
if (postBinding) {
sendRequestToIDP(destination, samlResponseDocument, relayState, httpContext.getResponse(), willSendRequest);
} else {
String destinationQuery = saml2HandlerResponse.getDestinationQueryStringWithSignature();
// This is the case with signatures disabled
if (destinationQuery == null) {
boolean areWeSendingRequest = saml2HandlerResponse.getSendRequest();
String samlMsg = DocumentUtil.getDocumentAsString(samlResponseDocument);
String base64Request = RedirectBindingUtil.deflateBase64URLEncode(samlMsg.getBytes("UTF-8"));
destinationQuery = RedirectBindingUtil.getDestinationQueryString(base64Request, relayState,
areWeSendingRequest);