Class HardenedWSDLLocator

java.lang.Object
org.apache.axis2.util.HardenedWSDLLocator
All Implemented Interfaces:
javax.wsdl.xml.WSDLLocator

public class HardenedWSDLLocator extends Object implements javax.wsdl.xml.WSDLLocator
A WSDLLocator that refuses a DOCTYPE declaration in the WSDL, or in anything it imports, before wsdl4j sees it.

wsdl4j parses with its own unhardened DocumentBuilderFactory, and it fetches the whole import chain itself, so a document reaching it unscreened is an XXE in the server JVM. SecureWSDLLocator screens the client-side path, but it fetches over http/https only -- deliberately, since that is all that path needs -- so it cannot be used where a WSDL is loaded from a file, an archive, a classpath resource or a catalog, which is what the deployment and runtime paths do.

This one separates the two concerns. It never decides where a document comes from: either a delegate locator resolves it, keeping whatever catalog or archive behaviour that locator implements, or it is read from its URI with any scheme the JVM supports. What it does in both cases is validate the bytes with a hardened SAX parse first, and hand wsdl4j a stream over the validated bytes. So hardening does not narrow what can be loaded.

  • Constructor Details

    • HardenedWSDLLocator

      public HardenedWSDLLocator(javax.wsdl.xml.WSDLLocator delegate)
      Validates whatever a locator already in use resolves, leaving its resolution behaviour -- catalogs, archives, the classpath -- exactly as it was.
      Parameters:
      delegate - the locator to wrap
    • HardenedWSDLLocator

      public HardenedWSDLLocator(String baseURI)
      Reads from a URI with any scheme the JVM supports, which is what the call sites replaced by this used to let wsdl4j do for itself.
      Parameters:
      baseURI - the WSDL location
  • Method Details

    • getBaseInputSource

      public InputSource getBaseInputSource()
      Specified by:
      getBaseInputSource in interface javax.wsdl.xml.WSDLLocator
    • getBaseURI

      public String getBaseURI()
      Specified by:
      getBaseURI in interface javax.wsdl.xml.WSDLLocator
    • getImportInputSource

      public InputSource getImportInputSource(String parentLocation, String importLocation)
      Specified by:
      getImportInputSource in interface javax.wsdl.xml.WSDLLocator
    • getLatestImportURI

      public String getLatestImportURI()
      Specified by:
      getLatestImportURI in interface javax.wsdl.xml.WSDLLocator
    • close

      public void close()
      Specified by:
      close in interface javax.wsdl.xml.WSDLLocator