use of org.cybergarage.xml.ParserException in project i2p.i2p by i2p.
the class Device method loadDescription.
public boolean loadDescription(String descString) throws InvalidDescriptionException {
try {
Parser parser = UPnP.getXMLParser();
rootNode = parser.parse(descString);
if (rootNode == null)
throw new InvalidDescriptionException(Description.NOROOT_EXCEPTION);
deviceNode = rootNode.getNode(Device.ELEM_NAME);
if (deviceNode == null)
throw new InvalidDescriptionException(Description.NOROOTDEVICE_EXCEPTION);
} catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
if (initializeLoadedDescription() == false)
return false;
setDescriptionFile(null);
return true;
}
use of org.cybergarage.xml.ParserException in project i2p.i2p by i2p.
the class Service method loadSCPD.
// //////////////////////////////////////////////
// SCPD node
// //////////////////////////////////////////////
public boolean loadSCPD(String scpdStr) throws InvalidDescriptionException {
try {
Parser parser = UPnP.getXMLParser();
Node scpdNode = parser.parse(scpdStr);
if (scpdNode == null)
return false;
ServiceData data = getServiceData();
data.setSCPDNode(scpdNode);
} catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
return true;
}
use of org.cybergarage.xml.ParserException in project i2p.i2p by i2p.
the class SOAPRequest method getRootNode.
private synchronized Node getRootNode() {
if (rootNode != null)
return rootNode;
try {
byte[] content = getContent();
ByteArrayInputStream contentIn = new ByteArrayInputStream(content);
Parser parser = SOAP.getXMLParser();
rootNode = parser.parse(contentIn);
} catch (ParserException e) {
Debug.warning(e);
}
return rootNode;
}
use of org.cybergarage.xml.ParserException 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