Commit 4eacf951 authored by Axel Brand's avatar Axel Brand Committed by daeva

finetuning of Maininterceptor and processors, earlier testing for namespaces...

finetuning of Maininterceptor and processors, earlier testing for namespaces makes things a lot easier

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/plugins@13547 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1c07320a
......@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.dom4j.Element;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
......@@ -23,58 +24,60 @@ public class MainInterceptor implements PacketInterceptor {
private static final Logger Log = LoggerFactory.getLogger(MainInterceptor.class);
private Set<String> activeTransports = new ConcurrentHashSet<String>();
private Map<String, AbstractRemoteRosterProcessor> packetProcessors = new HashMap<String, AbstractRemoteRosterProcessor>();
private String serverDomain;
private Boolean frozen;
public MainInterceptor() {
Log.debug("Started MainInterceptor for GoJara Plugin.");
XMPPServer server = XMPPServer.getInstance();
serverDomain = server.getServerInfo().getXMPPDomain();
RosterManager rosterMananger = server.getRosterManager();
AbstractRemoteRosterProcessor updateToComponent = new ClientToComponentUpdateProcessor();
AbstractRemoteRosterProcessor iqRegistered = new DiscoIQRegisteredProcessor();
AbstractRemoteRosterProcessor iqRosterPayload = new IQRosterPayloadProcessor(rosterMananger);
AbstractRemoteRosterProcessor nonPersistant = new NonPersistantRosterProcessor(rosterMananger);
AbstractRemoteRosterProcessor statisticsProcessor = new StatisticsProcessor();
AbstractRemoteRosterProcessor iqLastProcessor = new IQLastProcessor();
AbstractRemoteRosterProcessor whitelistProcessor = new WhitelistProcessor();
packetProcessors.put("clientToComponentUpdate", updateToComponent);
AbstractRemoteRosterProcessor updateToComponent = new ClientToComponentUpdateProcessor(activeTransports);
AbstractRemoteRosterProcessor whitelistProcessor = new WhitelistProcessor(activeTransports);
packetProcessors.put("sparkIQRegistered", iqRegistered);
packetProcessors.put("iqRosterPayload", iqRosterPayload);
packetProcessors.put("handleNonPersistant", nonPersistant);
packetProcessors.put("statisticsProcessor", statisticsProcessor);
packetProcessors.put("iqLastProcessor", iqLastProcessor);
packetProcessors.put("clientToComponentUpdate", updateToComponent);
packetProcessors.put("whitelistProcessor", whitelistProcessor);
frozen = false;
}
//These get called from our RemoteRosterPlugin
// These get called from our RemoteRosterPlugin
public boolean addTransport(String subDomain) {
Log.debug("Trying to add " +subDomain + "to Set of watched Transports.");
Log.debug("Trying to add " + subDomain + "to Set of watched Transports.");
return this.activeTransports.add(subDomain);
}
public boolean removeTransport(String subDomain) {
Log.debug("Trying to remove " + subDomain + " from Set of watched Transports.");
return this.activeTransports.remove(subDomain);
// if (this.activeTransports.contains(subDomain)) {
// this.activeTransports.remove(subDomain);
// return true;
// }
// return false;
// if (this.activeTransports.contains(subDomain)) {
// this.activeTransports.remove(subDomain);
// return true;
// }
// return false;
}
//idk if this "smells" but as we still dont know why OF is not correctly shutting down our Interceptor
//better safe then sorry
public void freeze(){
frozen = true;
// idk if this "smells" but as we still dont know why OF is not correctly
// shutting down our Interceptor better safe then sorry
public void freeze() {
frozen = true;
activeTransports = null;
packetProcessors = null;
}
/*
As our Set of Subdomains is a Hash of Strings like icq.domain.tld, if we
want to check if a jid CONTAINS a watched subdomain we need to iterate over the set.
We also return the subdomain as a string so we can use it if we find it.
/**
* As our Set of Subdomains is a Hash of Strings like icq.domain.tld, if we
* want to check if a jid CONTAINS a watched subdomain we need to iterate
* over the set. We also return the subdomain as a string so we can use it
* if we find it.
*/
private String searchJIDforSubdomain(String jid) {
for (String subdomain : activeTransports) {
......@@ -83,79 +86,97 @@ public class MainInterceptor implements PacketInterceptor {
}
return "";
}
private String generateSubdomainString() {
String subdomainstring = "";
for (String subdomain : activeTransports) {
subdomainstring += subdomain + "#";
}
return subdomainstring;
}
/*
* This Interceptor tests if GoJara needs to process this package. We decided to do one global Interceptor
* so we would'nt redundantly test for cases we already checked in previous Interceptors, also we have only one big ugly If Structure
* to maintain instead of several.
* @see org.jivesoftware.openfire.interceptor.PacketInterceptor#interceptPacket(org.xmpp.packet.Packet, org.jivesoftware.openfire.session.Session, boolean, boolean)
/**
* This Interceptor tests if GoJara needs to process this package. We
* decided to do one global Interceptor so we would'nt redundantly test for
* cases we already checked in previous Interceptors, also we have only one
* big ugly If Structure to maintain instead of several.
*
* @see org.jivesoftware.openfire.interceptor.PacketInterceptor#interceptPacket
* (org.xmpp.packet.Packet, org.jivesoftware.openfire.session.Session,
* boolean, boolean)
*/
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
throws PacketRejectedException {
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
if (frozen)
return;
//We have to watch out for null else this will throw Exceptions
String from,to;
String from, to;
try {
from = (packet.getFrom() != null) ? packet.getFrom().toString() : "";
to = (packet.getTo() != null) ? packet.getTo().toString() : "";
} catch (IllegalArgumentException e) {
Log.warn("There was an illegal JID while intercepting Message for GoJara. Not Intercepting it! "+e.getMessage());
Log.warn("There was an illegal JID while intercepting Message for GoJara. Not Intercepting it! " + e.getMessage());
return;
}
//We dont want this to get too packed, so here we test only for stuff we can test on PACKET + Instanceof
if (incoming && processed) {
Log.debug("Incoming processed Package i might be interested in. I'm "+ this.hashCode() + "\n Package: \n " + packet.toString() + "\n");
//if to is Empty, this might be a Client to Component Update we have to forward.
if (to.isEmpty())
packetProcessors.get("clientToComponentUpdate").process(packet, generateSubdomainString(), to, from);
//if to is equal to a subdomain of a INCOMING package we need to check if its for registering
else if (activeTransports.contains(to) && packet instanceof IQ)
packetProcessors.get("sparkIQRegistered").process(packet,to, to, from);
//If from EQUALS the subdomain, this is likely a RosterPush or Presence we have to react to.
else if (!from.isEmpty() && activeTransports.contains(from)) {
if (packet instanceof IQ)
packetProcessors.get("iqRosterPayload").process(packet,from, to, from);
//it could also be a presence from Transport, so we test for Non-Persistancy
else if (packet instanceof Presence && !JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false))
packetProcessors.get("handleNonPersistant").process(packet,from, to, from);
}
//Functionality Processors for this Case are Done, now Logging. We need to be sure its not
//The Ping Spectrum send itself, and one of from or to contains a watched subdomain.
// We ignore Pings from S2 to S2 itself. We test for Log first so
// that we can return in case
// The packet doesnt have any watched namespace.
String from_s = searchJIDforSubdomain(from);
String to_s = searchJIDforSubdomain(to);
String subdomain = from_s.isEmpty() ? to_s : from_s;
if (!from.equals(to) && !subdomain.isEmpty() && !(from.isEmpty() && to.isEmpty()) && packet instanceof IQ)
packetProcessors.get("statisticsProcessor").process(packet,subdomain, to, from);
if (!from.equals(to) && !subdomain.isEmpty() && !(from.isEmpty() && to.isEmpty()))
packetProcessors.get("statisticsProcessor").process(packet, subdomain, to, from);
}
else if (incoming && !processed && JiveGlobals.getBooleanProperty("plugin.remoteroster.iqLastFilter", false)) {
Log.debug("Incoming unprocessed Package i might be interested in. I'm "+ this.hashCode() + "\n Package: \n " + packet.toString() + "\n");
// if to is EQUAL to the subdomain or a string containing a subdomain
String subdomain = searchJIDforSubdomain(to);
if (!subdomain.isEmpty() && packet instanceof IQ)
packetProcessors.get("iqLastProcessor").process(packet,subdomain, to, from);
}
else if(!incoming && processed) {
Log.debug("Outgoing processed Package i might be interested in. I'm "+ this.hashCode() + " Package: \n " + packet.toString() + "\n");
if ((from.isEmpty() || from.equals(serverDomain)) && packet instanceof IQ)
//This might be a Disco IQ from the SERVER itself, so we have to check for Acess-Restriction
packetProcessors.get("whiteListProcessor").process(packet, generateSubdomainString(), to, from);
//If we want the StatisticsProcessor to diff between Outgoing and Incoming, it would go here
}
}
if (packet instanceof IQ) {
IQ myPacket = (IQ) packet;
Element query = myPacket.getChildElement();
if (query == null)
return;
// Jabber:IQ:roster Indicates Client to Component update or Rosterpush
else if (query.getNamespaceURI().equals("jabber:iq:roster")) {
Log.debug("Incoming RosterPackage i might be interested in. I'm " + this.hashCode() + "\n Package: \n "
+ packet.toString() + "\n");
if (to.isEmpty())
packetProcessors.get("clientToComponentUpdate").process(packet, "", to, from);
else if (!from.isEmpty() && activeTransports.contains(from))
packetProcessors.get("iqRosterPayload").process(packet, from, to, from);
}
// Disco#Info - check for register processing
else if (query.getNamespaceURI().equals("http://jabber.org/protocol/disco#info") && !to.isEmpty()
&& activeTransports.contains(to)) {
Log.debug("Incoming Disco#info might be interested in. I'm " + this.hashCode() + "\n Package: \n " + packet.toString()
+ "\n");
packetProcessors.get("sparkIQRegistered").process(packet, to, to, from);
}
}
// Check for Rostercleanup in Nonpersistant-mode
} else if (packet instanceof Presence && !JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)) {
if (activeTransports.contains(from))
packetProcessors.get("handleNonPersistant").process(packet, from, to, from);
}
} else if (incoming && !processed && JiveGlobals.getBooleanProperty("plugin.remoteroster.iqLastFilter", false)) {
// JABBER:IQ:LAST
if (packet instanceof IQ) {
IQ myPacket = (IQ) packet;
Element query = myPacket.getChildElement();
if (query != null && query.getNamespaceURI().equals("jabber:iq:last")) {
String subdomain = searchJIDforSubdomain(to);
if (!subdomain.isEmpty()) {
Log.debug("Incoming unprocessed Package i might be interested in. I'm " + this.hashCode() + "\n Package: \n "
+ packet.toString() + "\n");
packetProcessors.get("iqLastProcessor").process(packet, subdomain, to, from);
}
}
}
} else if (!incoming && processed) {
// DISCO#ITEMS - Whitelisting Feature
if (packet instanceof IQ) {
IQ myPacket = (IQ) packet;
Element query = myPacket.getChildElement();
if (query != null && query.getNamespaceURI().equals("http://jabber.org/protocol/disco#items")) {
Log.debug("Outgoing processed Package i might be interested in. I'm " + this.hashCode() + " Package: \n "
+ packet.toString() + "\n");
packetProcessors.get("whiteListProcessor").process(packet, "", to, from);
}
}
// If we want the StatisticsProcessor to diff between Outgoing and
// Incoming, it would go here
}
}
}
package org.jivesoftware.openfire.plugin.gojara.messagefilter.processors;
import java.util.Set;
import org.dom4j.Element;
import org.dom4j.Node;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
......@@ -15,52 +17,48 @@ import org.xmpp.packet.Packet;
* href="http://jkaluza.fedorapeople.org/remote-roster.html#sect-id215516"
* >Here</a>
*
* @author Holger Bergunde
<iq id="FSwIU-68" type="set" from="user@example/resource">
// <query xmlns="jabber:iq:roster">
// <item jid="123456789@subdomain" name="wulschti" subscription="both">
// <group>General</group>
// </item>
// </query>
// </iq>
* @author Holger Bergunde <iq id="FSwIU-68" type="set"
* from="user@example/resource"> // <query xmlns="jabber:iq:roster"> //
* <item jid="123456789@subdomain" name="wulschti" subscription="both">
* // <group>General</group> // </item> // </query> // </iq>
*/
public class ClientToComponentUpdateProcessor extends AbstractRemoteRosterProcessor {
private Set<String> watchedSubdomains;
public ClientToComponentUpdateProcessor() {
public ClientToComponentUpdateProcessor(Set<String> activeTransports) {
watchedSubdomains = activeTransports;
Log.debug("Created ClientToComponentUpdateProcessor");
}
private String searchJIDforSubdomain(String[] valid_subdomains,String jid){
for (String s : valid_subdomains){
if (jid.contains(s))
return s;
private String searchJIDforSubdomain(String jid) {
for (String subdomain : watchedSubdomains) {
if (subdomain.contains(jid))
return subdomain;
}
return "";
}
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
Log.debug("Processing packet in ClientToComponentUpdateProcessor");
Element query = ((IQ) packet).getChildElement();
if (query != null && query.getNamespaceURI().equals("jabber:iq:roster")) {
if (findNodesInDocument(query.getDocument(), "//roster:item").size() > 0) {
// We now know we have to check the JID of the to be added User against our valid subdomains.
String[] valid_subdomains = subdomain.split("[#]");
for (Node n : findNodesInDocument(query.getDocument(), "//roster:item")) {
String jid = n.valueOf("@jid");
// TODO: We ignore remove iq packets for now. There might be
// conflicts
// when we remove our legacy network registration.
String found_subdomain = searchJIDforSubdomain(valid_subdomains, jid);
if (!found_subdomain.isEmpty() && !n.valueOf("@subscription").equals("remove")) {
Log.debug("Mirroring packet from local network to legacy component " + found_subdomain);
IQ forward = (IQ) packet.createCopy();
forward.setTo(found_subdomain);
dispatchPacket(forward);
}
if (findNodesInDocument(query.getDocument(), "//roster:item").size() > 0) {
// We now know we have to check the JID of the to be added User
// against our valid subdomains.
for (Node n : findNodesInDocument(query.getDocument(), "//roster:item")) {
String jid = n.valueOf("@jid");
// TODO: We ignore remove iq packets for now. There might be
// conflicts
// when we remove our legacy network registration.
String found_subdomain = searchJIDforSubdomain(jid);
if (!found_subdomain.isEmpty() && !n.valueOf("@subscription").equals("remove")) {
Log.debug("Mirroring packet from local network to legacy component " + found_subdomain);
IQ forward = (IQ) packet.createCopy();
forward.setTo(found_subdomain);
dispatchPacket(forward);
}
}
}
......
......@@ -29,7 +29,7 @@ public class DiscoIQRegisteredProcessor extends AbstractRemoteRosterProcessor {
private boolean _isRegistered = false;
public DiscoIQRegisteredProcessor() {
Log.debug("Created DiscoIQResigteredProcessor");
Log.debug("Created DiscoIQRegisteredProcessor");
}
@Override
......
package org.jivesoftware.openfire.plugin.gojara.messagefilter.processors;
import org.dom4j.Element;
import org.dom4j.tree.DefaultElement;
import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
......@@ -36,12 +35,8 @@ public class IQLastProcessor extends AbstractRemoteRosterProcessor{
throws PacketRejectedException {
IQ iqpacket = (IQ) packet;
Element root = iqpacket.getChildElement();
if (root == null)
return;
String ns = root.getNamespaceURI();
if (ns.equals("jabber:iq:last") && iqpacket.getType().equals(IQ.Type.get)) {
if (iqpacket.getType().equals(IQ.Type.get)) {
Log.debug("Processing IQLast Packet for " + subdomain);
IQ answer = IQ.createResultIQ(iqpacket);
answer.setType(IQ.Type.error);
......@@ -59,8 +54,6 @@ public class IQLastProcessor extends AbstractRemoteRosterProcessor{
PacketRouter router = _server.getPacketRouter();
router.route(answer);
//There is no need for the Server to process this Package if S2 doesn't support it.
throw new PacketRejectedException();
}
}
......
......@@ -49,24 +49,21 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
String username = getUsernameFromJid(to);
if (query != null && query.getNamespaceURI().equals("jabber:iq:roster")) {
if (myPacket.getType().equals(IQ.Type.get)) {
handleIQget(myPacket,subdomain,username);
}
else if (myPacket.getType().equals(IQ.Type.set)) {
handleIQset(myPacket,subdomain,username);
handleIQget(myPacket, subdomain, username);
} else if (myPacket.getType().equals(IQ.Type.set)) {
handleIQset(myPacket, subdomain, username);
}
}
}
}
private void handleIQget(IQ myPacket, String subdomain, String username){
if(JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)){
private void handleIQget(IQ myPacket, String subdomain, String username) {
if (JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)) {
Roster roster;
try {
roster = _rosterManager.getRoster(username);
Collection<RosterItem> items = roster.getRosterItems();
Log.debug("Sending contacts with subdomain " + subdomain + " from user " +username + " to external Component");
Log.debug("Sending contacts with subdomain " + subdomain + " from user " + username + " to external Component");
sendRosterToComponent(myPacket, items, subdomain);
} catch (UserNotFoundException e) {
e.printStackTrace();
......@@ -74,7 +71,7 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
} else {
Log.debug("Sending nonpersistant-RemoteRosterResponse to external Component for User: " + username);
sendEmptyRoster(myPacket, subdomain);
}
}
}
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {
......@@ -84,8 +81,7 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
Element query = new DefaultElement("query");
for (RosterItem i : items) {
if (i.getJid().toString().contains(subdomain)) {
Log.debug("Roster exchange for external component " + subdomain + ". Sending user "
+ i.getJid().toString());
Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
Element item = new DefaultElement("item", null);
item.add(new DefaultAttribute("jid", i.getJid().toString()));
item.add(new DefaultAttribute("name", i.getNickname()));
......@@ -104,7 +100,7 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
dispatchPacket(response);
}
private void sendEmptyRoster(Packet requestPacket, String subdomain){
private void sendEmptyRoster(Packet requestPacket, String subdomain) {
IQ iq = (IQ) requestPacket;
IQ response = IQ.createResultIQ(iq);
response.setTo(subdomain);
......@@ -124,11 +120,11 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
String jid = n.valueOf("@jid");
String name = n.valueOf("@name");
String subvalue = n.valueOf("@subscription");
//We dont want to add or delete the subdomain itself
if (jid.equals(subdomain))
// We dont want to add or delete the subdomain itself
if (jid.equals(subdomain))
continue;
if(subvalue.equals("both")){
if (subvalue.equals("both")) {
try {
roster = _rosterManager.getRoster(username);
List<String> grouplist = new ArrayList<String>();
......@@ -143,10 +139,10 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
RosterItem item = roster.getRosterItem(new JID(jid));
item.setGroups(grouplist);
roster.updateRosterItem(item);
//dont send iq-result if just updating user
// dont send iq-result if just updating user
continue;
} catch (UserNotFoundException exc) {
//Then we should add him!
// Then we should add him!
}
RosterItem item = roster.createRosterItem(new JID(jid), name, grouplist, false, rosterPersistent);
item.setSubStatus(RosterItem.SUB_BOTH);
......@@ -155,7 +151,7 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
Log.debug("Could not add user to Roster although no entry should exist..." + username, e);
e.printStackTrace();
}
} else if (subvalue.equals("remove")){
} else if (subvalue.equals("remove")) {
try {
roster = _rosterManager.getRoster(username);
roster.deleteRosterItem(new JID(jid), false);
......
......@@ -10,9 +10,11 @@ import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
/**
* When this Processor gets called, it deletes all Contacts of a given User that contain a specific subdomain.
* We use this to clean up all Contacts of a Users Gateway registration as soon as he logs out. In this case
* the Transport sends a Unavailable Presence without subtext "Connecting" to the user.
* When this Processor gets called, it deletes all Contacts of a given User that
* contain a specific subdomain. We use this to clean up all Contacts of a Users
* Gateway registration as soon as he logs out. In this case the Transport sends
* a Unavailable Presence without subtext "Connecting" to the user.
*
* @author Holger Bergunde
* @author axel.frederik.brand
*
......@@ -29,10 +31,11 @@ public class NonPersistantRosterProcessor extends AbstractRemoteRosterProcessor
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
Presence myPacket = (Presence) packet;
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable) && !myPacket.getElement().getStringValue().equals("Connecting")) {
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable)
&& !myPacket.getElement().getStringValue().equals("Connecting")) {
String username = getUsernameFromJid(to);
Log.debug("Processing packet in NonPersistantRosterProcessor for " + subdomain + "and user " + username);
try {
Roster roster = _rosterManager.getRoster(username);
Collection<RosterItem> items = roster.getRosterItems();
......@@ -47,7 +50,7 @@ public class NonPersistantRosterProcessor extends AbstractRemoteRosterProcessor
} catch (Exception e) {
Log.debug("Execption occured when cleaning up the Roster.", e);
e.printStackTrace();
}
}
}
}
......
package org.jivesoftware.openfire.plugin.gojara.messagefilter.processors;
import java.util.List;
import java.util.Set;
import org.dom4j.Element;
import org.dom4j.Node;
......@@ -20,50 +21,39 @@ import org.xmpp.packet.Packet;
* @author Holger Bergunde
* @author axel.frederik.brand
*/
public class WhitelistProcessor extends AbstractRemoteRosterProcessor{
public class WhitelistProcessor extends AbstractRemoteRosterProcessor {
private PermissionManager _permissions;
private Set<String> watchedSubdomains;
public WhitelistProcessor() {
public WhitelistProcessor(Set<String> activeTransports) {
_permissions = new PermissionManager();
watchedSubdomains = activeTransports;
Log.debug("Created WhitelistProcessor");
}
/**
* At this point we already know:
* Package is NOT incoming
* Package is processed
* From is either Empty (it was null) or equals the serverDomain.
* Package is a IQ
* 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 A String containing several watched subdomains separated by [#]
* @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 {
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
IQ myPacket = (IQ) packet;
Element root = myPacket.getChildElement();
if (root == null)
return;
String ns = root.getNamespaceURI();
if (ns.equals("http://jabber.org/protocol/disco#items") && myPacket.getType().equals(IQ.Type.result)) {
if (myPacket.getType().equals(IQ.Type.result) && (from.isEmpty() || from.equals(_server.getServerInfo().getXMPPDomain()))) {
Log.debug("Processing packet in Whitelistprocessor for " + to);
//As some users can be allowed to use only specific Gateways, we have to do this for every subdomain separately
String[] valid_subdomains = subdomain.split("[#]");
for (String single_subdomain : valid_subdomains) {
if (_permissions.isGatewayLimited(single_subdomain) && !_permissions.allowedForUser(single_subdomain, myPacket.getTo())) {
List<Node> nodes = XpathHelper.findNodesInDocument(root.getDocument(), "//discoitems:item");
for (Node node : nodes) {
if (node.valueOf("@jid").equals(single_subdomain)) {
root.remove(node);
}
}
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);
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment