<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
On 11/1/11 8:47 PM, Brad Cox wrote:
<blockquote
cite="mid:CAH2etF77T1xewzVcx7xYrMPsmua6Bk3z1D+087v=KNLjUG+DBw@mail.gmail.com"
type="cite">Got it. My problem was confusing building with
unmarshalling. May be closing in on it.</blockquote>
<br>
Ok, that code below looks more correct. I also wasn't clear that
you were starting with a DOM from elsewhere, and were then adding
stuff to it using OpenSAML. Unmarshalling an XMLObject tree around
that Envelope Element as the first step is the right way to go.<br>
<br>
<blockquote
cite="mid:CAH2etF77T1xewzVcx7xYrMPsmua6Bk3z1D+087v=KNLjUG+DBw@mail.gmail.com"
type="cite">
<div><br>
</div>
<div>The attachSamlAssertion method now fails in
the Signer.signObject(signature) call because
signature.XMLSignature is null. </div>
<blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none;
padding: 0px;">
<div>
<div>ERROR<span class="Apple-tab-span" style="white-space:
pre;"> </span>11691<span class="Apple-tab-span"
style="white-space: pre;"> </span>main<span
class="Apple-tab-span" style="white-space: pre;"> </span>DisaBlueprintSamlProcessorTest.java:76<span
class="Apple-tab-span" style="white-space: pre;"> </span>Exception<span
class="Apple-tab-span" style="white-space: pre;"> </span>com.technica.xacml2.runtime.XacmlFault:
XMLObject does not have an XMLSignature instance, unable to
compute signature</div>
</div>
</blockquote>
<div><br>
</div>
Debugger shows XMLSignature variable is indeed null but the
Signature interface has no way to set it. SignatureImpl does, but
not sure I should use that and don't know what to set it to.<br>
</blockquote>
<br>
<br>
Right, I think you're close now. You're just forgetting to marshall
everything before you sign with the Signer. The Apache xmlsec
XMLSignature instance isn't settable, it's created by the
marshalling process. It's not intended that manipulate or access
it. <br>
<br>
<br>
<blockquote
cite="mid:CAH2etF77T1xewzVcx7xYrMPsmua6Bk3z1D+087v=KNLjUG+DBw@mail.gmail.com"
type="cite">
<blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none;
padding: 0px;">
<div><br>
</div>
</blockquote>
<div>
<div>
<div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>public void attachSamlAssertion(Document document)</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>{</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>Element envelopeElmt =
document.getDocumentElement();</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>try</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>{</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(envelopeElmt);</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>XMLObject envelopeObj =
unmarshaller.unmarshall(envelopeElmt);</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>Envelope envelope = (Envelope) envelopeObj;</div>
<br>
<div><snip><br>
</div>
<br>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>Assertion assertion = newAssertion();</div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>security.getUnknownXMLObjects().add(assertion);</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<br>
Just insert a call to marshall the envelope XMLObject right here,
prior to signing. Much of that tree is alread marshalled, but the
new Security, Signature, etc that you've added are not, so (re-)
marshalling the whole Envelope XMLObject will take care of that.<br>
<br>
<br>
<blockquote
cite="mid:CAH2etF77T1xewzVcx7xYrMPsmua6Bk3z1D+087v=KNLjUG+DBw@mail.gmail.com"
type="cite">
<div>
<div>
<div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span>Signer.signObject(signature);</div>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<br>
<br>
<br>
<blockquote
cite="mid:CAH2etF77T1xewzVcx7xYrMPsmua6Bk3z1D+087v=KNLjUG+DBw@mail.gmail.com"
type="cite">
<div>
<div>
<div>Here's how I'm building the signature:
<div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
Off-hand, that looks ok.<br>
<br>
<br>
<br>
</body>
</html>