Package com.io7m.jxe.core
Class JXEHardenedDispatchingResolver
java.lang.Object
com.io7m.jxe.core.JXEHardenedDispatchingResolver
- All Implemented Interfaces:
org.xml.sax.EntityResolver,org.xml.sax.ext.EntityResolver2
public final class JXEHardenedDispatchingResolver
extends java.lang.Object
implements org.xml.sax.ext.EntityResolver2
A hardened entity resolver that can resolve resources from a set of
given schemas or from any descendant of a given directory. The resolver
prevents path traversal attacks by refusing to resolve resources outside
of the given directory.
-
Method Summary
Modifier and Type Method Description static JXEHardenedDispatchingResolvercreate(java.util.Optional<java.nio.file.Path> in_base_directory, JXESchemaResolutionMappings in_schemas)Create a new resolver.org.xml.sax.InputSourcegetExternalSubset(java.lang.String name, java.lang.String base_uri)org.xml.sax.InputSourceresolveEntity(java.lang.String public_id, java.lang.String system_id)org.xml.sax.InputSourceresolveEntity(java.lang.String name, java.lang.String public_id, java.lang.String base_uri, java.lang.String system_id)
-
Method Details
-
create
public static JXEHardenedDispatchingResolver create(java.util.Optional<java.nio.file.Path> in_base_directory, JXESchemaResolutionMappings in_schemas)Create a new resolver. The resolver will resolve schemas from the given schema mappings, and will optionall resolve other file resources from the given base directory. If no base directory is provided, no resolution of resources from the filesystem will occur.- Parameters:
in_base_directory- The base directory used to resolve resources, if anyin_schemas- A set of schema mappings- Returns:
- A new resolver
-
getExternalSubset
public org.xml.sax.InputSource getExternalSubset(java.lang.String name, java.lang.String base_uri) throws org.xml.sax.SAXException- Specified by:
getExternalSubsetin interfaceorg.xml.sax.ext.EntityResolver2- Throws:
org.xml.sax.SAXException
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String name, java.lang.String public_id, java.lang.String base_uri, java.lang.String system_id) throws org.xml.sax.SAXException, java.io.IOException- Specified by:
resolveEntityin interfaceorg.xml.sax.ext.EntityResolver2- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String public_id, java.lang.String system_id)- Specified by:
resolveEntityin interfaceorg.xml.sax.EntityResolver
-