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);
}
}
}
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);
}
}
}
}
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;
}
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;
}
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 + ".");
}
}
Aggregations