<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<div class="moz-cite-prefix">On 8/7/19 6:50 PM, Brent Putman wrote:<br>
</div>
<blockquote type="cite"
cite="mid:883cf953-2d86-d558-0997-6a05b11341eb@georgetown.edu">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p><br>
</p>
<div class="moz-cite-prefix">On 8/6/19 1:30 AM, DD K wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAD3X5rb17o6XYYdF0oLrq7wBvOnfnA7qvKpEaRkgj_38v_AaJw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<div dir="ltr">
<div class="gmail-adn gmail-ads">
<div class="gmail-gs">
<div class="gmail-">
<div id="gmail-:sy" class="gmail-ii gmail-gt">
<div id="gmail-:s9" class="gmail-a3s gmail-aXjCH">
<div dir="ltr"><br>
<div>The exception is thrown from the code snippet
at the commented line:</div>
<div><br>
</div>
<div>
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(204,120,50)">public static </span>XMLObject <span style="color:rgb(255,198,109)">unmarshall</span>(String authReqStr) <span style="color:rgb(204,120,50)">throws </span>IdentityException {
InputStream inputStream = <span style="color:rgb(204,120,50)">null;
</span><span style="color:rgb(204,120,50)"> try </span>{
<span style="font-style:italic">doBootstrap</span>()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>DocumentBuilderFactory documentBuilderFactory = IdentityUtil.<span style="font-style:italic">getSecuredDocumentBuilderFactory</span>()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>inputStream = <span style="color:rgb(204,120,50)">new </span>ByteArrayInputStream(authReqStr.trim().getBytes(StandardCharsets.<span style="color:rgb(152,118,170);font-style:italic">UTF_8</span>))<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>Document document = docBuilder.parse(inputStream)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>Element element = document.getDocumentElement()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>UnmarshallerFactory unmarshallerFactory = XMLObjectProviderRegistrySupport.<span style="font-style:italic">getUnmarshallerFactory</span>()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element)<span style="color:rgb(204,120,50)">;</span><span style="color:rgb(204,120,50)"></span><span style="color:rgb(152,118,170);font-style:italic"></span><span style="color:rgb(204,120,50)">
</span><span style="color:rgb(204,120,50)"> return </span>unmarshaller.unmarshall(element)<span style="color:rgb(204,120,50)">; // Exception thrown here
</span><span style="color:rgb(204,120,50)"> </span>} <span style="color:rgb(204,120,50)">catch </span>(Exception e) {
<span style="color:rgb(152,118,170);font-style:italic">log</span>.error(<span style="color:rgb(106,135,89)">"Error in constructing AuthRequest from the encoded String"</span><span style="color:rgb(204,120,50)">, </span>e)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> throw </span>IdentityException.<span style="font-style:italic">error</span>(
<span style="color:rgb(106,135,89)">"Error in constructing AuthRequest from the encoded String "</span><span style="color:rgb(204,120,50)">,
</span><span style="color:rgb(204,120,50)"> </span>e)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>} <span style="color:rgb(204,120,50)">finally </span>{
<span style="color:rgb(204,120,50)">if </span>(inputStream != <span style="color:rgb(204,120,50)">null</span>) {
<span style="color:rgb(204,120,50)">try </span>{
inputStream.close()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>} <span style="color:rgb(204,120,50)">catch </span>(IOException e) {
<span style="color:rgb(152,118,170);font-style:italic">log</span>.error(<span style="color:rgb(106,135,89)">"Error while closing the stream"</span><span style="color:rgb(204,120,50)">, </span>e)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>}
}
}
}</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</blockquote>
<p><br>
</p>
<p><br>
</p>
<p>I don't see anything obviously wrong there. If it's throwing
on that line, it's likely that the unmarshaller is null, which
means you didn't get anything back from the
unmarshallerFactory. That means something is likely not working
with your initialization of the library. I can't say anything
more than that. I'd suggest turning up logging to DEBUG or even
TRACE on some or all of the OpenSAML packages to see what is
actually happening, for example whether you are actually
successfully reading and registering the XMLObject builders,
marshallers and unmarshallers.<br>
</p>
</blockquote>
<p><br>
</p>
<p>I doubt it's related to your NPE issue, but I meant to also say
that we'd in general strongly recommend using our ParserPool imp
to parse the InputStream into a Document. It's safer and easier,
and there's also some mandatory things that you must now do when
parsing with your own JAXP or other XML components, or else
unmarshalling will fail, period.</p>
<p><a class="moz-txt-link-freetext" href="https://wiki.shibboleth.net/confluence/display/OS30/Secure+XML+Processing+Requirements">https://wiki.shibboleth.net/confluence/display/OS30/Secure+XML+Processing+Requirements</a><br>
</p>
</body>
</html>