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;
}
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())));
}
Aggregations