class MultiplexerStanzaHandler extends StanzaHandler {

    private static final Logger Log = LoggerFactory.getLogger( MultiplexerStanzaHandler.class );

    /**
     * Handler of IQ packets sent from the Connection Manager to the server.
     */
    private MultiplexerPacketHandler packetHandler;

    public MultiplexerStanzaHandler(PacketRouter router, Connection connection) {
        super(router, connection);
    }

    @Override
    protected void processIQ(final IQ packet) {<FILL_FUNCTION_BODY>}

    @Override
    protected void processMessage(final Message packet) throws UnauthorizedException {
        throw new UnauthorizedException("Message packets are not supported. Original packets " +
                "should be wrapped by route packets.");
    }

    @Override
    protected void processPresence(final Presence packet) throws UnauthorizedException {
        throw new UnauthorizedException("Message packets are not supported. Original packets " +
                "should be wrapped by route packets.");
    }

    /**
     * Process stanza sent by a client that is connected to a connection manager. The
     * original stanza is wrapped in the route element. Only a single stanza must be
     * wrapped in the route element.
     *
     * @param packet the route element.
     */
    private void processRoute(final Route packet) {
        if (!session.isAuthenticated()) {
            // Session is not authenticated so return error
            Route reply = new Route(packet.getStreamID());
            reply.setID(packet.getID());
            reply.setTo(packet.getFrom());
            reply.setFrom(packet.getTo());
            reply.setError(PacketError.Condition.not_authorized);
            session.process(reply);
            return;
        }
        // Process the packet
        packetHandler.route(packet);
    }

    @Override
    boolean processUnknowPacket(Element doc) {
        String tag = doc.getName();
        if ("route".equals(tag)) {
            // Process stanza wrapped by the route packet
            processRoute(new Route(doc));
            return true;
        } else if ("handshake".equals(tag)) {
            if (!((LocalConnectionMultiplexerSession) session).authenticate(doc.getStringValue())) {
                Log.debug( "Closing session that failed to authenticate: {}", session );
                session.close();
            }
            return true;
        } else if ("error".equals(tag) && "stream".equals(doc.getNamespacePrefix())) {
            Log.debug( "Closing session because of received stream error {}. Affected session: {}", doc.asXML(), session );
            session.close();
            return true;
        }
        return false;
    }

    @Override
    Namespace getNamespace() {
        return new Namespace("", "jabber:connectionmanager");
    }

    @Override
    boolean validateHost() {
        return false;
    }

    @Override
    boolean validateJIDs() {
        return false;
    }

    @Override
    void createSession(String serverName, XmlPullParser xpp, Connection connection) throws XmlPullParserException
    {
        // The connected client is a connection manager so create a ConnectionMultiplexerSession
        session = LocalConnectionMultiplexerSession.createSession(serverName, xpp, connection);
        if (session != null) {
            packetHandler = new MultiplexerPacketHandler(session.getAddress().getDomain());
        }
    }

    @Override
    void startTLS() throws Exception {
        connection.startTLS(false, false);
    }
}

        if (!session.isAuthenticated()) {
            // Session is not authenticated so return error
            IQ reply = new IQ();
            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setID(packet.getID());
            reply.setTo(packet.getFrom());
            reply.setFrom(packet.getTo());
            reply.setError(PacketError.Condition.not_authorized);
            session.process(reply);
            return;
        }
        // Process the packet
        packetHandler.handle(packet);
    
<methods>public void <init>(org.jivesoftware.openfire.PacketRouter, org.jivesoftware.openfire.Connection) ,public JID getAddress() ,public void process(java.lang.String, org.dom4j.io.XMPPPacketReader) throws java.lang.Exception,public void setSession(org.jivesoftware.openfire.session.LocalSession) <variables>private static final Logger Log,public static final SystemProperty<java.lang.Boolean> PROPERTY_OVERWRITE_EMPTY_TO,private static final org.jivesoftware.openfire.StreamIDFactory STREAM_ID_FACTORY,protected org.jivesoftware.openfire.Connection connection,protected org.jivesoftware.openfire.PacketRouter router,protected org.jivesoftware.openfire.net.SASLAuthentication.Status saslStatus,protected org.jivesoftware.openfire.session.LocalSession session,protected boolean sessionCreated,protected boolean startedSASL,protected boolean startedTLS,protected boolean waitingCompressionACK