cipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
Document encryptedDoc = cipher.doFinal(document, document.getDocumentElement());
Element encryptedDocRootElement = encryptedDoc.getDocumentElement();
// The EncryptedKey element is added
Element encryptedKeyElement = cipher.martial(document, ekey);
// Outer ds:KeyInfo Element to hold the EncryptionKey
Element sigElement = encryptedDoc.createElementNS(XMLSIG_NS, DS_KEY_INFO);
sigElement.setAttributeNS(XMLNS, "xmlns:ds", XMLSIG_NS);
sigElement.appendChild(encryptedKeyElement);