Commit 9674c91d authored by Axel Brand's avatar Axel Brand Committed by daeva

Gojara 2.1.4 + 2.1.5, See changelog

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13779 b35dd754-fafc-0310-a699-88a17e54d16e
parent 950acddc
......@@ -43,6 +43,21 @@
<h1>
GoJara Plugin Changelog
</h1>
<p><b>2.1.5</b> -- Okt 21, 2013</p>
<ul>
<li>Fixed: Mistakenly sent second unregister command when already unregistering.</li>
<li>Fixed: Only remove tracked user registration from our db when we receive proper response</li>
<li>Better handling of unregisters when in persistent / nonpersistant modes</li>
</ul>
<p><b>2.1.4</b> -- Okt 15, 2013</p>
<ul>
<li>Added option to disable presence Pushing that we implemented for Spark but may cause trouble with other clients.</li>
<li>Added option to let user decide if he wants subdomains to show up as contact on roster</li>
</ul>
<p><b>2.1.3</b> -- Aug 20, 2013</p>
<ul>
......
......@@ -9,8 +9,8 @@
<description>ProtoXEP-xxxx: Remote Roster Management support
</description>
<author>Holger Bergunde / Daniel Henninger / Axel-F. Brand</author>
<version>2.1.3</version>
<date>03/19/2013</date>
<version>2.1.5</version>
<date>10/21/2013</date>
<databaseKey>gojara</databaseKey>
<databaseVersion>1</databaseVersion>
<minServerVersion>3.7.0</minServerVersion>
......
......@@ -54,11 +54,11 @@ public class MainInterceptor implements PacketInterceptor {
public MainInterceptor() {
Log.info("Created MainInterceptor for GoJara Plugin.");
server = XMPPServer.getInstance();
RosterManager rosterMananger = server.getRosterManager();
RosterManager rosterManager = server.getRosterManager();
AbstractRemoteRosterProcessor iqRegisteredProcessor = new DiscoIQRegisteredProcessor();
AbstractRemoteRosterProcessor iqRosterPayloadProcessor = new IQRosterPayloadProcessor(rosterMananger);
AbstractRemoteRosterProcessor nonPersistantProcessor = new NonPersistantRosterProcessor(rosterMananger);
AbstractRemoteRosterProcessor iqRosterPayloadProcessor = new IQRosterPayloadProcessor(rosterManager);
AbstractRemoteRosterProcessor nonPersistantProcessor = new NonPersistantRosterProcessor(rosterManager);
AbstractRemoteRosterProcessor statisticsProcessor = new StatisticsProcessor();
AbstractRemoteRosterProcessor updateToComponentProcessor = new ClientToComponentUpdateProcessor(activeTransports);
AbstractRemoteRosterProcessor whitelistProcessor = new WhitelistProcessor(activeTransports);
......@@ -150,7 +150,7 @@ public class MainInterceptor implements PacketInterceptor {
return;
// Jabber:IQ:roster Indicates Client to Component update or Rosterpush
else if (query.getNamespaceURI().equals("jabber:iq:roster")) {
if (to.length() == 0 && iqPacket.getType().equals(IQ.Type.set))
if (!activeTransports.contains(from) && to.length() == 0 && iqPacket.getType().equals(IQ.Type.set))
packetProcessors.get("clientToComponentUpdate").process(packet, "", to, from);
else if (from.length() > 0 && activeTransports.contains(from))
packetProcessors.get("iqRosterPayload").process(packet, from, to, from);
......@@ -214,7 +214,7 @@ public class MainInterceptor implements PacketInterceptor {
if (query.getNamespaceURI().equals("jabber:iq:register") && iqPacket.getType().equals(IQ.Type.set)) {
// spark + gajim unregister
if (query.element("remove") != null)
tSessionManager.removeRegistrationOfUser(to, iqPacket.getFrom().getNode().toString());
tSessionManager.removeRegistrationOfUserFromDB(to, iqPacket.getFrom().getNode().toString());
else if (query.element("x") != null) {
Element xElem = query.element("x");
String xNamespace = xElem.getNamespaceURI();
......@@ -264,7 +264,7 @@ public class MainInterceptor implements PacketInterceptor {
}
}
} else if (packet instanceof Presence) {
} else if (JiveGlobals.getBooleanProperty("plugin.remoteroster.blockPresences", true) && packet instanceof Presence) {
/*
* We block Presences to users of a subdomain (except transport itself) so OF/S2 wont log you in
* automatically if you have a subdomain user in your roster. This prevents some clients from logging
......
package org.jivesoftware.openfire.plugin.gojara.messagefilter.processors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager;
import org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager;
......@@ -31,7 +34,7 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor {
if (command.equals("online_users")) {
handleOnlineUsers(message, subdomain);
} else if (command.equals("unregister")) {
handleUnregister(message);
handleUnregister(message, subdomain);
} else if (command.equals("config_check")) {
handleConfigCheck(subdomain);
} else if (command.equals("uptime")) {
......@@ -59,8 +62,18 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor {
}
}
private void handleUnregister(Message message) {
private void handleUnregister(Message message, String subdomain) {
Log.debug("Found unregister command! ");
String body = message.getBody();
Pattern p = Pattern.compile("^User '(.+)' unregistered.");
Matcher m = p.matcher(body);
if (m.matches()) {
String user = m.group(1);
JID userJid = new JID(user);
transportSessionManager.removeRegistrationOfUserFromDB(subdomain, userJid.getNode());
Log.debug("unregister command was successfull for user: " + userJid.getNode());
}
}
private void handleConfigCheck(String subdomain) {
......
......@@ -3,6 +3,8 @@ package org.jivesoftware.openfire.plugin.gojara.messagefilter.processors;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.dom4j.Element;
import org.dom4j.Node;
......@@ -20,13 +22,10 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
/**
* This class implements the XEP-xxx Remote Roster Management standard
* "2.3 Server or component requests user's roster". Part of command pattern
* used in {@link RemoteRosterInterceptor}
* This class implements the XEP-xxx Remote Roster Management standard "2.3 Server or component requests user's roster".
* Part of command pattern used in {@link RemoteRosterInterceptor}
*
* Further information: <a
* href="http://jkaluza.fedorapeople.org/remote-roster.html#sect-id215516"
* >Here</a>
* Further information: <a href="http://jkaluza.fedorapeople.org/remote-roster.html#sect-id215516" >Here</a>
*
* @author Holger Bergunde
* @author axel.frederik.brand
......@@ -79,7 +78,8 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
response.setTo(subdomain);
Element query = new DefaultElement("query");
for (RosterItem i : items) {
if (i.getJid().toString().contains(subdomain)) {
String jid = i.getJid().toString();
if (!jid.equals(subdomain) && jid.contains(subdomain)) {
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()));
......@@ -109,7 +109,7 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
dispatchPacket(response);
}
private void handleIQset(IQ myPacket, String subdomain, String username) throws PacketRejectedException {
private void handleIQset(IQ myPacket, final String subdomain, final String username) throws PacketRejectedException {
IQ response = IQ.createResultIQ(myPacket);
List<Node> nodes = findNodesInDocument(myPacket.getElement().getDocument(), "//roster:item");
......@@ -123,7 +123,8 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
// reject that packet, it seems openfire itself
// can interpret the iq:roster remove stanzas in some way, this was
// causing trouble on register:remove
if (jid.equals(subdomain))
if (JiveGlobals.getBooleanProperty("plugin.remoteroster.ignoreSubdomains", true) && jid.equals(subdomain)
&& subvalue.equals("both"))
throw new PacketRejectedException();
if (subvalue.equals("both")) {
......@@ -150,24 +151,47 @@ public class IQRosterPayloadProcessor extends AbstractRemoteRosterProcessor {
item.setSubStatus(RosterItem.SUB_BOTH);
roster.updateRosterItem(item);
} catch (Exception e) {
Log.debug("Could not add user to Roster although no entry should exist..." + username, e);
e.printStackTrace();
Log.info("Could not add user to Roster although no entry should exist..." + username, e);
}
dispatchPacket(response);
} else if (subvalue.equals("remove")) {
// check if its the right package to initiate unregister removal of contacts
// we dont need to do this when persistent = false because they will get deleted as soon as gateway is unavailable
if (JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false) && jid.equals(subdomain)) {
deleteSubdomainItemsFromRoster(username, subdomain);
}
// in ANY case, if its a roster:remove, we want to reject packet, as it causes errors if Openfire tries
// to handle it
throw new PacketRejectedException();
}
}
}
/**
* Searches the users roster for a specific subdomain and deletes all contacts that contain subdomain
*
* @param username
* @param subdomain
*/
private void deleteSubdomainItemsFromRoster(String username, String subdomain) {
try {
roster = _rosterManager.getRoster(username);
roster.deleteRosterItem(new JID(jid), false);
Log.debug("Removed contact " + jid + " from contact list of " + username);
} catch (UserNotFoundException e) {
Log.debug("Could not find user while cleaning up the roster in GoJara for user " + username, e);
response.setType(IQ.Type.error);
} catch (SharedGroupException e) {
// We should ignore this. External contacts cannot be in
// shared groups
Roster roster = _rosterManager.getRoster(username);
Collection<RosterItem> items = roster.getRosterItems();
for (RosterItem item : items) {
String itemName = item.getJid().toString();
if (itemName.contains(subdomain)) {
Log.debug("Removing contact " + item.getJid().toString() + " from contact list because of Unregister.");
roster.deleteRosterItem(item.getJid(), false);
}
}
dispatchPacket(response);
} catch (UserNotFoundException e) {
Log.debug("Couldnt find User!" + e.toString());
} catch (SharedGroupException e) {
e.printStackTrace();
}
}
}
......@@ -42,7 +42,7 @@ public class NonPersistantRosterProcessor extends AbstractRemoteRosterProcessor
Collection<RosterItem> items = roster.getRosterItems();
for (RosterItem item : items) {
String itemName = item.getJid().toString();
if (itemName.contains(subdomain) && !itemName.equals(subdomain)) {
if (itemName.contains(subdomain)) {
Log.debug("Removing contact " + item.getJid().toString() + " from contact list.");
roster.deleteRosterItem(item.getJid(), false);
......
......@@ -134,15 +134,15 @@ public class GojaraAdminManager {
*
* @param transport
*/
public void unregisterUserFrom(String transport, String user) {
public String unregisterUserFrom(String transport, String user) {
if (unconfiguredGateways.contains(transport))
return;
return "Gateway " + transport + "is not active. Didn't send unregister for "+ user+".";
Message message = generateCommand(transport, "unregister");
message.setBody("unregister " + _server.createJID(user, null).toString());
router.route(message);
Log.debug("Sent Unregister Packet!" + message.toString());
return "Sent unregister Packet for user: "+user;
}
public void putStatisticValue(String subdomain, String statistic, int value) {
......
......@@ -107,25 +107,15 @@ public class TransportSessionManager {
/**
*
* Removing a registration will cause a unregister msg being sent to Spectrum2 for this specific User/Gateway
* combination Also it will be removed from our db. For this to happen the transport has to be active.
* Removes registration from our database.
*
* @param transport
* @param user
* @return String that describes what happened.
*/
public String removeRegistrationOfUser(String transport, String user) {
adminManager.unregisterUserFrom(transport, user);
int result = db.removeSessionEntry(transport, user);
if (result == 0) {
return "Did not remove entry for user: " + user + " and transport: " + transport + "\n";
} else if (result == 1) {
return "Successfully removed entry for user: " + user + " and transport: " + transport + " \n";
} else {
return "What is happening ???: " + result;
public void removeRegistrationOfUserFromDB(String transport, String user) {
db.removeSessionEntry(transport, user);
}
}
/**
* Initializes Sessions through adminmanager, ofc needs to be called at a point where there are Transports registered in
* transportSessions
......
......@@ -49,7 +49,7 @@
String[] uservalues = request.getParameterValues(key.toString());
for (String transport : uservalues) {
%>
<li><%=transportManager.removeRegistrationOfUser(transport, key.toString())%></li>
<li><%=gojaraAdminManager.unregisterUserFrom(transport, key.toString())%></li>
<%
}
}
......
......@@ -52,7 +52,7 @@
for (String key : unregister) {
%>
<li><%=transportManager.removeRegistrationOfUser(key, username)%></li>
<li><%=gojaraAdminManager.unregisterUserFrom(key, username)%></li>
<%
}
%>
......
......@@ -22,6 +22,11 @@
String persistentRosterParam = request.getParameter("persistentEnabled");
boolean persistentRoster = persistentRosterParam == null? false : persistentRosterParam.equals("true");
String ignoreSubdomainsParam = request.getParameter("ignoreSubdomains");
boolean ignnoreSubdomains = ignoreSubdomainsParam == null ? false : ignoreSubdomainsParam.equals("true");
String blockPresencesParam = request.getParameter("blockPresences");
boolean blockPresences = blockPresencesParam == null ? false : blockPresencesParam.equals("true");
String sparkdiscoParam = request.getParameter("sparkDiscoInfo");
boolean sparkDiscoInfo = sparkdiscoParam == null ? false : sparkdiscoParam.equals("true");
......@@ -53,10 +58,12 @@
}
}
JiveGlobals.setProperty("plugin.remoteroster.persistent", (persistentRoster ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.blockPresences", (blockPresences ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.sparkDiscoInfo", (sparkDiscoInfo ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.iqLastFilter", (iqLastFilter ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.mucFilter", (mucFilter ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.gajimBroadcast", (gajimBroadcast ? "true" : "false"));
JiveGlobals.setProperty("plugin.remoteroster.ignoreSubdomains", (ignnoreSubdomains ? "true" : "false"));
response.sendRedirect("rr-main.jsp?success=true");
return;
}
......@@ -302,7 +309,7 @@
<td align="left" style="font-size: -3; color: grey">When Persistent-Roster is enabled, contacts will be saved to database and
no contacts will be deleted by GoJara automatically.<br>
When Persistent-Roster is disabled, contacts will not be saved to database and
GoJara will automatically delete all Legacy-RosterItems from the OF-Roster of a User upon logout. </td>
GoJara will automatically delete all Legacy-RosterItems from the OF-Roster of a User upon logout.<br>Enable this if you have a good reason to need it. </td>
</tr>
<tr>
<td><input type="checkbox" name="mucFilter" id="GO2" value="true"
......@@ -317,6 +324,20 @@
can remove these.</td>
</tr>
<tr>
<td><input type="checkbox" name="ignoreSubdomains" id="GO3" value="true"
<%=JiveGlobals.getBooleanProperty("plugin.remoteroster.ignoreSubdomains", true) ? "checked=\"checked\"" : ""%> />
</td>
<td><label for="GO2">Do not add Subdomains to Roster</label></td>
</tr>
<tr>
<td />
<td align="left" style="font-size: -3; color: grey">If you do not want the gateway itself to show up as a contact on your roster,
enable this (only happens on registration).
</td>
</tr>
</tbody>
</table>
</td>
......@@ -364,6 +385,26 @@
This feature is not supported by spectrum so it won't response to this IQ stanza. To prevent the client from waiting
for a response we could answer with a service-unavailable message as described in XEP-12.</td>
</tr>
<tr>
<td><input type="checkbox" name="blockPresences" id="SDI3" value="true"
<%=JiveGlobals.getBooleanProperty("plugin.remoteroster.blockPresences", true) ? "checked=\"checked\""
: ""%> />
</td>
<td><label for="SDI">Block presence pushing to rosterItems except gateway</label></td>
</tr>
<tr>
<td />
<td align="left" style="font-size: -3; color: grey">Openfire automatically pushes Presences to every Item on your Roster.
For Spark, this means that roster items which are imported through gateway will trigger automatic login, even if you configured
Spark to not connect to these gateways on Startup.
Block Presences if you use Spark.</td>
</tr>
</tbody>
</table>
</td>
......@@ -384,7 +425,7 @@
<td />
<td align="left" style="font-size: -3; color: grey">Enable this if Gojara should push available presences to
transports from your roster on startup. If disabled, you have to manually send an available presence to the specific
transport to connect to it.</td>
transport to connect to it. (Not needed you dont add Subdomains to roster + disabled presence blocking.)</td>
</tr>
</tbody>
</table>
......
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