*/
private ResponseType getResponseType(MockCatalinaResponse response, ByteArrayOutputStream bos) {
ResponseType responseType = null;
try {
SAML2Response samlResponse = new SAML2Response();
if (bos == null) {
MockCatalinaRequest requestTmp = new MockCatalinaRequest();
AuthenticatorTestUtils.populateParametersWithQueryString(response.redirectString, requestTmp);
responseType = (ResponseType) samlResponse.getSAML2ObjectFromStream(RedirectBindingUtil
.base64DeflateDecode(requestTmp.getParameter(GeneralConstants.SAML_RESPONSE_KEY)));
} else {
Document postBindingForm = DocumentUtil.getDocument(bos.toString());
logger.info("POST Binding response from the IDP:");
logger.info(prettyPrintDocument(postBindingForm).toString());
NodeList nodes = postBindingForm.getElementsByTagName("INPUT");
Element inputElement = (Element) nodes.item(0);
String idpResponse = inputElement.getAttributeNode("VALUE").getValue();
responseType = (ResponseType) samlResponse.getSAML2ObjectFromStream(PostBindingUtil
.base64DecodeAsStream(idpResponse));
}
Document convert = samlResponse.convert(responseType);
logger.info("ResponseType returned from the IDP:");
System.out.println(prettyPrintDocument(convert));
} catch (Exception e) {
e.printStackTrace();