24 |
24 |
25 import java.io.BufferedInputStream; |
25 import java.io.BufferedInputStream; |
26 import java.io.IOException; |
26 import java.io.IOException; |
27 import java.io.OutputStream; |
27 import java.io.OutputStream; |
28 |
28 |
|
29 import javax.xml.XMLConstants; |
29 import javax.xml.parsers.DocumentBuilderFactory; |
30 import javax.xml.parsers.DocumentBuilderFactory; |
30 import javax.xml.parsers.ParserConfigurationException; |
31 import javax.xml.parsers.ParserConfigurationException; |
31 |
32 |
32 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
33 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
33 import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; |
34 import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; |
143 |
144 |
144 |
145 |
145 } |
146 } |
146 |
147 |
147 try { |
148 try { |
148 //Exceptional case there is current not text case testing this(Before it was a |
149 // Exceptional case there is current not text case testing this |
149 //a common case). |
150 // (before it was a a common case). |
|
151 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
|
152 dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, |
|
153 Boolean.TRUE); |
150 Document doc = |
154 Document doc = |
151 DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( |
155 dbf.newDocumentBuilder().parse(input.getOctetStream()); |
152 input.getOctetStream()); |
|
153 |
156 |
154 Element rootNode = doc.getDocumentElement(); |
157 Element rootNode = doc.getDocumentElement(); |
155 StringBuffer sb = new StringBuffer(); |
158 StringBuffer sb = new StringBuffer(); |
156 traverseElement(rootNode,sb); |
159 traverseElement(rootNode,sb); |
157 byte[] decodedBytes = Base64.decode(sb.toString()); |
160 byte[] decodedBytes = Base64.decode(sb.toString()); |
158 |
161 |
159 return new XMLSignatureInput(decodedBytes); |
162 return new XMLSignatureInput(decodedBytes); |
160 } catch (ParserConfigurationException e) { |
163 } catch (ParserConfigurationException e) { |
161 throw new TransformationException("c14n.Canonicalizer.Exception",e); |
164 throw new TransformationException("c14n.Canonicalizer.Exception",e); |
162 } catch (SAXException e) { |
165 } catch (SAXException e) { |
163 throw new TransformationException("SAX exception", e); |
166 throw new TransformationException("SAX exception", e); |
164 } |
167 } |
165 } catch (Base64DecodingException e) { |
168 } catch (Base64DecodingException e) { |
166 throw new TransformationException("Base64Decoding", e); |
169 throw new TransformationException("Base64Decoding", e); |
167 } |
170 } |
168 } |
171 } |
169 |
172 |
170 void traverseElement(org.w3c.dom.Element node,StringBuffer sb) { |
173 void traverseElement(org.w3c.dom.Element node,StringBuffer sb) { |
171 Node sibling=node.getFirstChild(); |
174 Node sibling=node.getFirstChild(); |