List of usage examples for javax.xml.stream XMLInputFactory IS_SUPPORTING_EXTERNAL_ENTITIES
String IS_SUPPORTING_EXTERNAL_ENTITIES
To view the source code for javax.xml.stream XMLInputFactory IS_SUPPORTING_EXTERNAL_ENTITIES.
Click Source Link
From source file:com.hp.application.automation.tools.octane.tests.xml.AbstractXmlIterator.java
private static XMLInputFactory createXmlInputFactory() { XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); xmlFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); return xmlFactory; }
From source file:com.adaptris.core.services.UseXmlCharsetAsEncodingService.java
private static XMLInputFactory createInputFactory() { XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); return factory; }
From source file:com.predic8.membrane.core.multipart.XOPReconstitutor.java
public XOPReconstitutor() { xmlInputFactory = XMLInputFactory.newInstance(); xmlInputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); }
From source file:com.lucidworks.hadoop.ingest.util.EmptyEntityResolver.java
/** * Configures the given {@link XMLInputFactory} to not parse external entities. * No further configuration on is needed, all required entity resolvers are configured. *//*from w ww.j a v a 2 s . c om*/ public static void configureXMLInputFactory(XMLInputFactory inputFactory) { // don't enable validation of DTDs: trySetStAXProperty(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE); // enable this to *not* produce parsing failure on external entities: trySetStAXProperty(inputFactory, XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE); inputFactory.setXMLResolver(EmptyEntityResolver.STAX_INSTANCE); }
From source file:org.owasp.webgoat.plugin.XXE.java
private SearchForm parseXml(String xml) throws Exception { JAXBContext jc = JAXBContext.newInstance(SearchForm.class); XMLInputFactory xif = XMLInputFactory.newFactory(); xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, true); xif.setProperty(XMLInputFactory.SUPPORT_DTD, true); XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(xml)); Unmarshaller unmarshaller = jc.createUnmarshaller(); return (SearchForm) unmarshaller.unmarshal(xsr); }
From source file:ValidateStax.java
private static XMLEventReader getXMLEventReader(String filename) { XMLInputFactory xmlif = null; XMLEventReader xmlr = null;// ww w . ja va 2s. c o m try { xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); FileInputStream fis = new FileInputStream(filename); xmlr = xmlif.createXMLEventReader(filename, fis); } catch (Exception ex) { ex.printStackTrace(); } return xmlr; }
From source file:com.github.lindenb.jvarkit.tools.blast.BlastFilterJS.java
@Override protected Collection<Throwable> call(String inputName) throws Exception { final CompiledScript compiledScript; Unmarshaller unmarshaller;//w w w . jav a2s. c om Marshaller marshaller; try { compiledScript = super.compileJavascript(); JAXBContext jc = JAXBContext.newInstance("gov.nih.nlm.ncbi.blast"); unmarshaller = jc.createUnmarshaller(); marshaller = jc.createMarshaller(); XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlInputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); PrintWriter pw = openFileOrStdoutAsPrintWriter(); XMLOutputFactory xof = XMLOutputFactory.newFactory(); xof.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE); XMLEventWriter w = xof.createXMLEventWriter(pw); StreamSource src = null; if (inputName == null) { LOG.info("Reading stdin"); src = new StreamSource(stdin()); } else { LOG.info("Reading file " + inputName); src = new StreamSource(new File(inputName)); } XMLEventReader r = xmlInputFactory.createXMLEventReader(src); XMLEventFactory eventFactory = XMLEventFactory.newFactory(); SimpleBindings bindings = new SimpleBindings(); while (r.hasNext()) { XMLEvent evt = r.peek(); switch (evt.getEventType()) { case XMLEvent.START_ELEMENT: { StartElement sE = evt.asStartElement(); Hit hit = null; JAXBElement<Hit> jaxbElement = null; if (sE.getName().getLocalPart().equals("Hit")) { jaxbElement = unmarshaller.unmarshal(r, Hit.class); hit = jaxbElement.getValue(); } else { w.add(r.nextEvent()); break; } if (hit != null) { bindings.put("hit", hit); boolean accept = super.evalJavaScriptBoolean(compiledScript, bindings); if (accept) { marshaller.marshal(jaxbElement, w); w.add(eventFactory.createCharacters("\n")); } } break; } case XMLEvent.SPACE: break; default: { w.add(r.nextEvent()); break; } } r.close(); } w.flush(); w.close(); pw.flush(); pw.close(); return RETURN_OK; } catch (Exception err) { return wrapException(err); } finally { } }
From source file:StreamSrcStAXRst.java
private static XMLEventReader getXMLEventReader(String filename) { XMLInputFactory xmlif = null; XMLEventReader xmlr = null;// w ww.ja v a 2s . com try { xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); FileInputStream fis = new FileInputStream(filename); xmlr = xmlif.createXMLEventReader(filename, fis); } catch (Exception ex) { ex.printStackTrace(); } return xmlr; }
From source file:sapience.injectors.stax.inject.StringBasedStaxStreamInjector.java
private void setupFactories() { inFac = XMLInputFactory2.newInstance(); inFac.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); inFac.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); inFac.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); outFac = XMLOutputFactory2.newInstance(); eventFac = Stax2EventFactoryImpl.newInstance(); }