Hi guys/gals,
I have a big problem, and a looming deadline at the same time.
I am writing a content-filtering plugin which basically takes care of the following:
-
provides an admin interface for defining the bad words list
-
serves this list (in XML format) to the client at login-time
I am stuck at point 2. I first tried to serve this XML file by using a JSP page which is part of the admin-console pages of the plugin - but I bumped into the problem of authentication. When the client needs to open this page, he is greeted by an “Authorization needed” page. I didn’'t know how to solve this problem - how to automatically authenticate the client when he requests the page - without hard-coding the admin pass into the code, so I went to look for another solution.
This other solution was to use an IQ packet in the jabber:iq:private namespace. The idea was to use these type of messages (which are basically used for storing client app preferences on the server, etc) to serve the bad words list. I wrote a plugin extending the IQPrivateHandler class, and overriding the HandleIQ method with the following code:
@Override public IQ handleIQ(IQ packet) throws UnauthorizedException {
IQ resultPacket = IQ.createResultIQ(packet);
Element resultElement = resultPacket.getElement();
resultElement.addElement(“query”, “jabber:iq:private”);
if (packet.getType().equals(IQ.Type.get)) {
Element child = packet.getChildElement();
if (child.getName().equals(“query”) && child.getNamespaceURI().equals(“jabber:iq:private”)) {
boolean badwordsRequest = (child.element(“badwords”) != null);
if (badwordsRequest) {
loadBadWordsXML();
Element badWords = badWordsXMLDocument.getRootElement();
resultElement.element(“query”).add(badWords);
}
return resultPacket;
}
}
return IQ.createResultIQ(packet);
}[/code]
The problem with this approach is that the server somehow strips the contents of the element has to have an enclosing element in its own namespace. But even after I’'ve done this, the server still strips away the data I need.
I think that this behaviour may be related to some un-overriden IQPacketHandler/PrivateStorage method that goes through the database for the packet contents, finds nothing, and returns empty result, while stripping away my data.
So, my question is: how do I get away with this, without the server stripping out the things I need?
Any ideas about how to solve this problem, or other suggestions about the ways that would enable me to send this wordlist to the client will be very much appreciated.
Thanks for your time and patience to read this long post.
Darko
P.S. As I was writing this, I came to the idea to use PrivateStorage instance to add() the data I need programmatically, and let the client to just IQ-get the necessary data. I’'ll try to see if this works tommorow.