Class XMLUtils


  • public final class XMLUtils
    extends Object
    Utility classes for handling XML.
    • Method Detail

      • getSafeDocumentBuilder

        public static DocumentBuilder getSafeDocumentBuilder​(boolean validating)
                                                      throws ParserConfigurationException
        Provides a secure DocumentBuilder implementation, which is protected against different types of entity expansion attacks and makes sure that only locally available DTDs can be referenced within the XML document.
        Parameters:
        validating - Whether the returned DocumentBuilder should validate input.
        Returns:
        A secure DocumentBuilder instance.
        Throws:
        ParserConfigurationException - In case xerces does not support one of the required features.
      • getSafeSAXParser

        public static SAXParser getSafeSAXParser​(boolean validating)
                                          throws ParserConfigurationException,
                                                 SAXException
        Provides a secure SAXParser instance, which is protected against different types of entity expension, DoS attacks and makes sure that only locally available DTDs can be referenced within the XML document.
        Parameters:
        validating - Whether the returned DocumentBuilder should validate input.
        Returns:
        A secure SAXParser instance.
        Throws:
        ParserConfigurationException - In case Xerces does not support one of the required features.
        SAXException - In case Xerces does not support one of the required features.