Hi, I'm having some encryption problems... I'm trying to encrypt the contents of a SOAPBody of a SOAPEnvelope using TRIPLEDES and AES_128. I tryed to follow the steps of the example in
org.apache.xml.security.samples.encryption but I'm having problem in the some steps: 1. After the encryption how can I turn the resulting org.w3c.Document into a SOAPEnvelope or SOAPMessage to sendo it to the web service server??? I tryed this but it's not working... " org.w3c.dom.Document doc = soapEnv.getAsDocument(); Key symmetricKey = GenerateDataEncryptionKey(); Key kek = GenerateAndStoreKeyEncryptionKey(); String algorithmURI = XMLCipher.TRIPLEDES_KeyWrap; XMLCipher keyCipher = XMLCipher.getInstance(algorithmURI); keyCipher.init(XMLCipher.WRAP_MODE, kek); EncryptedKey encryptedKey = keyCipher.encryptKey(doc, symmetricKey); Element rootElement = doc.getDocumentElement(); algorithmURI = XMLCipher.AES_128; XMLCipher xmlCipher = XMLCipher.getInstance(algorithmURI); xmlCipher.init(XMLCipher.ENCRYPT_MODE, symmetricKey); EncryptedData encryptedData = xmlCipher.getEncryptedData(); KeyInfo keyInfo = new KeyInfo(doc); keyInfo.add(encryptedKey); encryptedData.setKeyInfo(keyInfo); //xmlCipher.doFinal(doc, rootElement, true); xmlCipher.doFinal(doc, doc); Canonicalizer c14n = Canonicalizer .getInstance(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS); byte[] canonicalMessage = c14n.canonicalizeSubtree(doc); InputStream is = new java.io.ByteArrayInputStream(canonicalMessage); SOAPEnvelope env = new SOAPEnvelope(is); " The exception is: org.xml.sax.SAXException: Bad envelope tag: EncryptedData Thanks in advance for the help... ============================================== Quia natura mutari non potest idcirco verae amicitiae sempiternae sunt - (Horace) RAFAEL J. DEITOS Automação - UFSC - Florianópolis - SC http://www.das.ufsc.br/~deitos ==============================================