use of org.cybergarage.xml.Node in project i2p.i2p by i2p.
the class Action method getActionData.
// //////////////////////////////////////////////
// UserData
// //////////////////////////////////////////////
private ActionData getActionData() {
Node node = getActionNode();
ActionData userData = (ActionData) node.getUserData();
if (userData == null) {
userData = new ActionData();
node.setUserData(userData);
userData.setNode(node);
}
return userData;
}
use of org.cybergarage.xml.Node in project i2p.i2p by i2p.
the class Action method setArgumentList.
public void setArgumentList(ArgumentList al) {
Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME);
if (argumentListNode == null) {
argumentListNode = new Node(ArgumentList.ELEM_NAME);
getActionNode().addNode(argumentListNode);
} else {
argumentListNode.removeAllNodes();
}
Iterator<Argument> i = al.iterator();
while (i.hasNext()) {
Argument a = i.next();
a.setService(getService());
argumentListNode.addNode(a.getArgumentNode());
}
}
use of org.cybergarage.xml.Node in project i2p.i2p by i2p.
the class JaxpParser method parse.
/* (non-Javadoc)
* @see org.cybergarage.xml.Parser#parse(java.io.InputStream)
*/
public Node parse(InputStream inStream) throws ParserException {
org.cybergarage.xml.Node root = null;
try {
// https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
factory.setExpandEntityReferences(false);
try {
try {
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
} catch (ParserConfigurationException pce) {
}
try {
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
} catch (ParserConfigurationException pce) {
}
try {
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (ParserConfigurationException pce) {
}
try {
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (ParserConfigurationException pce) {
}
}// FreeBSD
catch (AbstractMethodError ame) {
}
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new BlankingResolver());
InputSource inSrc = new InputSource(new NullFilterInputStream(inStream));
Document doc = builder.parse(inSrc);
org.w3c.dom.Element docElem = doc.getDocumentElement();
if (docElem != null)
root = parse(root, docElem);
/*
NodeList rootList = doc.getElementsByTagName("root");
Debug.message("rootList = " + rootList.getLength());
if (0 < rootList.getLength())
root = parse(root, rootList.item(0));
*/
} catch (Exception e) {
throw new ParserException(e);
}
return root;
}
Aggregations