Junit test for SAML Response from IDP

Surinaidu Majji pioneer.suri at gmail.com
Sun Dec 14 23:16:58 EST 2014


I wrote a method to parse the SAMLResponse from IDP, I have collected the
samlResponse by debugging my application
the same thing i am passing to the below code as an input:

    public Response parseResponse(String responseMessage)
                        throws MarshallingException, IOException,
XMLParserException,
                        MessageDecodingException {
                String decodeResponse = decoder.decodeResponse(
responseMessage);
                log.debug("decoded Response : "+decodeResponse);
                Document document = null;
                Unmarshaller unmarshaller = null;

                try {
                        BasicParserPool parserPoolManager = new
BasicParserPool();

                        document = parserPoolManager.parse(new
ByteArrayInputStream(decodeResponse.getBytes()));
                        Element metadataRoot =
document.getDocumentElement();
                        QName qName = new QName(metadataRoot.
getNamespaceURI(),
                                        metadataRoot.getLocalName(),
metadataRoot.getPrefix());
                        **unmarshaller = Configuration.
getUnmarshallerFactory()
                                        .getUnmarshaller(qName);**
                        Response response = (Response) unmarshaller
                                        .unmarshall(metadataRoot);


                        for (Assertion assertion :
response.getAssertions()) {
                            // Processing here
                            }
                         } catch(Exception e) {

                         }
      }

I am writing the junit test case for the above method, but it is not able to
unmarshall it.
The line "unmarshaller = Configuration.getUnmarshallerFactory()
                                        .getUnmarshaller(qName);" is giving
'null'.
But the i have collected the input responseMessage from my application which
is real data.
I could not be able to run the test successfully even the code is working in
actual application.


Thanks & Regards,
M.Surinaidu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20141215/a8f30bd1/attachment.html 


More information about the dev mailing list