if (input.isOctetStream()) {
try {
byte[] base64Bytes = input.getBytes();
byte[] decodedBytes = Base64.decode(base64Bytes);
return new XMLSignatureInput(
new ByteArrayInputStream(decodedBytes));
} catch (Base64DecodingException ex) {
throw new TransformationException("empty", ex);
}
} else {
try {
Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(input.getOctetStream());
DocumentTraversal dt = ((DocumentTraversal) doc);
Node rootNode = (Node) doc;
// we accept all nodes
NodeFilter nodefilter =
new org.apache.xml.security.c14n.helper.AlwaysAcceptNodeFilter();
TreeWalker treewalker = dt.createTreeWalker(rootNode,
NodeFilter.SHOW_ALL,
nodefilter, true);
StringBuffer sb = new StringBuffer();
process(treewalker, sb);
byte[] decodedBytes = Base64.decode(sb.toString());
return new XMLSignatureInput(
new ByteArrayInputStream(decodedBytes));
} catch (ParserConfigurationException e) {
throw new TransformationException("c14n.Canonicalizer.Exception",
e);
} catch (SAXException e) {