Skip to Content.
Sympa Menu

mace-opensaml-users - Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion

Subject: OpenSAML user discussion

List archive

Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion


Chronological Thread 
  • From: Chad La Joie <>
  • To:
  • Subject: Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion
  • Date: Tue, 14 Jul 2009 16:36:13 +0200
  • Organization: SWITCH

About the only way to move between XML libraries with different object models (and AXIOM is *not* DOM) is to write the XML out to a string from one model and read it back in to the other model.

Thilina Mahesh Buddhika wrote:
hi all,

I am trying to sign a SAML 2.0 assertion built using OpenSAML2.0 library. In
this assertion, I am using holder-of-key subject confirmation method. In
subjectConfirmationData element, I am adding a <ds:keyInfo> element to it. I
use Axiom to build this keyInfo element. Then I am unmarshelling that
keyinfo element to an XMLObject by using the following code snippet.


---------------------------------------------------------------------------------
UnmarshallerFactory unmarshallerFactory =
Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller =
unmarshallerFactory.getUnmarshaller(keyInfoElem);

// Unmarshall using the document root element, an EntitiesDescriptor
in this case
XMLObject keyInfoElement = null;
try {
keyInfoElement = unmarshaller.unmarshall(keyInfoElem);
} catch (UnmarshallingException e) {
throw new TrustException("Error unmarshalling KeyInfo Element",
e);
}

----------------------------------------------------------------------

Then I am adding this element into a KeyInfoConfirmationDataType element.

When I am trying to sign the resulting SAML assertion I am hitting with an
exception as stated in subject. The StackTrace is as follows.


org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed
at org.opensaml.xml.util.XMLHelper.adoptElement(XMLHelper.java:482)
at
org.opensaml.xml.util.XMLHelper.appendChildElement(XMLHelper.java:467)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:161)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallChildElements(AbstractXMLObjectMarshaller.java:316)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallInto(AbstractXMLObjectMarshaller.java:224)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:175)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallChildElements(AbstractXMLObjectMarshaller.java:316)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallInto(AbstractXMLObjectMarshaller.java:224)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:175)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallChildElements(AbstractXMLObjectMarshaller.java:316)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallInto(AbstractXMLObjectMarshaller.java:224)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:175)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallChildElements(AbstractXMLObjectMarshaller.java:316)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallInto(AbstractXMLObjectMarshaller.java:224)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:130)
at
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:86)
at
org.apache.rahas.impl.SAML2TokenIssuer.setSignature(SAML2TokenIssuer.java:461)


When I went through the code of XMLHelper, I found that this error is due to
the use of two different dom implementations of adaper and adaptee elements.

/**
* Adopts an element into a document if the child is not already in the
document.
*
* @param adoptee the element to be adopted
* @param adopter the document into which the element is adopted
*/
public static void adoptElement(Element adoptee, Document adopter) {
if (!(adoptee.getOwnerDocument().equals(adopter))) {
if (adopter.adoptNode(adoptee) == null) {
// This can happen if the adopter and adoptee were produced
by different DOM implementations
throw new XMLRuntimeException("DOM Element node adoption
failed");
}
}
}

I guess this is due to the fact that I am using axiom to build the keyInfo
element. Due to some constraints, I am keen on keeping the Axiom involvement
as it is.

Is there any workaround for this ?

Thanks in advance.

best regards,
/thilina


E-Mail :

I blog here : http://thilinamb.com


--
SWITCH
Serving Swiss Universities
--------------------------
Chad La Joie, Software Engineer, Net Services
Werdstrasse 2, P.O. Box, 8021 Zürich, Switzerland
phone +41 44 268 15 75, fax +41 44 268 15 68
,
http://www.switch.ch




Archive powered by MHonArc 2.6.16.

Top of Page