Search in sources :

Example 41 with Element

use of org.dom4j.Element in project Openfire by igniterealtime.

the class MucFilterProcessor method process.

/**
	 * At this Point we know: MucBlock = true, !incoming, !processed Package is
	 * IQ with Namespace disco#info, from equals the watched subdomain given
	 * through subdomain
	 */
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
    IQ iqPacket = (IQ) packet;
    if (iqPacket.getType().equals(IQ.Type.result) && to.length() > 0) {
        Element root = iqPacket.getChildElement();
        List<Node> nodes = XpathHelper.findNodesInDocument(root.getDocument(), "//disco:feature");
        for (Node node : nodes) {
            String var = node.valueOf("@var");
            if (var.equals("http://jabber.org/protocol/muc"))
                root.remove(node);
        }
    }
}
Also used : Element(org.dom4j.Element) Node(org.dom4j.Node) IQ(org.xmpp.packet.IQ)

Example 42 with Element

use of org.dom4j.Element in project Openfire by igniterealtime.

the class WhitelistProcessor method process.

/**
	 * If this is valid disco#items package for this Use-Case we iterate through
	 * the nodes and check if we have to remove nodes, this way they are not
	 * shown to the user receiving this disco#items.
	 * 
	 * @param subdomain
	 *            not the actual Subdomain here, as we have to use our set.
	 */
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
    IQ myPacket = (IQ) packet;
    if (myPacket.getType().equals(IQ.Type.result) && (from.length() == 0 || from.equals(_server.getServerInfo().getXMPPDomain()))) {
        Log.debug("Processing packet in Whitelistprocessor for " + to + "Packet: " + packet.toString());
        Element root = myPacket.getChildElement();
        List<Node> nodes = XpathHelper.findNodesInDocument(root.getDocument(), "//discoitems:item");
        for (Node node : nodes) {
            String node_domain = node.valueOf("@jid");
            if (watchedSubdomains.contains(node_domain)) {
                if (_permissions.isGatewayLimited(node_domain) && !_permissions.allowedForUser(node_domain, myPacket.getTo()))
                    root.remove(node);
            }
        }
    }
}
Also used : Element(org.dom4j.Element) Node(org.dom4j.Node) IQ(org.xmpp.packet.IQ)

Example 43 with Element

use of org.dom4j.Element in project Openfire by igniterealtime.

the class Request method getMetaDataElement.

public Element getMetaDataElement() {
    QName qName = DocumentHelper.createQName("metadata", DocumentHelper.createNamespace("", "http://jivesoftware.com/protocol/workgroup"));
    Element metaDataElement = DocumentHelper.createElement(qName);
    for (String name : metaData.keySet()) {
        List<String> values = metaData.get(name);
        for (String value : values) {
            Element elem = metaDataElement.addElement("value");
            elem.addAttribute("name", name).setText(value);
        }
    }
    return metaDataElement;
}
Also used : QName(org.dom4j.QName) Element(org.dom4j.Element)

Example 44 with Element

use of org.dom4j.Element in project Openfire by igniterealtime.

the class TransferRequest method getSessionElement.

@Override
public Element getSessionElement() {
    // Add the workgroup of the original user request
    QName qName = DocumentHelper.createQName("session", DocumentHelper.createNamespace("", "http://jivesoftware.com/protocol/workgroup"));
    Element sessionElement = DocumentHelper.createElement(qName);
    sessionElement.addAttribute("id", sessionID);
    sessionElement.addAttribute("workgroup", userRequest.getWorkgroup().getJID().toString());
    return sessionElement;
}
Also used : QName(org.dom4j.QName) Element(org.dom4j.Element)

Example 45 with Element

use of org.dom4j.Element in project Openfire by igniterealtime.

the class TransferRequest method userJoinedRoom.

@Override
public void userJoinedRoom(JID roomJID, JID user) {
    Log.debug("User " + user + " has joined " + roomJID + ". User should be kicked.");
    if (actualInvitee != null && actualInvitee.toBareJID().equals(user.toBareJID())) {
        joinedRoom = System.currentTimeMillis();
        // This request has been completed so remove it from the list of related
        // requests of the original user request
        userRequest.removeRelatedRequest(this);
        // Kick the inviter from the room
        IQ kick = new IQ(IQ.Type.set);
        kick.setTo(roomJID);
        kick.setFrom(workgroup.getFullJID());
        Element childElement = kick.setChildElement("query", "http://jabber.org/protocol/muc#admin");
        Element item = childElement.addElement("item");
        item.addAttribute("jid", inviter.toString());
        item.addAttribute("role", "none");
        item.addElement("reason").setText("Transfer was successful");
        workgroup.send(kick);
        Log.debug("Sent kicked to  " + user + " in room " + roomJID + ".");
    }
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Aggregations

Element (org.dom4j.Element)2207 Document (org.dom4j.Document)500 ArrayList (java.util.ArrayList)294 List (java.util.List)249 SAXReader (org.dom4j.io.SAXReader)196 Iterator (java.util.Iterator)163 IQ (org.xmpp.packet.IQ)142 HashMap (java.util.HashMap)135 IOException (java.io.IOException)114 File (java.io.File)101 Attribute (org.dom4j.Attribute)97 StringReader (java.io.StringReader)90 DefaultElement (org.dom4j.tree.DefaultElement)87 JID (org.xmpp.packet.JID)87 Test (org.junit.jupiter.api.Test)78 DocumentException (org.dom4j.DocumentException)74 QName (org.dom4j.QName)68 AnnotatedElement (java.lang.reflect.AnnotatedElement)64 Node (org.dom4j.Node)64 Test (org.junit.Test)64