private void cloneElement(Element element) throws WSSecurityException { if (expandXopInclude) { // Look for xop:Include Nodes List<Element> includeElements = XMLUtils.findElements(element.getFirstChild(), "Include", WSConstants.XOP_NS); if (includeElements != null && !includeElements.isEmpty()) { // Clone the Element to be signed + insert the clone into the tree at the same level // We will expand the xop:Include for one of the nodes + sign that (and then remove it), // while leaving the original in the tree to be sent in the message clonedElements.add(element); Document doc = this.getSecurityHeader().getSecurityHeaderDoc(); element.getParentNode().appendChild(WSSecurityUtil.cloneElement(doc, element)); WSSecurityUtil.inlineAttachments(includeElements, attachmentCallbackHandler, false); } } }
encryptedData.appendChild(WSSecurityUtil.cloneElement(doc, keyInfo.getElement()));
encryptedData.appendChild(WSSecurityUtil.cloneElement(doc, keyInfo.getElement()));