Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Currently i am working on SAML IDP intitated SSO implementation.
Here are steps what i have done.
If user session doesn't exists, calling the login URL of IDP server(One login).
URL serviceUrl = new URL("https://lechm-dev.onelogin.com/trust/saml2/http-post/sso/74697012");
httpServletResponse.sendRedirect(serviceUrl.toString());
After login, IDP is sending the SAML response to the redirect URL
@RequestMapping(value = {"/saml/auth"})
public String authenticate(HttpServletRequest request, HttpServletResponse response) throws Exception{
MyUser myUser = null;
if(null != request.getParameter("SAMLResponse")) {
myUser = userService.createUserFromResponse(request.getParameter("SAMLResponse"));
return "authenticate...! ";
In the user service logic for parsing the SAML response
@Override
public MyUser createUserFromResponse(String samlResponse) throws
ParserConfigurationException, SAXException,
IOException, UnmarshallingException, XMLParserException {
Response resp = null;
if (samlResponse != null) {
Document document = null;
try {
DefaultBootstrap.bootstrap();
BasicParserPool basicParserPool = new BasicParserPool();
basicParserPool.setNamespaceAware(true);
Reader reader = new StringReader(samlResponse);
document = basicParserPool.parse(reader); // here i am getting SAXParseException
} catch (ConfigurationException e1) {
e1.printStackTrace();
Element element = document.getDocumentElement();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
XMLObject responseXmlObj = unmarshaller.unmarshall(element);
resp = (Response) responseXmlObj;
createUserJSONFromAttributes(resp);
LOG.debug(">>>>>>> SAML Response : MyUser Object >>>>> : " + myUser.toString());
return myUser;
Here, on parsing the SAML response i am facing SAXParseException.
23:59:53 ERROR org.opensaml.xml.parse.BasicParserPool - XML Parsing Error
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.opensaml.xml.parse.BasicParserPool$DocumentBuilderProxy.parse(BasicParserPool.java:690)
at org.opensaml.xml.parse.BasicParserPool.parse(BasicParserPool.java:233)
Please let me know what i have done wrong.. Please suggest. Thank you in advance.
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.