Skip to Content.
Sympa Menu

mace-opensaml-users - Re: [OpenSAML] SAMLResponse signature verification

Subject: OpenSAML user discussion

List archive

Re: [OpenSAML] SAMLResponse signature verification


Chronological Thread 
  • From: Brent Putman <>
  • To:
  • Subject: Re: [OpenSAML] SAMLResponse signature verification
  • Date: Wed, 10 Mar 2010 18:21:46 -0500



On 3/10/10 3:26 AM, JC Estienney wrote:
>
>
> // Preparation de la deserialisation de la racine du doc
> Unmarshaller unmarshaller =
> unmarshallerFactory.getUnmarshaller(racine);
>
> Response reponseSAML = (Response)
> unmarshaller.unmarshall(racine);
> System.out.println("Destination : " +
> reponseSAML.getDestination());
>
> System.out.println(XMLHelper.prettyPrintXML(reponseSAML.getDOM()));
>
> System.out.println(XMLHelper.prettyPrintXML(reponseSAML.getSignature().getDOM()));
> Assertion assertion =
> (Assertion)reponseSAML.getAssertions().get(0);
> //Validation structurelle de l'assertion SAML
> assertion.validate(true);
> AssertionMarshaller marshaller = new AssertionMarshaller();
> // HERE IS THE PB
> Element element = marshaller.marshall(assertion);
> // THE object reponseSAML is altered
> System.out.println(XMLHelper.prettyPrintXML(element));
>
>


Ah! Ok, now I see what is going on. Yes, that marshalling operation on
the Assertion is absolutely causing that weird behavior of the Response
with the missing Assertion. The reason: The single-arg
marshall(XMLObject) method impl actually marshalls the XMLObject into a
newly constructed Document. If the XMLObject is already marshalled,
it's not a no-op as you might think, it actually winds up
unconditionally adopting the DOM Element subtree into the new Document,
which removes it from the original DOM tree. Off-hand, I don't know why
the marshaller always unconditionally marshalls into a new Document like
that, rather than detecting whether the target is already marshalled.
Chad might be able to comment further, but it's possible we might need
to look at changing that behavior, or at least provide some option for
not doing that, like an overloaded marshall(XMLObject target, boolean
newDocumentIfAlreadyMarshalled) or something similar. At the very least,
unnecessarily adopting into a new Document is somewhat expensive.

In any case, you probably realize that you don't really need to
re-marshall there, since you just unmarshalled the object, and so it
already has a DOM. Although this perhaps highlights a similar issue
with the API - it nominally wasn't intended that people call getDOM() to
get the XMLObject's Element, but instead call marshall(XMLObject) - but
if marshall() always has potentially unwanted side-effects as it does,
then that's a problem too. For now I suppose the only option is just
use getDOM(), if you need a sub-Element from an already marshalled (or
unmarshalled) tree.

--Brent



Archive powered by MHonArc 2.6.16.

Top of Page