Package org.opencastproject.util
Class XmlSafeParser
java.lang.Object
org.opencastproject.util.XmlSafeParser
Preconfigured XML parsers, which are safeguarded against XXE and billion laugh attacks.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TransformerFactoryConfigures a TransformerFactory, to guard it against XXE and billion laugh attacks.static DocumentBuilderFactoryCreates a preconfigured DocumentBuilderFactory, which is guarded against XXE and billion laugh attacks.static SAXParserFactoryCreates a preconfigured SAXParserFactory, which is guarded against XXE and billion laugh attacks.static TransformerFactoryCreates a preconfigured default TransformerFactory, which is guarded against XXE and billion laugh attacks.static Documentparse(InputStream in) Parse a XML Document with a parser, which is guarded against XXE and billion laugh attacks.static Documentparse(InputSource s) Parse a XML Document with a parser, which is guarded against XXE and billion laugh attacks.
-
Method Details
-
newDocumentBuilderFactory
Creates a preconfigured DocumentBuilderFactory, which is guarded against XXE and billion laugh attacks.- Returns:
- the preconfigured DocumentBuilderFactory
-
newSAXParserFactory
Creates a preconfigured SAXParserFactory, which is guarded against XXE and billion laugh attacks.- Returns:
- the preconfigured SAXParserFactory
-
newTransformerFactory
Creates a preconfigured default TransformerFactory, which is guarded against XXE and billion laugh attacks.- Returns:
- the preconfigured TransformerFactory
-
configureTransformerFactory
Configures a TransformerFactory, to guard it against XXE and billion laugh attacks. Supports the default Transformer and the Saxon Transformer. The returned TransformerFactory is the same as the passed TranformerFactory.- Parameters:
f- the TransformerFactory to configure- Returns:
- the configured Factory
-
parse
Parse a XML Document with a parser, which is guarded against XXE and billion laugh attacks. The parsing is namespace aware. Designed for checking documents for XXE and billion laugh attacks before further parsing the returned document with the Unmarshaller, which can't be safely configured.- Parameters:
in- the document to parse- Returns:
- the parsed document
- Throws:
IOExceptionSAXException
-
parse
Parse a XML Document with a parser, which is guarded against XXE and billion laugh attacks. The parsing is namespace aware. Designed for checking documents for XXE and billion laugh attacks before further parsing the returned document with the Unmarshaller, which can't be safely configured.- Parameters:
s- the document to parse- Returns:
- the parsed document
- Throws:
IOExceptionSAXException
-