Search in sources :

Example 1 with Canonicalizer11_OmitComments

use of org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments in project santuario-java by apache.

the class TransformC14N11 method enginePerformTransform.

protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, OutputStream os, Transform transform) throws CanonicalizationException {
    Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
    c14n.setSecureValidation(secureValidation);
    if (os != null) {
        c14n.setWriter(os);
    }
    byte[] result = null;
    result = c14n.engineCanonicalize(input);
    XMLSignatureInput output = new XMLSignatureInput(result);
    output.setSecureValidation(secureValidation);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
Also used : Canonicalizer11_OmitComments(org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments) XMLSignatureInput(org.apache.xml.security.signature.XMLSignatureInput)

Example 2 with Canonicalizer11_OmitComments

use of org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments in project santuario-java by apache.

the class Santuario191Test method testSantuario191.

@org.junit.Test
public void testSantuario191() throws Exception {
    // 
    // Parse the Data
    // 
    db = XMLUtils.createDocumentBuilder(false);
    Document doc = null;
    try (InputStream is = new ByteArrayInputStream(INPUT_DATA.getBytes(StandardCharsets.UTF_8))) {
        doc = db.parse(is);
    }
    // 
    // Canonicalize the data
    // 
    NodeList dataNodes = doc.getElementsByTagName("data");
    Canonicalizer11_OmitComments c14ner = new Canonicalizer11_OmitComments();
    byte[] result = c14ner.engineCanonicalizeSubTree(dataNodes.item(0));
    // 
    // Test against expected result
    // 
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    out.write(result);
    assertTrue(EXPECTED_RESULT.equals(out.toString(StandardCharsets.UTF_8.name())));
}
Also used : Canonicalizer11_OmitComments(org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NodeList(org.w3c.dom.NodeList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.w3c.dom.Document)

Aggregations

Canonicalizer11_OmitComments (org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 XMLSignatureInput (org.apache.xml.security.signature.XMLSignatureInput)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1