Package org.apache.xml.security.encryption

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


        NodeList nodeList = document.getElementsByTagNameNS(
                XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
                XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
        );
        Element ee = (Element) nodeList.item(0);
        return cipher.doFinal(document, ee);
    }

    private TestSecurityEventListener verifyUsingStAX(
            byte[] doc, Key decryptionKey, PublicKey signatureVerificationKey) throws Exception {
        return verifyUsingStAX(new ByteArrayInputStream(doc), decryptionKey, signatureVerificationKey);
View Full Code Here


        NodeList nodeList = document.getElementsByTagNameNS(
                XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
                XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
            );
        Element ee = (Element)nodeList.item(0);
        return cipher.doFinal(document, ee);
    }

}
View Full Code Here

        DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
        Document document = builder.parse(file);

        XMLCipher cipher = XMLCipher.getInstance("http://www.w3.org/2001/04/xmlenc#aes256-cbc");
        cipher.init(XMLCipher.ENCRYPT_MODE, encryptionSymKey);
        document = cipher.doFinal(document, document.getDocumentElement());

        XMLUtils.outputDOM(document, new BufferedOutputStream(new FileOutputStream(new File(getTmpFilePath(), "encryption-dom-" + tagCount + ".xml"))));
    }

    protected void doDOMDecryptionInbound(File file, int tagCount) throws Exception {
View Full Code Here

        DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
        Document document = builder.parse(file);

        XMLCipher cipher = XMLCipher.getInstance("http://www.w3.org/2001/04/xmlenc#aes256-cbc");
        cipher.init(XMLCipher.DECRYPT_MODE, encryptionSymKey);
        cipher.doFinal(document, document.getDocumentElement());
    }
}
View Full Code Here

        Key dek = options.getDataEncryptionKey();
        org.w3c.dom.Element element = dom.getDocumentElement();
        XMLCipher xmlCipher = XMLCipher.getInstance();
        xmlCipher.init(XMLCipher.DECRYPT_MODE, dek);
        xmlCipher.setKEK(kek);
        dom = xmlCipher.doFinal(dom, element);
        return domToFom(dom, options);
      } catch (Exception e) {
        throw new SecurityException(e);
      }
  }
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 WSSecurityException("Payload CipherData is missing", null);
        }
        String cipherText = ((Element)list.item(0)).getTextContent().trim();
View Full Code Here

        XMLCipher xmlCipher = XMLCipher.getInstance(xmlCipherAlgorithm);
        xmlCipher.init(XMLCipher.ENCRYPT_MODE, dataEncryptionKey);

        if (secureTag.equalsIgnoreCase("")) {
            embedKeyInfoInEncryptedData(document, keyCipher, xmlCipher, dataEncryptionKey);
            document = xmlCipher.doFinal(document, document.getDocumentElement());
        } else {
                         
            XPathBuilder xpathBuilder = new XPathBuilder(secureTag);
            xpathBuilder.setNamespaceContext(getNamespaceContext());
            NodeList nodeList = xpathBuilder.evaluate(exchange, NodeList.class);
View Full Code Here

           
            for (int i = 0; i < nodeList.getLength(); i++) {
                Node node = nodeList.item(i);
                document = node.getOwnerDocument();
                embedKeyInfoInEncryptedData(node.getOwnerDocument(), keyCipher, xmlCipher, dataEncryptionKey);
                Document temp = xmlCipher.doFinal(node.getOwnerDocument(), (Element) node, getSecureTagContents());
                document.importNode(temp.getDocumentElement().cloneNode(true), true);
            }   
        }

        try {
View Full Code Here

        xmlCipher.init(XMLCipher.DECRYPT_MODE, null);
        xmlCipher.setKEK(keyEncryptionKey);

        if (secureTag.equalsIgnoreCase("")) {
            checkEncryptionAlgorithm(keyEncryptionKey, encodedDocument.getDocumentElement());
            encodedDocument = xmlCipher.doFinal(encodedDocument, encodedDocument.getDocumentElement());
        } else {

            XPathBuilder xpathBuilder = new XPathBuilder(secureTag);
            xpathBuilder.setNamespaceContext(getNamespaceContext());
            NodeList nodeList = xpathBuilder.evaluate(exchange, NodeList.class);
View Full Code Here

            for (int i = 0; i < nodeList.getLength(); i++) {
                Node node = nodeList.item(i);
                encodedDocument = node.getOwnerDocument();
                if (getSecureTagContents()) {
                    checkEncryptionAlgorithm(keyEncryptionKey, (Element)node);
                    Document temp = xmlCipher.doFinal(encodedDocument, (Element) node, true);
                    encodedDocument.importNode(temp.getDocumentElement().cloneNode(true), true);
                } else {
                    NodeList childNodes = node.getChildNodes();
                    for (int j = 0; j < childNodes.getLength(); j++) {
                        Node childNode = childNodes.item(j);
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.