Class 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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static JXEHardenedDispatchingResolver create​(java.util.Optional<java.nio.file.Path> in_base_directory, JXESchemaResolutionMappings in_schemas)
      Create a new resolver.
      org.xml.sax.InputSource getExternalSubset​(java.lang.String name, java.lang.String base_uri)  
      org.xml.sax.InputSource resolveEntity​(java.lang.String public_id, java.lang.String system_id)  
      org.xml.sax.InputSource resolveEntity​(java.lang.String name, java.lang.String public_id, java.lang.String base_uri, java.lang.String system_id)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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 any
        in_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:
        getExternalSubset in interface org.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:
        resolveEntity in interface org.xml.sax.ext.EntityResolver2
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • resolveEntity

        public org.xml.sax.InputSource resolveEntity​(java.lang.String public_id,
                                                     java.lang.String system_id)
        Specified by:
        resolveEntity in interface org.xml.sax.EntityResolver