@Test public void testTransformerFactory() throws TransformerException { thrown.expect(TransformerException.class); thrown.expectMessage(containsString("accessExternalDTD")); StreamSource xmlSource = new StreamSource(xmlDocument); Transformer transformer = SafeXml.newTransformerFactory().newTransformer(); transformer.transform(xmlSource, new StreamResult(new StringWriter())); }
public static TransformerFactory newTransformerFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); return factory; }
SafeXml { public static TransformerFactory newTransformerFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); return factory; } }
SafeXml { public static TransformerFactory newTransformerFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); return factory; } private  SafeXml(); }
SafeXml { public static TransformerFactory newTransformerFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); return factory; } private  SafeXml(); static XMLInputFactory newXmlInputFactory(); static DocumentBuilderFactory newdocumentBuilderFactory(); static DocumentBuilderFactory newStrictDocumentBuilderFactory(); static TransformerFactory newTransformerFactory(); static SAXTransformerFactory newSaxTransformerFactory(); static SAXParserFactory newSaxParserFactory(); static SAXParserFactory newStrictSaxParserFactory(); }
SafeXml { public static TransformerFactory newTransformerFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); return factory; } private  SafeXml(); static XMLInputFactory newXmlInputFactory(); static DocumentBuilderFactory newdocumentBuilderFactory(); static DocumentBuilderFactory newStrictDocumentBuilderFactory(); static TransformerFactory newTransformerFactory(); static SAXTransformerFactory newSaxTransformerFactory(); static SAXParserFactory newSaxParserFactory(); static SAXParserFactory newStrictSaxParserFactory();  }