mace-opensaml-users - Issues marshalling XmlObject with DOM without namespace
Subject: OpenSAML user discussion
List archive
- From: "Stepan Hrbacek" <>
- To:
- Subject: Issues marshalling XmlObject with DOM without namespace
- Date: Mon, 1 Dec 2008 08:43:53 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=RijKiOnQP3mLiqGb1i6aHWtSrf99CLEP0w6VHaY5dHJ1VlqSk1t4YI8vmGAqlBY9Kp NH4AdSfXwr6dS9NvHcQ2bDnBA1LFFxq4yYH/sHeK18wV2HUTnI7Nop/qa+L/gkNH/RhJ QNUXzM8ZVIpbdPFuRIzkt6bjswDIXkhVWrPnE=
Hi,
I use OpenSAML 2.2.2 for creating SAML 1.1/2.0 assertions with attribute statements containing complex attribute values (XML elements). Recently I have experienced issue marshalling attribute values containing XML elements without namespace (but valid XML data).
Following test shows it:
=================
public void testMarshallWithoutNamespaceUseXSAnyUnmarshallerSaml1()
throws ParsingException, SAXException, IOException,
ParserConfigurationException, MarshallingException,
ConfigurationException, UnmarshallingException {
org.opensaml.DefaultBootstrap.bootstrap();
javax.xml.parsers.DocumentBuilderFactory docBldrFact = javax.xml.parsers.DocumentBuilderFactory.newInstance();
docBldrFact.setNamespaceAware(true);
org.w3c.dom.Element valueElem = docBldrFact.newDocumentBuilder().parse(new org.xml.sax.InputSource(new java.io.StringReader("<value/>"))).getDocumentElement();
org.opensaml.xml.io.Unmarshaller unmarshaller = new org.opensaml.xml.schema.impl.XSAnyUnmarshaller();
org.opensaml.xml.XMLObject valueXmlObj = unmarshaller.unmarshall(valueElem);
org.opensaml.xml.XMLObjectBuilder xmlObjectBilder = new org.opensaml.xml.schema.impl.XSAnyBuilder();
org.opensaml.xml.ElementExtensibleXMLObject attrValueXmlObj = (org.opensaml.xml.ElementExtensibleXMLObject) xmlObjectBilder.buildObject(org.opensaml.saml1.core.AttributeValue.DEFAULT_ELEMENT_NAME);
attrValueXmlObj.getUnknownXMLObjects().add(valueXmlObj);
org.opensaml.saml1.core.Attribute attrXmlObj = ((org.opensaml.saml1.core.impl.AttributeBuilder) org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(
org.opensaml.saml1.core.Attribute.DEFAULT_ELEMENT_NAME)).buildObject();
attrXmlObj.setAttributeName("aaa");
attrXmlObj.setAttributeNamespace("bbb");
attrXmlObj.getAttributeValues().add(attrValueXmlObj);
org.opensaml.xml.io.Marshaller marshaller = org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(attrXmlObj.getElementQName());
org.w3c.dom.Element domObj = marshaller.marshall(attrXmlObj);
}
org.opensaml.DefaultBootstrap.bootstrap();
javax.xml.parsers.DocumentBuilderFactory docBldrFact = javax.xml.parsers.DocumentBuilderFactory.newInstance();
docBldrFact.setNamespaceAware(true);
org.w3c.dom.Element valueElem = docBldrFact.newDocumentBuilder().parse(new org.xml.sax.InputSource(new java.io.StringReader("<value/>"))).getDocumentElement();
org.opensaml.xml.io.Unmarshaller unmarshaller = new org.opensaml.xml.schema.impl.XSAnyUnmarshaller();
org.opensaml.xml.XMLObject valueXmlObj = unmarshaller.unmarshall(valueElem);
org.opensaml.xml.XMLObjectBuilder xmlObjectBilder = new org.opensaml.xml.schema.impl.XSAnyBuilder();
org.opensaml.xml.ElementExtensibleXMLObject attrValueXmlObj = (org.opensaml.xml.ElementExtensibleXMLObject) xmlObjectBilder.buildObject(org.opensaml.saml1.core.AttributeValue.DEFAULT_ELEMENT_NAME);
attrValueXmlObj.getUnknownXMLObjects().add(valueXmlObj);
org.opensaml.saml1.core.Attribute attrXmlObj = ((org.opensaml.saml1.core.impl.AttributeBuilder) org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(
org.opensaml.saml1.core.Attribute.DEFAULT_ELEMENT_NAME)).buildObject();
attrXmlObj.setAttributeName("aaa");
attrXmlObj.setAttributeNamespace("bbb");
attrXmlObj.getAttributeValues().add(attrValueXmlObj);
org.opensaml.xml.io.Marshaller marshaller = org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(attrXmlObj.getElementQName());
org.w3c.dom.Element domObj = marshaller.marshall(attrXmlObj);
}
During an execution of this test I get following exception:
=========================================
org.opensaml.xml.io.MarshallingException: Unable to root namespaces of cached DOM element, value
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.prepareForAdoption(AbstractXMLObjectMarshaller.java:446)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:157)
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 A.testMarshallWithoutNamespaceUseXSAnyUnmarshallerSaml1(A.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.opensaml.xml.parse.XMLParserException: Unable to resolve namespace prefix null found on element value
at org.opensaml.xml.util.XMLHelper.rootNamespaces(XMLHelper.java:897)
at org.opensaml.xml.util.XMLHelper.rootNamespaces(XMLHelper.java:870)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.prepareForAdoption(AbstractXMLObjectMarshaller.java:441)
... 27 more
First I have reported this as a bug https://bugs.internet2.edu/jira/browse/JXT-42, but this was closed as invalid because the way I use to create the complex attribute value is not supported by OpenSAML / XmlTooling.at org.opensaml.xml.io.AbstractXMLObjectMarshaller.prepareForAdoption(AbstractXMLObjectMarshaller.java:446)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:157)
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 A.testMarshallWithoutNamespaceUseXSAnyUnmarshallerSaml1(A.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.opensaml.xml.parse.XMLParserException: Unable to resolve namespace prefix null found on element value
at org.opensaml.xml.util.XMLHelper.rootNamespaces(XMLHelper.java:897)
at org.opensaml.xml.util.XMLHelper.rootNamespaces(XMLHelper.java:870)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.prepareForAdoption(AbstractXMLObjectMarshaller.java:441)
... 27 more
Could you please give me a hint how to perform the above stated use case in a supported way and without marshalling issues?
Thank you
Stepan
- Issues marshalling XmlObject with DOM without namespace, Stepan Hrbacek, 12/01/2008
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Brent Putman, 12/03/2008
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Stepan Hrbacek, 12/04/2008
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Chad La Joie, 12/04/2008
- RE: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Scott Cantor, 12/04/2008
- Message not available
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Stepan Hrbacek, 12/04/2008
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Stepan Hrbacek, 12/04/2008
- Re: [OpenSAML] Issues marshalling XmlObject with DOM without namespace, Brent Putman, 12/03/2008
Archive powered by MHonArc 2.6.16.