Author: veithen Date: Tue Jan 24 07:06:57 2012 New Revision: 1235143 URL: http://svn.apache.org/viewvc?rev=1235143&view=rev Log: Merged r1090540 and r1235059 to the 1.6 branch.
Modified: axis/axis2/java/rampart/branches/1_6/ (props changed) axis/axis2/java/rampart/branches/1_6/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java Propchange: axis/axis2/java/rampart/branches/1_6/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jan 24 07:06:57 2012 @@ -1 +1 @@ -/axis/axis2/java/rampart/trunk:1072266-1072267,1072300,1072313-1072314,1072316,1072321,1072324,1073746,1074043,1074447,1074534,1075676,1075683-1075684,1083686,1087998,1088013,1088558,1088571,1089599,1129515,1129552,1130570,1131278,1132548,1132564,1134446,1134683,1137396,1144616,1157613,1157670,1157672,1157674,1157724,1157731,1172842,1175271,1175324,1177260,1177279,1177413,1178193,1186491,1190533,1190600,1194848,1194994,1220915,1221926,1221937,1221940,1222136,1222418 +/axis/axis2/java/rampart/trunk:1072266-1072267,1072300,1072313-1072314,1072316,1072321,1072324,1073746,1074043,1074447,1074534,1075676,1075683-1075684,1083686,1087998,1088013,1088558,1088571,1089599,1090540,1129515,1129552,1130570,1131278,1132548,1132564,1134446,1134683,1137396,1144616,1157613,1157670,1157672,1157674,1157724,1157731,1172842,1175271,1175324,1177260,1177279,1177413,1178193,1186491,1190533,1190600,1194848,1194994,1220915,1221926,1221937,1221940,1222136,1222418,1235059 Modified: axis/axis2/java/rampart/branches/1_6/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/1_6/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java?rev=1235143&r1=1235142&r2=1235143&view=diff ============================================================================== --- axis/axis2/java/rampart/branches/1_6/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java (original) +++ axis/axis2/java/rampart/branches/1_6/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java Tue Jan 24 07:06:57 2012 @@ -37,6 +37,7 @@ import org.apache.axiom.soap.impl.dom.fa import org.apache.rampart.handler.WSSHandlerConstants; import org.apache.ws.security.WSSecurityException; import org.apache.xml.security.utils.XMLUtils; +import org.w3c.dom.DOMConfiguration; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -90,7 +91,35 @@ public class Axis2Util { throws WSSecurityException { try { if(env instanceof Element) { - return ((Element)env).getOwnerDocument(); + Element element = (Element)env; + Document document = element.getOwnerDocument(); + // For outgoing messages, Axis2 only creates the SOAPEnvelope, but no document. If + // the Axiom implementation also supports DOM, then the envelope (seen as a DOM + // element) will have an owner document, but the document and the envelope have no + // parent-child relationship. On the other hand, the input expected by WSS4J is + // a document with the envelope as document element. Therefore we need to set the + // envelope as document element on the owner document. + if (element.getParentNode() != document) { + document.appendChild(element); + } + // If the Axiom implementation supports DOM, then it is possible/likely that the + // DOM API was used to create the object model (or parts of it). In this case, the + // object model is not necessarily well formed with respect to namespaces because + // DOM doesn't generate namespace declarations automatically. This is an issue + // because WSS4J/Santuario expects that all namespace declarations are present. + // If this is not the case, then signature values or encryptions will be incorrect. + // To avoid this, we normalize the document. Note that if we disable the other + // normalizations supported by DOM, this is generally not a heavy operation. + // In particular, the Axiom implementation is not required to expand the object + // model (including OMSourcedElements) because the Axiom builder is required to + // perform namespace repairing, so that no modifications to unexpanded parts of + // the message are required. + DOMConfiguration domConfig = document.getDomConfig(); + domConfig.setParameter("split-cdata-sections", Boolean.FALSE); + domConfig.setParameter("well-formed", Boolean.FALSE); + domConfig.setParameter("namespaces", Boolean.TRUE); + document.normalizeDocument(); + return document; } if (useDoom) {