Class SecureTransformerFactory

java.lang.Object
org.apache.commons.xml.secure.SecureTransformerFactory

public final class SecureTransformerFactory extends Object
Creates new, secure TransformerFactory instances.

Beyond the three universal guarantees on org.apache.commons.xml.secure: xsl:import, xsl:include and document() URIs are not resolved.

The guarantees govern what the transform reads, not what it writes: an output instruction like xsl:result-document still writes wherever the stylesheet directs, so an untrusted stylesheet's output destinations must be restricted outside the library.

The guarantees apply to every parser the factory creates internally for the standard TransformerFactory entry points: stylesheet compilation (newTemplates(Source), newTransformer(Source)) and source-document reading at Transformer.transform(Source, Result) time.

The href an xml-stylesheet processing instruction names is content of the document being scanned, so getAssociatedStylesheet treats it as any other content-named reference: install a URIResolver resolving that href to compile the stylesheet it points at. Without one the returned Source carries empty content rather than naming the URI, so compiling it cannot fetch a stylesheet the parsed document chose.

The SAXTransformerFactory extension methods (newTransformerHandler(..), newTemplatesHandler(), newXMLFilter(..)), if reachable by casting the returned factory, produce objects carrying the same guarantees.

This class is not itself a TransformerFactory, so it inherits none of the static JAXP factory methods. A caller therefore cannot obtain an unsecured factory through this class by calling a method such as newDefaultInstance(). The secure factories are instances of a nested, non-public wrapper class.

See Also:
  • Method Details