Class SecureXmlFactories
java.lang.Object
org.tailormap.api.util.SecureXmlFactories
Factories for parsing XML hardened against XXE, for XML from external sources such as responses of OGC services. Use
these instead of the JAXP
newInstance() methods, enforced by the PMD rule UseSecureXmlFactories.
Only the JDK XML implementations are on the classpath, so no implementation-specific hardening is needed. A DOCTYPE is allowed because OGC responses can have one (WMS 1.1.1 exception reports usually do), but the external DTD and external entities are never loaded.
-
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentBuilderFactoryCreate aDocumentBuilderFactorywhich does not load external DTDs, entities or schemas.static XMLInputFactoryCreate anXMLInputFactory(StAX) which does not process DTDs or external entities.
-
Method Details
-
newDocumentBuilderFactory
public static DocumentBuilderFactory newDocumentBuilderFactory() throws ParserConfigurationExceptionCreate aDocumentBuilderFactorywhich does not load external DTDs, entities or schemas.- Returns:
- the hardened factory
- Throws:
ParserConfigurationException- if the implementation does not support a feature
-
newXMLInputFactory
Create anXMLInputFactory(StAX) which does not process DTDs or external entities.- Returns:
- the hardened factory
-