use of org.jdom2.input.SAXBuilder in project cas by apereo.
the class AbstractSamlObjectBuilder method constructDocumentFromXml.
/**
* Construct document from xml.
*
* @param xmlString the xml string
* @return the document
*/
@SuppressWarnings("java:S2755")
public static Document constructDocumentFromXml(final String xmlString) {
LOGGER.trace("Attempting to construct an instance of Document from xml: [{}]", xmlString);
try {
val builder = new SAXBuilder();
builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
return builder.build(new ByteArrayInputStream(xmlString.getBytes(Charset.defaultCharset())));
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
return null;
}
}
use of org.jdom2.input.SAXBuilder in project jena by apache.
the class GMLReader method newSAXBuilder.
// ---- XXE safe SAXBuilder
private static SAXBuilder newSAXBuilder() {
SAXBuilder builder = new SAXBuilder();
builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
builder.setExpandEntities(false);
return builder;
}
use of org.jdom2.input.SAXBuilder in project jPOS by jpos.
the class QThreadPoolExecutorTest method getDocument.
protected Document getDocument(InputStream is) {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
Document doc = null;
try {
doc = builder.build(is);
return doc;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.jdom2.input.SAXBuilder in project scylla by bptlab.
the class SimulationManager method parseInput.
protected void parseInput() throws ScyllaValidationException, JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
if (globalConfigurationFilename == null || globalConfigurationFilename.isEmpty())
throw new ScyllaValidationException("No global configuration provided.");
// parse global configuration XML
Document gcDoc = builder.build(globalConfigurationFilename);
Element gcRootElement = gcDoc.getRootElement();
parseGlobalConfiguration(gcRootElement);
CommonProcessElementsParser cpeParser = new CommonProcessElementsParser(this);
// parse each process model XML (.bpmn)
for (String filename : processModelFilenames) {
Document pmDoc = builder.build(filename);
parseProcessCommonsAndModel(cpeParser, pmDoc.getRootElement(), filename);
}
SimulationConfigurationParser simParser = new SimulationConfigurationParser(this);
// parse each simulation configuration XML
for (String filename : simulationConfigurationFilenames) {
Document scDoc = builder.build(filename);
parseSimulationConfiguration(simParser, scDoc);
}
}
use of org.jdom2.input.SAXBuilder in project scylla by bptlab.
the class SimulationConfigurationPane method open.
@Override
protected void open() throws JDOMException, IOException {
buttonClosefile.setEnabled(true);
try {
creator = SimulationConfigurationCreator.createFromFile(getFile().getPath());
} catch (NotAValidFileException e1) {
setFile(null);
e1.printStackTrace();
return;
}
if (gcc != null)
creator.setGCC(gcc);
Element modelRoot = null;
if (bpmnPath != null && !bpmnPath.isEmpty())
try {
Document doc;
SAXBuilder builder = new SAXBuilder();
doc = builder.build(bpmnPath);
modelRoot = doc.getRootElement();
creator.setModel(modelRoot, false);
} catch (JDOMException | IOException e) {
e.printStackTrace();
} catch (NoProcessSpecifiedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotAuthorizedToOverrideException e) {
int override = showModelOverrideConfirmationDialog(e);
if (override == 0)
try {
creator.setModel(modelRoot, true);
} catch (NoProcessSpecifiedException | NotAuthorizedToOverrideException e1) {
e1.printStackTrace();
}
else
clearBpmnPath();
e.printStackTrace();
}
setChangeFlag(true);
textfieldId.loadSavedValue();
if (creator.getRandomSeed() != null) {
textfieldSeed.setValue(creator.getRandomSeed());
}
if (creator.getProcessInstances() != null)
spinnerNOI.setValue(Integer.parseInt(creator.getProcessInstances()));
String startDt = creator.getStartDateTime();
if (startDt != null) {
startDateTime = ZonedDateTime.parse(startDt);
textfieldStartTime.setValue(startDateTime.toLocalTime());
textfieldStartDate.setValue(startDateTime.toLocalDate());
}
String endDt = creator.getEndDateTime();
if (endDt != null) {
checkboxUnlimited.setSelected(false);
endDateTime = ZonedDateTime.parse(endDt);
textfieldEndTime.setValue(endDateTime.toLocalTime());
textfieldEndDate.setValue(endDateTime.toLocalDate());
} else {
checkboxUnlimited.setSelected(true);
textfieldEndDate.getComponent().setEnabled(false);
textfieldEndTime.getComponent().setEnabled(false);
}
importCreatorElements();
setChangeFlag(false);
setEnabled(true);
}
Aggregations