powered by Jive Software

Packet Intercepting

I’‘ve been writing a PacketInterceptor to work with incoming and outgoing Jabber packets. I’'ve noticed that the javadocs seem to say that if I register the PacketInterceptor as a global interceptor, all packets will pass through it. However, in practice it seems that my PacketInterceptor never gets the chance to examine incoming jabber:iq:auth packets. Are these handled specially by the engine?

Hi Jeff,

Are these handled specially by the engine?

No, how are you looking for jabber:iq:auth packets? I’'ve included some code below that uses a PacketInterceptor that only prints out jabber:iq:auth packets.

Hope that helps,


package org.jivesoftware.messenger.plugin;

import org.dom4j.Element;

import org.jivesoftware.messenger.Session;

import org.jivesoftware.messenger.container.Plugin;

import org.jivesoftware.messenger.container.PluginManager;

import org.jivesoftware.messenger.interceptor.InterceptorManager;

import org.jivesoftware.messenger.interceptor.PacketInterceptor;

import org.jivesoftware.messenger.interceptor.PacketRejectedException;

import org.xmpp.packet.IQ;

import org.xmpp.packet.Packet;

import java.io.File;

public class InterceptorPlugin implements Plugin, PacketInterceptor {

private InterceptorManager interceptorManager;

public InterceptorPlugin() {

interceptorManager = InterceptorManager.getInstance();


public void initializePlugin(PluginManager pm, File f) {



public void destroyPlugin() {



public void interceptPacket(Packet p, Session session, boolean read, boolean processed) throws PacketRejectedException {

if (p instanceof IQ) {

IQ packet = (IQ) p;

Element childElement = (packet).getChildElement();

String namespace = null;

if (childElement != null) {

namespace = childElement.getNamespaceURI();


if (“jabber:iq:auth”.equals(namespace)) {







1 Like

Thanks for your help. It seems the mistake was on my end and that I can, indeed, alter incoming and outgoing authentication packets.

I’‘m trying to implement a system where users may use their email address as their login name. This is how my organization implements its sign on facilities, so I’‘m trying to make our internal IM server function this way as well. I’‘ve decided to create usernames internally in the server as an escaped version of the email address. For example, somebody@somewhere.com should become somebody[at]somewhere.com@server.org. Outgoing packets should make it appear to the client as though it is indeed authenticated by somewhere.com to be somebody. I’'ve made some progress so far, but I have a ways to go before finishing.

I’'m trying to implement a system where users may

use their email address as their login name.

Ah, yes, I remember you question from before about whether or not this was possible.

Good luck!