title: Parsing SAMLRequest into an AuthnRequest using OpenSaml the Unmarshaller is NULL
body: <p>I want to parse a SAMLRequest I obtain in an HttpServletRequest into an AuthnRequest Object so I can obtain it's issuer and other attributes.</p>
  
  <p>Using OpenSaml version</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.opensaml&lt;/groupId&gt;
              &lt;artifactId&gt;opensaml-core&lt;/artifactId&gt;
              &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <pre><code>        private String receiveResponse(@RequestParam(name = "SAMLRequest") final String samlRequest, final Model model,
          final HttpServletRequest request, final HttpServletResponse response){
  
          final String encodedSAMLRequest = request.getParameter(EidasConstants.SAML_REQUEST);
  
          byte[] samlToken = EidasStringUtil.decodeBytesFromBase64(encodedSAMLRequest);
          //equal to base64.decode
  
          ByteArrayInputStream stream = new ByteArrayInputStream(samlToken);        
          DefaultBootstrap.bootstrap();
  
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setNamespaceAware(true);
          DocumentBuilder docBuilder = factory.newDocumentBuilder();
          Document samlDocument = docBuilder.parse(stream);
          Element samlElem = samlDocument.getDocumentElement();
  
          UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
          Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElem);
          Object requestXmlObj = unmarshaller.unmarshall(samlElem);
          AuthnRequest authRequest = (AuthnRequest) requestXmlObj;
          }
  </code></pre>
  
  <p>The Element I have is this </p>
  
  <pre><code>&lt;samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" AssertionConsumerServiceURL=
  "https://amis-dev.ulisboa.pt/nidp/saml2/spassertion_consumer" Consent="urn:oasis:names:tc:SAML:2.0:consent:unavailable" Destination="http://10.110.58.
  100:8080/RequestReceiver" ForceAuthn="false" ID="iddVeu9K-BZRNMsife2aSbJ_SZUt8" IsPassive="false" IssueInstant="2019-08-28T14:33:33Z" ProtocolBinding=
  "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0"&gt;
  &lt;saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"&gt;ULisboa&lt;/saml:Issuer&gt;
  &lt;ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
  &lt;ds:SignedInfo&gt;
  &lt;CanonicalizationMethod xmlns="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
  &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/&gt;
  &lt;ds:Reference URI="#iddVeu9K-BZRNMsife2aSbJ_SZUt8"&gt;
  &lt;ds:Transforms&gt;
  &lt;ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/&gt;
  &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
  &lt;/ds:Transforms&gt;
  &lt;ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/&gt;
  &lt;DigestValue xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;DB9eyPJL2El5nj01uowV7AtskOuiqW+482q29Ox9nU4=&lt;/DigestValue&gt;
  &lt;/ds:Reference&gt;
  &lt;/ds:SignedInfo&gt;
  &lt;SignatureValue xmlns="http://www.w3.org/2000/09/xmldsig#"&gt;
  VgNtmtSJEHSY2dgHKNJbSDKocDZfMyIrxkjGkBLgWAKMRwC601C0OY9t1w0C5ZT+79pjbzVgHJ47
  OxNrXqW0ayVuSQiFdw8pPAsNRsCXRkgPWUQf2so5XgvIAUZOd491sehRKzz6LNF9FhJWuNLXuNIl
  joKu9Sn5G7OZXaynSFQ93Rph4uMYp/esu/tlO8d1toPpZS0phwlAEtQvoVgWRQBNyXdgzyulrorJ
  Ogm3zP5U6F41wYhO9mb29rcEIuTUQUrOaNHNJ+f1BlJuffs4S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AmF1y6gV5vp0z5XcyFOfxnzANBgkqhkiG9w0BAQsFAAOCAQEAOgsfy6lu/k7r
  CrkS6OQq1kbMh02iRJeO37k2qJCK9dRmk+P0prteopLy8GESWkVIDnoAmTpTnIbjr9fy/NmCplCm
  D69w56GI+fPVdUpYpTH5wpBoEutDEz53XfCBwb50Ujwg2+LQy1HrEH2B990Sm78UcNahyHfVVAtk
  kx9wLpkyk0FZwgabjrFkZCTsEmJvvbAfHG4jAoMElE3aUuO2Oxp4kwgn1v871Xjmt7iOzSMAYuWC
  ZaoJN8S2ZDrsjhHOSzOGKMb9aoxwIm3w8LnikWCtv2lBWnXSCV2HaQ5UhjH+pjt5yrBgsDWPOtQF
  6dJlIODiWR35BmBaAQOkF7Aapg==
  &lt;/ds:X509Certificate&gt;
  &lt;/ds:X509Data&gt;
  &lt;/ds:KeyInfo&gt;
  &lt;/ds:Signature&gt;
  &lt;samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"/&gt;
  &lt;/samlp:AuthnRequest&gt;
  
  </code></pre>
  
  <p>It's used in</p>
  
  <pre><code>Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElem);
  </code></pre>
  
  <p>to create the unmarshaller but the unmarshaller is returned NULL.</p>
  
  <p>The error message obtained is </p>
  
  <pre><code>java.lang.NullPointerException: null
          at pt.ulisboa.ssobroker.controller.RequestReceiverController.receiveResponse(RequestReceiverController.java:100) ~[classes/:na]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
          at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
          at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.1.8.RELEASE.jar:5.1.
  8.RELEASE]
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.8.RELEASE.
  jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
   ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:89
  2) ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[
  spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.8.
  RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE
  ]
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) ~[spring-webmvc-5.1.8.RELEASE.jar:5.1.8.RELEASE]
  </code></pre>
  
  <p>So finally I just want to obtain the AuthnRequest object so I can use it, but because the unmarshaller is NULL I cannot obtain it, I have tested every other step until there and it seems normal, I just don't know why the unmarshaller is returned as NULL.</p>
  
  <p>I have tried a method using a parsePool from shibboleth but to no avail.</p>
  
  <pre><code>AuthnRequest authRequest = (AuthnRequest) XMLObjectSupport.unmarshallFromInputStream(parserPool, stream);
  </code></pre>
  
  <p>but I could not get the shibboleth parserPool to initialize correctly</p>