<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="moz-cite-prefix">On 1/24/14 9:17 AM, Yann Bourdeau
      wrote:<br>
    </div>
    <blockquote
      cite="mid:1FCD07FE-85A3-4359-AF2A-1737DE3EB267@mnubo.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      Hi!
      <div><br>
      </div>
      <div><span class="Apple-tab-span" style="white-space:pre"> </span>I
        have a hard time figuring out how to validate the signature of a
        response for SSO. From what i have found on the net and the
        documentation i need to use a TrustEngine and a File MetaData
        Provider that will contains the the x.509 certificate to
        validate agains it. </div>
    </blockquote>
    <br>
    <br>
    If you haven't found it yet, the OpenSAML user guide for signatures
    is here:<br>
    <br>
<a class="moz-txt-link-freetext" href="https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManJavaDSIG">https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManJavaDSIG</a><br>
    <br>
    It has a pretty good example for this.<br>
    <br>
    <br>
    <br>
    <blockquote
      cite="mid:1FCD07FE-85A3-4359-AF2A-1737DE3EB267@mnubo.com"
      type="cite">
      <div>Each time, that i try to initialize the Mete Data Provider, i
        got a Java.lang.NullPointerException (Later Unable to marshall
        metadata).</div>
    </blockquote>
    <br>
    <br>
    I think you're actual problem is not related to signature components
    itself.&nbsp; I think that NPE is happening because you haven't supplied
    a parser pool to the metadata provider.&nbsp; I don't see your code below
    doing that and based on line numbers in the exception that's what I
    suspect.&nbsp; That is a required property on the metadata provider.&nbsp; <br>
    <br>
    <br>
    <br>
    <blockquote
      cite="mid:1FCD07FE-85A3-4359-AF2A-1737DE3EB267@mnubo.com"
      type="cite">
      <div><br>
      </div>
      <div>Anyway here is my code:</div>
      <div>
        <div>String responseMessage =
          getContext().getRequest().getParameter("SAMLResponse").toString();&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp;</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>DocumentBuilderFactory
          documentBuilderFactory = DocumentBuilderFactory.newInstance();</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>documentBuilderFactory.setNamespaceAware(true);</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>DocumentBuilder
          docBuilder = documentBuilderFactory.newDocumentBuilder();</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; byte[] encodedRequestMessage = Base64.decode(
          responseMessage );</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>ByteArrayInputStream
          is=new ByteArrayInputStream(new String(encodedRequestMessage,
          "UTF-8").getBytes());</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>Document
          document = docBuilder.parse(is);</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>Element
          element = document.getDocumentElement();</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>UnmarshallerFactory
          unmarshallerFactory = Configuration.getUnmarshallerFactory();</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>Unmarshaller
          unmarshaller = unmarshallerFactory.getUnmarshaller(element);</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>Response
          response = (Response) unmarshaller.unmarshall(element);</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
      </div>
    </blockquote>
    <br>
    Btw, the real way to do the above is using a MessageDecoder, which
    implements the SAML binding in use.&nbsp; It encapsulates all of the
    above.&nbsp; We don't have any good official docs on that, but someone
    has an example that at least illustrates the idea:<br>
    <br>
<a class="moz-txt-link-freetext" href="https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManualPsedocodeSP">https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUserManualPsedocodeSP</a><br>
    <br>
    Or you can look at the decoder unit tests for examples.<br>
    <br>
    <br>
    <br>
    <br>
    <blockquote
      cite="mid:1FCD07FE-85A3-4359-AF2A-1737DE3EB267@mnubo.com"
      type="cite">
      <div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; // INIT ONCE</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; FilesystemMetadataProvider idpMetaDataProvider =
          new FilesystemMetadataProvider(new
          File("/Volumes/&Eacute;l&eacute;phant/apache/apache-tomcat-7.0.47/webapps/panelo/WEB-INF/classes/opensamlmetadata.xml"));
          &nbsp;</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>idpMetaDataProvider.initialize();</div>
      </div>
    </blockquote>
    <br>
    Yeah, you need to supply a ParserPool instance before you init the
    provider.<br>
    <br>
    <br>
    <br>
  </body>
</html>