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: Thilina Mahesh Buddhika <>
- To:
- Subject: Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion
- Date: Wed, 15 Jul 2009 11:05:18 +0530
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=CX2M2WfgFNdEHl9muGD2w5pZdG9yxcn1cGHV3kT3zkBgwFFB8Nz2H5kWvgvsSIV/oZ CJ9Nqdbx7CPonzLoCPU1utTjQMWbBe2cqT4NyygRawQ0nIJxMPwjlDyayEx/kacoiq87 yJr8bQtb1u4jJ2vrNIMKH+FaqLtPKeXO2mEcM=
Thanks Chad. It solved my problem.
best regards,
/thilina
E-Mail :
I blog here : http://thilinamb.com
On Tue, Jul 14, 2009 at 8:06 PM, Chad La Joie <> wrote:
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
- org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion, Thilina Mahesh Buddhika, 07/14/2009
- Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion, Chad La Joie, 07/14/2009
- Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion, Thilina Mahesh Buddhika, 07/15/2009
- Re: [OpenSAML] org.opensaml.xml.XMLRuntimeException: DOM Element node adoption failed thrown when signing the assertion, Chad La Joie, 07/14/2009
Archive powered by MHonArc 2.6.16.