Package org.apache.xml.security.encryption

Examples of org.apache.xml.security.encryption.XMLCipher.doFinal()


    if (content) {
      encBodyData = (Element) encBodyData.getParentNode();
    }
    try {
      xmlCipher.doFinal(doc, encBodyData, content);
    } catch (Exception e) {
      throw new WSSecurityException(WSSecurityException.FAILED_ENC_DEC,
          null, null, e);
    }
  }
View Full Code Here


            encBodyData = (Element) encBodyData.getParentNode();
        }
        final Node parent = encBodyData.getParentNode();
        final java.util.List before_peers = listChildren(parent);
        try {
            xmlCipher.doFinal(doc, encBodyData, content);
        } catch (Exception e1) {
            throw new WSSecurityException(WSSecurityException.FAILED_ENC_DEC, null, null, e1);
        }
        final java.util.List after_peers = listChildren(parent);
        final java.util.List new_nodes = newNodes(before_peers, after_peers);
View Full Code Here

  XMLCipher dataCipher = XMLCipher.getInstance(XMLCipher.TRIPLEDES);
  dataCipher.init(XMLCipher.ENCRYPT_MODE, secretKey);

  for (int i = 0; i < dataToEncrypt.getLength(); i++) {
          dataCipher.doFinal(doc,(Element) dataToEncrypt.item(i), true);
  }

  // Check that user content has been removed
  Element user = (Element) dataToEncrypt.item(0);
        Node child = user.getFirstChild();
View Full Code Here

        EncryptedData encryptedData = dataCipher.getEncryptedData();
        encryptedData.setKeyInfo(keyInfo);
       
        for (int i = 0; i < dataToEncrypt.getLength(); i++) {
            dataCipher.doFinal(doc,(Element) dataToEncrypt.item(i), true);
        }

        NodeList keyInfoList = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "KeyInfo");
        assertEquals(keyInfoList.getLength(), 2);
    }
View Full Code Here

            String expression = "//*[local-name()='" + localName + "']";
            Element elementToEncrypt =
                (Element) xpath.evaluate(expression, document, XPathConstants.NODE);
            Assert.assertNotNull(elementToEncrypt);

            document = cipher.doFinal(document, elementToEncrypt, false);
        }

        NodeList nodeList = document.getElementsByTagNameNS(
            XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
            XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
View Full Code Here

            encData = (Element) encData.getParentNode();
            parent = encData.getParentNode();
        }
       
        try {
            xmlCipher.doFinal(doc, encData, content);
        } catch (Exception ex) {
            throw new WSSecurityException(WSSecurityException.FAILED_CHECK, null, null, ex);
        }
       
        if (parent.getLocalName().equals(WSConstants.ENCRYPTED_HEADER)
View Full Code Here

      String encryptionAlgorithm = XMLEncryptionUtil.getXMLEncryptionURL(secretKey.getAlgorithm(), keySize);
      //Encrypt the Document
      cipher = XMLCipher.getInstance(encryptionAlgorithm);
      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
View Full Code Here

      }

      // Create a new cipher just to be paranoid
      XMLCipher cipher3 = XMLCipher.getInstance();
      cipher3.init(XMLCipher.DECRYPT_MODE, key);
            dd = cipher3.doFinal(ed, ee);

            target = toString(dd);

      Assert.assertEquals(source, target);
    }
View Full Code Here

              
        // encrypt payloadDoc
        XMLCipher xmlCipher =
            EncryptionUtils.initXMLCipher(symEncAlgo, XMLCipher.ENCRYPT_MODE, symmetricKey);
       
        Document result = xmlCipher.doFinal(payloadDoc, payloadDoc.getDocumentElement(), false);
        NodeList list = result.getElementsByTagNameNS(WSConstants.ENC_NS, "CipherValue");
        if (list.getLength() != 1) {
            throw new Exception("Payload CipherData is missing");
        }
        String cipherText = ((Element)list.item(0)).getTextContent().trim();
View Full Code Here

            try {
                xmlCipher.init(XMLCipher.ENCRYPT_MODE, encryptionKey);
                EncryptedData encData = xmlCipher.getEncryptedData();
                encData.setId(xencEncryptedDataId);
                encData.setKeyInfo(keyInfo);
                xmlCipher.doFinal(doc, body, content);
            } catch (Exception e2) {
                throw new WSSecurityException(WSSecurityException.FAILED_ENC_DEC, null, null, e2);
            }
            encDataRefs.add(new String("#" + xencEncryptedDataId));
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.