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

Gojara - Fixed changed Un-/ registration tracking to look for more specific...

Gojara - Fixed changed Un-/ registration tracking to look for more specific packets, currently spark and gajim compatible, other not tested. Minor Documentation changes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13726 b35dd754-fafc-0310-a699-88a17e54d16e
parent 715c4505
......@@ -44,6 +44,23 @@
GoJara Plugin Changelog
</h1>
<p><b>2.1.2</b> -- Aug 09, 2013</p>
<ul>
<li>Fixed changed Un-/ registration tracking to look for more specific packets, currently spark and gajim compatible, other not tested</li>
</ul>
<p><b>2.1.1</b> -- Aug 01, 2013</p>
<ul>
<li>Made time differences prettier</li>
<li>Renamed Settings page</li>
<li>Hopefully fixed instant-unregister bug</li>
<li>Fixed Mysql schema typo</li>
<li>Change the way gojaraadmin works so we dont actually create a user, better this way for LDAP databases etc</li>
<li>Fixed pagination</li>
</ul>
<p><b>2.1.0</b> -- Jul 25, 2013</p>
<ul>
......
......@@ -9,7 +9,7 @@
<description>ProtoXEP-xxxx: Remote Roster Management support
</description>
<author>Holger Bergunde / Daniel Henninger / Axel-F. Brand</author>
<version>2.1.0</version>
<version>2.1.2</version>
<date>03/19/2013</date>
<databaseKey>gojara</databaseKey>
<databaseVersion>1</databaseVersion>
......
......@@ -14,12 +14,13 @@ import java.util.TimerTask;
import org.apache.log4j.Logger;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.plugin.gojara.sessions.GatewaySession;
import org.jivesoftware.util.JiveGlobals;
/**
* @author Holger Bergunde, Axel-Frederik Brand This class is used to store logs in the database. A log entry is
* representated by {@link LogEntry}
* @author Holger Bergunde
* @author Axel-Frederik Brand
*
* This class is used to store logs in the database. A log entry is representated by {@link LogEntry}
*/
public class DatabaseManager {
......@@ -165,10 +166,10 @@ public class DatabaseManager {
logbuffer.add(new LogEntry(from, to, type, System.currentTimeMillis(), component));
else {
synchronized (logbuffer) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
for (LogEntry log : logbuffer) {
pstmt = con.prepareStatement(ADD_NEW_LOG);
pstmt.setLong(1, log.getDate());
......@@ -179,14 +180,14 @@ public class DatabaseManager {
pstmt.addBatch();
}
pstmt.executeBatch();
} catch (SQLException sqle) {
Log.error(sqle);
} finally {
DbConnectionManager.closeConnection(pstmt, con);
logbuffer.clear();
} catch (SQLException sqle) {
Log.error(sqle);
} finally {
DbConnectionManager.closeConnection(pstmt, con);
logbuffer.clear();
}
}
}
}
}
/**
......
......@@ -5,14 +5,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.dom4j.Element;
import org.dom4j.Node;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.processors.*;
import org.jivesoftware.openfire.plugin.gojara.sessions.GojaraAdminManager;
import org.jivesoftware.openfire.plugin.gojara.sessions.TransportSessionManager;
import org.jivesoftware.openfire.plugin.gojara.utils.XpathHelper;
import org.jivesoftware.openfire.roster.RosterManager;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.ConcurrentHashSet;
......@@ -190,20 +188,45 @@ public class MainInterceptor implements PacketInterceptor {
tSessionManager.disconnectUserFrom(from, packet.getTo().getNode().toString());
}
}
// TransportSession Feature - track Registrations so we can reset unsuccesfull ones
// TransportSession Feature - track Registrations and unregistrations so we can reset unsuccesfull ones
else if (packet instanceof IQ && activeTransports.contains(to)) {
IQ iqPacket = (IQ) packet;
Element query = iqPacket.getChildElement();
if (query == null)
return;
// Check if our jabber:iq:register packet is unregister packet, else it will be a register. If this doesnt work
// like its supposed to, we might need to intercept the iq OF sends to Spectrum instead of the IQ the client sends to OF
// Okay, so now we have a IQ Packet with a query xmlns: jabber:iq:register
// Spark sends registrations and unregistrations in such a query, register has a x xmls
// jabber:iq:gateway:register, unregister is just a <remove/> element
// Gajim sends the whole form with x xmlns jabber:x:data type="submit", where a field var=unregister
// value of 0 is a registration, and unregister = 1 is unregistration
if (query.getNamespaceURI().equals("jabber:iq:register") && iqPacket.getType().equals(IQ.Type.set)) {
// spark unregister
if (query.element("remove") != null)
tSessionManager.removeRegistrationOfUser(to, iqPacket.getFrom().getNode().toString());
else
tSessionManager.registerUserTo(to, iqPacket.getFrom().getNode().toString());
}
else if (query.element("x") != null) {
String namespace = query.element("x").getNamespaceURI();
// spark register
if (namespace.equals("jabber:iq:gateway:register"))
tSessionManager.registerUserTo(to, iqPacket.getFrom().getNode().toString());
// Gajim packet
else if (namespace.equals("jabber:x:data")) {
// .... not really nice, but i dont know xpath so idk how to do this else
@SuppressWarnings("rawtypes")
List list = query.element("x").elements("field");
for (Object ele : list) {
Element e = (Element) ele;
if (e.attributeValue("var").equals("unregister")) {
// register form
if (e.elementText("value").equals("0"))
tSessionManager.registerUserTo(to, iqPacket.getFrom().getNode().toString());
// unregister form
else if (e.elementText("value").equals("1"))
tSessionManager.removeRegistrationOfUser(to, iqPacket.getFrom().getNode().toString());
}
}
}
}
}
}
} else if (!incoming && !processed) {
......
......@@ -53,7 +53,7 @@ public class GojaraAdminManager {
}
/**
* Sends a testmessage to specified gateway and schedules a task to check if there was a response.
* Sends a testmessage to specified gateway, when a response gets intercepted we consider gateway configured
*
*/
public void testAdminConfiguration(String gateway) {
......
......@@ -64,7 +64,7 @@ public class TransportSessionManager {
}
/**
* register is seperate because a user may register to transport but not connect to it, e.g. with wrong credentials.
* register is seperate to connect because a user may register to transport but not connect to it, e.g. with wrong credentials.
* we still want to keep track of those registrations so we know they happened and we can reset them
*
* @param transport
......
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