powered by Jive Software

Intercept org.jivesoftware.smack.packet.IQ in Openfire

I want to 1) exchange custom IQ packets between XMPP clients and occasionally 2) intercept them on the server and reject them.

  1. I implemented my own IQ packet class that extends org.jivesoftware.smack.packet.IQ, and a provider that parses such packets by implementing the org.jivesoftware.smack.provider.IQProvider interface. Using the org.jivesoftware.smack.provider.ProviderManager.getInstance().addIQProvider I registered this provider and it works well – two smack-based clients can exchange my custom IQ packet. They can cast the smack.packet.Packet to my custom class and I can invoke any method defined in it.

  2. My openfire plugin implements the PacketInterceptor interface, which gives me a handle to a org.xmpp.packet.Packet that cannot be casted to smack.packet.Packet, thus I cannot use my previously implemented custom IQ packet class and the provider. I’ve done my research and I understand that org.jivesoftware.smack.packet.Packet and org.xmpp.packet.Packet, although they represent the same concept, are not the same classes and are not related to each other (in terms of Java). I understand that Smack will most likely not switch to xmpp.packet, thus if I want to intercept a smack.packet in my Openfire plugin’s code, I need to do some kind of conversion from xmpp.packet to smack.packet in order to use the same providers and custom IQ classes developed for Smack.

Now finally, here is my question - What is the best way of dealing with this issue? Should I convert the xmpp.packet to smack.packet, or should I implement xmpp.packet parser and essentially re-implement my smack provider’s code?

Thanks for help!