Class PreventLocalEntityResolver

  • All Implemented Interfaces:
    Serializable, EntityResolver, EntityResolver2

    public class PreventLocalEntityResolver
    extends Object
    implements EntityResolver2, Serializable
    EntityResolver implementation to prevent use external entity resolution to local files.

    When parsing an XML entity reference to a local file a SAXException is thrown, which can be handled appropriately.

    This implementation is both recommended and the default returned by GeoTools#getEntityResolver().

    Author:
    Davide Savazzi - geo-solutions.it
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      InputSource getExternalSubset​(String name, String baseURI)  
      InputSource resolveEntity​(String publicId, String systemId)  
      InputSource resolveEntity​(String name, String publicId, String baseURI, String systemId)
      Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI.
      • Methods inherited from class Object

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

      • ERROR_MESSAGE_BASE

        public static final String ERROR_MESSAGE_BASE
        Prefix used for SAXException message
        See Also:
        Constant Field Values
      • LOGGER

        protected static final Logger LOGGER
    • Constructor Detail

      • PreventLocalEntityResolver

        protected PreventLocalEntityResolver()
    • Method Detail

      • resolveEntity

        public InputSource resolveEntity​(String publicId,
                                         String systemId)
                                  throws SAXException,
                                         IOException
        Specified by:
        resolveEntity in interface EntityResolver
        Throws:
        SAXException
        IOException
      • getExternalSubset

        public InputSource getExternalSubset​(String name,
                                             String baseURI)
                                      throws SAXException,
                                             IOException
        Specified by:
        getExternalSubset in interface EntityResolver2
        Throws:
        SAXException
        IOException
      • resolveEntity

        public InputSource resolveEntity​(String name,
                                         String publicId,
                                         String baseURI,
                                         String systemId)
                                  throws SAXException,
                                         IOException
        Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI. Note that because the older DefaultHandler.resolveEntity(), method is overridden to call this one, this method may sometimes be invoked with null name and baseURI, and with the systemId already absolutized.
        Specified by:
        resolveEntity in interface EntityResolver2
        Throws:
        SAXException
        IOException