Search in sources :

Example 56 with Node

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;
}
Also used : Node(org.cybergarage.xml.Node) ActionData(org.cybergarage.upnp.xml.ActionData)

Example 57 with Node

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());
    }
}
Also used : Node(org.cybergarage.xml.Node)

Example 58 with Node

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;
}
Also used : ParserException(org.cybergarage.xml.ParserException) InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Document(org.w3c.dom.Document) ParserException(org.cybergarage.xml.ParserException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Node(org.cybergarage.xml.Node)

Aggregations

Node (org.cybergarage.xml.Node)58 ParserException (org.cybergarage.xml.ParserException)7 ArrayList (java.util.ArrayList)5 ServiceData (org.cybergarage.upnp.xml.ServiceData)5 Parser (org.cybergarage.xml.Parser)5 IOException (java.io.IOException)4 File (java.io.File)3 Device (org.cybergarage.upnp.Device)3 DeviceData (org.cybergarage.upnp.xml.DeviceData)3 UPnPDevice (org.osgi.service.upnp.UPnPDevice)3 URL (java.net.URL)2 Log (net.i2p.util.Log)2 InvalidDescriptionException (org.cybergarage.upnp.device.InvalidDescriptionException)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1