1 17 package com.sun.org.apache.xml.internal.security.c14n; 18 19 20 21 import java.io.ByteArrayInputStream ; 22 import java.io.OutputStream ; 23 import java.util.Set ; 24 25 import javax.xml.parsers.DocumentBuilder ; 26 import javax.xml.parsers.DocumentBuilderFactory ; 27 28 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.Node ; 31 import org.w3c.dom.NodeList ; 32 import org.xml.sax.InputSource ; 33 34 35 41 public abstract class CanonicalizerSpi { 42 43 57 public byte[] engineCanonicalize(byte[] inputBytes) 58 throws javax.xml.parsers.ParserConfigurationException , 59 java.io.IOException , org.xml.sax.SAXException , 60 CanonicalizationException { 61 62 java.io.ByteArrayInputStream bais = new ByteArrayInputStream (inputBytes); 63 InputSource in = new InputSource (bais); 64 DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); 65 66 dfactory.setNamespaceAware(true); 68 69 DocumentBuilder db = dfactory.newDocumentBuilder(); 70 71 93 94 Document document = db.parse(in); 97 byte result[] = this.engineCanonicalizeSubTree(document); 98 return result; 99 } 100 101 108 public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet) 109 throws CanonicalizationException { 110 111 return this 112 .engineCanonicalizeXPathNodeSet(XMLUtils 113 .convertNodelistToSet(xpathNodeSet)); 114 } 115 116 124 public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet, String inclusiveNamespaces) 125 throws CanonicalizationException { 126 127 return this 128 .engineCanonicalizeXPathNodeSet(XMLUtils 129 .convertNodelistToSet(xpathNodeSet), inclusiveNamespaces); 130 } 131 132 136 public abstract String engineGetURI(); 137 138 141 public abstract boolean engineGetIncludeComments(); 142 143 150 public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet) 151 throws CanonicalizationException; 152 153 161 public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces) 162 throws CanonicalizationException; 163 164 171 public abstract byte[] engineCanonicalizeSubTree(Node rootNode) 172 throws CanonicalizationException; 173 174 182 public abstract byte[] engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces) 183 throws CanonicalizationException; 184 185 190 public abstract void setWriter(OutputStream os); 191 192 193 protected boolean reset=false; 194 } 196 | Popular Tags |