Commit a6d97d85 authored by Axel Brand's avatar Axel Brand Committed by daeva

Fixed some typos

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13407 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1a6b6c70
......@@ -9,7 +9,7 @@ import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.AbstractRemoteRosterProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.CleanUpRosterProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.ClientToComponentUpdateProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.DiscoIQResigteredProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.DiscoIQRegisteredProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.NonPersistantRosterProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.ReceiveComponentUpdatesProcessor;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors.SendRosterProcessor;
......@@ -50,7 +50,7 @@ public class RemoteRosterInterceptor implements PacketInterceptor {
AbstractRemoteRosterProcessor sendroster = new SendRosterProcessor(rosterMananger, _mySubdomain);
AbstractRemoteRosterProcessor receiveChanges = new ReceiveComponentUpdatesProcessor(rosterMananger,
_mySubdomain);
AbstractRemoteRosterProcessor iqRegistered = new DiscoIQResigteredProcessor(_mySubdomain);
AbstractRemoteRosterProcessor iqRegistered = new DiscoIQRegisteredProcessor(_mySubdomain);
AbstractRemoteRosterProcessor nonPersistant = new NonPersistantRosterProcessor(rosterMananger, _mySubdomain);
AbstractRemoteRosterProcessor updateToComponent = new ClientToComponentUpdateProcessor(_mySubdomain);
_packetProcessor.put("sendRoster", sendroster);
......@@ -65,7 +65,7 @@ public class RemoteRosterInterceptor implements PacketInterceptor {
throws PacketRejectedException {
if (!processed && incoming) {
if (packet instanceof IQ) {
Log.debug("Incomping unprocessed package i might be interested in. Package: \n" + packet.toString()
Log.debug("Incoming unprocessed package i might be interested in. Package: \n" + packet.toString()
+ "\n");
IQ myPacket = (IQ) packet;
if (myPacket.getFrom() == null || myPacket.getTo() == null) {
......@@ -85,8 +85,8 @@ public class RemoteRosterInterceptor implements PacketInterceptor {
}
@SuppressWarnings("unused")
String to = myPacket.getTo().toString();
String from = myPacket.getFrom().toString();
String to = myPacket.getTo().toString();
if (from.equals(_mySubdomain)) {
if (myPacket.getType().equals(IQ.Type.get)
......@@ -98,7 +98,7 @@ public class RemoteRosterInterceptor implements PacketInterceptor {
// Component sends roster update
_packetProcessor.get("receiveChanges").process(packet);
}
} else if (myPacket.getTo().toString().equals(_mySubdomain)
} else if (to.equals(_mySubdomain)
&& myPacket.getType().equals(IQ.Type.get)
&& myPacket.toString().contains("http://jabber.org/protocol/disco#info")) {
/*
......
package org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors;
import java.util.Timer;
import java.util.TimerTask;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.dom4j.tree.DefaultAttribute;
import org.dom4j.tree.DefaultElement;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.RemoteRosterInterceptor;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet;
/**
* This implements a special IQ package for Spark client. Spark checks the
* disco#info package send from external component for a <registered> tag.
* Because spectrum does not support this feature we have to modify the disco
* package from spectrum with the registered tag if the user is registered with
* this gateway. Part of command pattern used in {@link RemoteRosterInterceptor}
*
* @author Holger Bergunde
*
*/
public class DiscoIQRegisteredProcessor extends AbstractRemoteRosterProcessor {
private boolean _isRegistered = false;
private String _mySubdoman;
public DiscoIQRegisteredProcessor(String subdomain) {
Log.debug("Created DiscoIQResigteredProcessor for " + subdomain);
_mySubdoman = subdomain;
}
@Override
public void process(Packet packet) throws PacketRejectedException {
Log.debug("Processing packet in DiscoIQResigteredProcessor for " + _mySubdoman);
// Check if the jabber:iq:register is enabled in admin panel
boolean isFeatureEnabled = JiveGlobals.getBooleanProperty("plugin.remoteroster.sparkDiscoInfo", false);
if (!isFeatureEnabled) {
Log.debug("Spark extension is deactivated. Won't change the disco#info");
return;
}
String from = packet.getFrom().toString();
String to = packet.getTo().toString();
final InterceptorManager interceptorManager = InterceptorManager.getInstance();
final PacketInterceptor interceptor = new PacketInterceptor() {
@Override
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
throws PacketRejectedException {
if (!processed && incoming) {
if (packet instanceof IQ) {
IQ iqPacket = (IQ) packet;
Element packetElement = iqPacket.getChildElement();
if (packetElement == null)
return;
String ns = iqPacket.getChildElement().getNamespace().getURI();
if (iqPacket.getType().equals(IQ.Type.result) && ns.equals("jabber:iq:register")
&& iqPacket.getFrom().toString().equals(_mySubdoman)) {
// Check if we are already registered
setRegistered(iqPacket.toString().contains("<registered/>"));
throw new PacketRejectedException();
} else if (iqPacket.getType().equals(IQ.Type.result)
&& ns.equals("http://jabber.org/protocol/disco#info")
&& iqPacket.getFrom().toString().equals(_mySubdoman)) {
/*
* This is the answer of the disco#info from spark
* to our component. add the jabber:iq:register
* feature if we are registered
*/
if (isRegistered()) {
Log.debug("Modifying disco#info packge to send registered iq feature to Spark user "
+ iqPacket.getTo().toString());
Attribute attribut = new DefaultAttribute("var", "jabber:iq:registered");
iqPacket.getChildElement().addElement("feature").add(attribut);
}
}
}
}
}
};
Log.debug("Creating my own listener for jabber:iq:register result to external component " + _mySubdoman);
interceptorManager.addInterceptor(interceptor);
IQ askComponent = new IQ();
askComponent.setTo(to);
askComponent.setFrom(from);
askComponent.setType(IQ.Type.get);
Element query = new DefaultElement("query");
query.addNamespace("", "jabber:iq:register");
askComponent.setChildElement(query);
// Remove the package intercepter in 1sec
TimerTask removeInterceptorTask = new TimerTask() {
@Override
public void run() {
Log.debug("Removing my created listener for jabber:iq:register. Component " + _mySubdoman);
interceptorManager.removeInterceptor(interceptor);
}
};
Timer timer = new Timer();
timer.schedule(removeInterceptorTask, 1000);
// Send the register query to component
dispatchPacket(askComponent);
}
private boolean isRegistered() {
return _isRegistered;
}
private void setRegistered(boolean bool) {
_isRegistered = bool;
}
}
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