Package gw.xml.simple

Class SimpleXmlParser


  • public class SimpleXmlParser
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.ThreadLocal<javax.xml.parsers.SAXParser> _saxParser  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SimpleXmlParser()  
    • Field Detail

      • _saxParser

        private static java.lang.ThreadLocal<javax.xml.parsers.SAXParser> _saxParser
    • Constructor Detail

      • SimpleXmlParser

        private SimpleXmlParser()
    • Method Detail

      • parseFile

        public static SimpleXmlNode parseFile​(java.io.File file)
      • parseInputStream

        public static SimpleXmlNode parseInputStream​(java.io.InputStream stream)
      • parseString

        public static SimpleXmlNode parseString​(java.lang.String s)
      • maybeWrapException

        private static java.lang.RuntimeException maybeWrapException​(java.lang.Exception e)
      • makeSAXParser

        private static javax.xml.parsers.SAXParser makeSAXParser()
                                                          throws javax.xml.parsers.ParserConfigurationException,
                                                                 org.xml.sax.SAXException
        Throws:
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
      • disableExternalEntities

        private static void disableExternalEntities​(javax.xml.parsers.SAXParserFactory factory)
                                             throws javax.xml.parsers.ParserConfigurationException,
                                                    org.xml.sax.SAXNotRecognizedException,
                                                    org.xml.sax.SAXNotSupportedException
        The purpose of this method is to prevent vulnerabilities related to XXE (XML external entity injection). Although the nature of XML parsing in this case is such that it is _not_ vulnerable, we configure the parser in this way to appease those who demand zero alarm results from static analysis tooling such as Veracode.
        Throws:
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException