Package com.itextpdf.kernel.utils
Class DefaultSafeXmlParserFactory
java.lang.Object
com.itextpdf.kernel.utils.DefaultSafeXmlParserFactory
- All Implemented Interfaces:
-
IXmlParserFactory
Implementation of
IXmlParserFactory
for creating safe xml parser objects. Creates parsers with configuration to prevent XML bombs and XXE attacks.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Configures document builder factory to make it secure against xml attacks.protected void
Configures SAX parser factory to make it secure against xml attacks.protected void
Configures transformer factory to make it secure against xml attacks.protected DocumentBuilderFactory
Creates a document builder factory implementation.createDocumentBuilderInstance
(boolean namespaceAware, boolean ignoringComments) Creates the instance of theDocumentBuilder
.protected SAXParserFactory
Creates a SAX parser factory implementation.Creates the instance of theTransformer
.createXMLReaderInstance
(boolean namespaceAware, boolean validating) Creates the instance of theXMLReader
.
-
Constructor Details
-
DefaultSafeXmlParserFactory
public DefaultSafeXmlParserFactory()Creates instance ofDefaultSafeXmlParserFactory
.
-
-
Method Details
-
createDocumentBuilderInstance
public DocumentBuilder createDocumentBuilderInstance(boolean namespaceAware, boolean ignoringComments) Description copied from interface:IXmlParserFactory
Creates the instance of theDocumentBuilder
.- Specified by:
-
createDocumentBuilderInstance
in interfaceIXmlParserFactory
- Parameters:
-
namespaceAware
- specifies whether the parser should be namespace aware -
ignoringComments
- specifies whether the parser should ignore comments - Returns:
-
instance of the
DocumentBuilder
-
createXMLReaderInstance
Description copied from interface:IXmlParserFactory
Creates the instance of theXMLReader
.- Specified by:
-
createXMLReaderInstance
in interfaceIXmlParserFactory
- Parameters:
-
namespaceAware
- specifies whether the parser should be namespace aware -
validating
- specifies whether the parser should validate documents as they are parsed - Returns:
-
instance of the
XMLReader
-
createTransformerInstance
Description copied from interface:IXmlParserFactory
Creates the instance of theTransformer
.- Specified by:
-
createTransformerInstance
in interfaceIXmlParserFactory
- Returns:
-
instance of the
Transformer
-
createDocumentBuilderFactory
Creates a document builder factory implementation.- Returns:
-
result of
DocumentBuilderFactory.newInstance()
call
-
createSAXParserFactory
Creates a SAX parser factory implementation.- Returns:
-
result of
SAXParserFactory.newInstance()
call
-
configureSafeDocumentBuilderFactory
Configures document builder factory to make it secure against xml attacks.- Parameters:
-
factory
-DocumentBuilderFactory
instance to be configured
-
configureSafeSAXParserFactory
Configures SAX parser factory to make it secure against xml attacks.- Parameters:
-
factory
-SAXParserFactory
instance to be configured
-
configureSafeTransformerFactory
Configures transformer factory to make it secure against xml attacks.- Parameters:
-
factory
-TransformerFactory
instance to be configured
-