supElementNamePaths not working correctly in Postprocessor

Added over 1 year ago

I have a post processor, and I want to intercept all account registration packets. However, using the Iq.IQ_QUERY_PATH value in supElementNamePaths is not working correctly (it is intercepting all packets). Here is my code:

public class RegistrationInterceptor extends XMPPProcessor implements XMPPPostprocessorIfc {

    private static Logger log = Logger.getLogger(RegistrationInterceptor.class.getName());
    public static final String ID = "myapp:iq:registrationinterceptor";
    private static final String[][] ELEMENT_NAME_PATHS = new String[][]{ Iq.IQ_QUERY_PATH };
    private static final String[] XMLNSS = new String[]{ "jabber:iq:register" };

    public String id() {
        return ID;

    public String[][] supElementNamePaths() {
        return ELEMENT_NAME_PATHS;

    public String[] supNamespaces() {
        return XMLNSS;

    public void postProcess(Packet packet, 
        XMPPResourceConnection session, 
        NonAuthUserRepository repo, 
        Queue<Packet> results, 
        Map<String, Object> settings) {

        // every packet (iq, message, presence, etc.) is being logged here

        if (log.isLoggable(Level.FINEST)) {
            log.finest("Processing packet: " + packet.toString());

Replies (4)


Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 1 year ago

Interfaces XMPPPreprocessorIfc and XMPPPostprocessorIfc@, do not have methods @supNamespaces() and @ supElementNamePaths()@ defined and as a result they are not supported. In methods like preProcess() and postProcess() you will receive every packet which is processed without any filters, so you need to filter those packets on your own.

Methods supNamespaces() and @ supElementNamePaths()@ are part of XMPPProcessor interface and are used to filter only packets being delivered to process() method.

Added by S E over 1 year ago

Ok. I simply looked at this code as a base to implement my own @postProcessor@:

As you can see, they also use supElementNamePaths to filter only message elements. But their postProcessor method also checks to make sure the element is a message. So it means that the supElementNamePaths and supNameSpaces they are using have no effect?

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 1 year ago

Yes, in this case, implementation of those methods has no effect.

Added by S E over 1 year ago

Ok, thank you for the clarification