java.lang.Object
com.inductiveautomation.ignition.common.XMLUtil

public class XMLUtil extends Object
  • Field Details

    • dateFormat

      public static final DateFormat dateFormat
  • Constructor Details

    • XMLUtil

      public XMLUtil()
  • Method Details

    • createSafeDocumentBuilderFactory

      public static DocumentBuilderFactory createSafeDocumentBuilderFactory()
      The createSafeDocumentBuilderFactory() method returns a new DocumentBuilderFactory Instance that has been configured to prevent XXE attacks possible through weakly configured XML parsers processing external entities.

      See: https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing for more info

    • createSafeTransformerFactory

      public static TransformerFactory createSafeTransformerFactory()
    • createSafeSAXParserFactory

      public static SAXParserFactory createSafeSAXParserFactory()
      The createSafeSAXParserFactory() method returns a new DocumentBuilderFactory Instance that has been configured to prevent XXE attacks possible through weakly configured XML parsers processing external entities.

      See: https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing for more info

    • createSafeXMLReader

      public static XMLReader createSafeXMLReader() throws SAXException
      The createSafeXMLReader() method returns a new XMLReader Instance that has been configured to prevent XXE attacks possible through weakly configured XML parsers processing external entities.

      See: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xmlreader for more info

      Calls XMLReaderFactory.createXMLReader()

      Throws:
      SAXException
    • createSafeXMLReader

      public static XMLReader createSafeXMLReader(String className) throws SAXException
      The createSafeXMLReader() method returns a new XMLReader Instance that has been configured to prevent XXE attacks possible through weakly configured XML parsers processing external entities.

      See: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xmlreader for more info

      Calls XMLReaderFactory.createXMLReader(String) and provides the given className

      Throws:
      SAXException
    • setSafetyFeatures

      public static void setSafetyFeatures(XMLReader reader)
      Sets safety features on the provided XMLReader instance

      See: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xmlreader for more info

    • printXMLHead

      public static void printXMLHead(Writer out) throws IOException
      Throws:
      IOException
    • printXMLHead

      public static void printXMLHead(PrintWriter out)
    • printXMLHead

      public static void printXMLHead(Formatter out)
    • printXMLHead

      public static void printXMLHead(StringBuilder out)
    • openElement

      public static void openElement(PrintWriter out, String element)
      Writes <element>
    • closeElement

      public static void closeElement(PrintWriter out, String element)
      Writes </element>
    • writeElement

      public static void writeElement(PrintWriter out, String element, String contents)
      Writes <element>contents</element> , quoting the contents. If contents is null, writes <element/>
    • main

      public static void main(String[] args)
    • quoteCharacters

      public static String quoteCharacters(String s)