Java Code Examples for org.xmpp.packet.IQ#setChildElement()

The following examples show how to use org.xmpp.packet.IQ#setChildElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentStanzaHandler.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
protected void processIQ(IQ packet) throws UnauthorizedException {
    if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
        // 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;
    }
    // Keep track of the component that sent an IQ get/set
    if (packet.getType() == IQ.Type.get || packet.getType() == IQ.Type.set) {
        // Handle subsequent bind packets
        LocalComponentSession componentSession = (LocalComponentSession) session;
        // Get the external component of this session
        LocalComponentSession.LocalExternalComponent component =
                (LocalComponentSession.LocalExternalComponent) componentSession.getExternalComponent();
        component.track(packet);
    }
    super.processIQ(packet);
}
 
Example 2
Source File: NodeSubscription.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the current subscription status to the user that tried to create a subscription to
 * the node. The subscription status is sent to the subsciber after the subscription was
 * created or if the subscriber tries to subscribe many times and the node does not support
 * multpiple subscriptions.
 *
 * @param originalRequest the IQ packet sent by the subscriber to create the subscription.
 */
void sendSubscriptionState(IQ originalRequest) {
    IQ result = IQ.createResultIQ(originalRequest);
    Element child = result.setChildElement("pubsub", "http://jabber.org/protocol/pubsub");
    Element entity = child.addElement("subscription");
    if (!node.isRootCollectionNode()) {
        entity.addAttribute("node", node.getUniqueIdentifier().getNodeId());
    }
    entity.addAttribute("jid", getJID().toString());
    if (node.isMultipleSubscriptionsEnabled()) {
        entity.addAttribute("subid", getID());
    }
    entity.addAttribute("subscription", getState().name());
    Element subscribeOptions = entity.addElement("subscribe-options");
    if (node.isSubscriptionConfigurationRequired() && isConfigurationPending()) {
        subscribeOptions.addElement("required");
    }
    // Send the result
    node.getService().send(result);
}
 
Example 3
Source File: IQSharedGroupHandler.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
    IQ result = IQ.createResultIQ(packet);
    String username = packet.getFrom().getNode();
    if (!serverName.equals(packet.getFrom().getDomain()) || username == null) {
        // Users of remote servers are not allowed to get their "shared groups". Users of
        // remote servers cannot have shared groups in this server.
        // Besides, anonymous users do not belong to shared groups so answer an error
        result.setChildElement(packet.getChildElement().createCopy());
        result.setError(PacketError.Condition.not_allowed);
        return result;
    }

    Collection<Group> groups = rosterManager.getSharedGroups(username);
    Element sharedGroups = result.setChildElement("sharedgroup",
            "http://www.jivesoftware.org/protocol/sharedgroup");
    for (Group sharedGroup : groups) {
        String displayName = sharedGroup.getProperties().get("sharedRoster.displayName");
        if (displayName != null) {
            sharedGroups.addElement("group").setText(displayName);
        }
    }
    return result;
}
 
Example 4
Source File: Node.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the list of affiliations with the node to the owner that sent the IQ
 * request.
 *
 * @param iqRequest IQ request sent by an owner of the node.
 */
void sendAffiliations(IQ iqRequest) {
    IQ reply = IQ.createResultIQ(iqRequest);
    Element childElement = iqRequest.getChildElement().createCopy();
    reply.setChildElement(childElement);
    Element affiliations = childElement.element("affiliations");

    for (NodeAffiliate affiliate : affiliates) {
        if (affiliate.getAffiliation() == NodeAffiliate.Affiliation.none) {
            continue;
        }
        Element entity = affiliations.addElement("affiliation");
        entity.addAttribute("jid", affiliate.getJID().toString());
        entity.addAttribute("affiliation", affiliate.getAffiliation().name());
    }
    // Send reply
    getService().send(reply);
}
 
Example 5
Source File: Node.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Sends the list of subscriptions with the node to the owner that sent the IQ
 * request.
 *
 * @param iqRequest IQ request sent by an owner of the node.
 */
void sendSubscriptions(IQ iqRequest) {
    IQ reply = IQ.createResultIQ(iqRequest);
    Element childElement = iqRequest.getChildElement().createCopy();
    reply.setChildElement(childElement);
    Element subscriptions = childElement.element("subscriptions");

    for (NodeAffiliate affiliate : affiliates) {
        for (NodeSubscription subscription : affiliate.getSubscriptions()) {
            if (subscription.isAuthorizationPending()) {
                continue;
            }
            Element entity = subscriptions.addElement("subscription");
            entity.addAttribute("jid", subscription.getJID().toString());
            //entity.addAttribute("affiliation", affiliate.getAffiliation().name());
            entity.addAttribute("subscription", subscription.getState().name());
            if (isMultipleSubscriptionsEnabled()) {
                entity.addAttribute("subid", subscription.getID());
            }
        }
    }
    // Send reply
    getService().send(reply);
}
 
Example 6
Source File: OfMeetPlugin.java    From openfire-ofmeet-plugin with Apache License 2.0 6 votes vote down vote up
public void sessionDestroyed(Session session)
{
    Log.debug("OfMeet Plugin -  sessionDestroyed "+ session.getAddress().toString() + "\n" + ((ClientSession) session).getPresence().toXML());

    boolean skypeAvailable = XMPPServer.getInstance().getPluginManager().getPlugin("ofskype") != null;

    if (OfMeetAzure.skypeids.containsKey(session.getAddress().getNode()))
    {
        String sipuri = OfMeetAzure.skypeids.remove(session.getAddress().getNode());

        IQ iq = new IQ(IQ.Type.set);
        iq.setFrom(session.getAddress());
        iq.setTo(XMPPServer.getInstance().getServerInfo().getXMPPDomain());

        Element child = iq.setChildElement("request", "http://igniterealtime.org/protocol/ofskype");
        child.setText("{'action':'stop_skype_user', 'sipuri':'" + sipuri + "'}");
        XMPPServer.getInstance().getIQRouter().route(iq);

        Log.info("OfMeet Plugin - closing skype session " + sipuri);
    }
}
 
Example 7
Source File: IQPrivacyHandler.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * User has specified a new active list that should be used for the current session.
 *
 * @param packet IQ packet setting new active list for the current session.
 * @param from sender of the IQ packet.
 * @param listName name of the new active list for the current session.
 * @return acknowledge of success.
 */
private IQ setActiveList(IQ packet, JID from, String listName) {
    IQ result = IQ.createResultIQ(packet);
    Element childElement = packet.getChildElement().createCopy();
    result.setChildElement(childElement);

    // Get the list
    PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
    if (list != null) {
        // Get the user session
        ClientSession session = sessionManager.getSession(from);
        if (session != null) {
            // Set the new active list for this session
            session.setActiveList(list);
        }
    }
    else {
        // List not found
        result.setError(PacketError.Condition.item_not_found);
    }
    return result;
}
 
Example 8
Source File: IQPEPHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public IQ handleIQ(IQ packet) {
    // Do nothing if server is not enabled
    if (!isEnabled()) {
        IQ reply = IQ.createResultIQ(packet);
        reply.setChildElement(packet.getChildElement().createCopy());
        reply.setError(PacketError.Condition.service_unavailable);
        return reply;
    }

    if (packet.getTo() == null || packet.getTo().equals( new JID(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) )
    {
        // packet addressed to service itself (not to a node/user)
        switch ( packet.getType() )
        {
            case set:
                return handleIQSetToService(packet );
            case get:
                return handleIQGetToService(packet );
            default:
                return null; // Ignore 'error' and 'result' stanzas.
        }
    }
    else
    {
        // packet was addressed to a node.
        if ( packet.isRequest() ) {
            return handleIQRequestToUser( packet );
        } else {
            return null; // Ignore IQ packets of type 'error' or 'result'.
        }
    }
}
 
Example 9
Source File: XmppPubSubControllerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private XmppRetract buildXmppRetract() {
    IQ iq = new IQ(IQ.Type.set);
    iq.setTo(toJid);
    iq.setFrom(fromJid);
    Element element = new DefaultElement(pubSub, Namespace.get(XmppPubSubConstants.PUBSUB_NAMESPACE));
    Element retractElement = new DefaultElement(retract).addAttribute(node, nodeAttribute);
    Element itemElement = new DefaultElement(item).addAttribute(id, itemId);
    retractElement.add(itemElement);
    element.add(retractElement);
    iq.setChildElement(element);
    XmppRetract xmppRetract = new XmppRetract(iq);
    return xmppRetract;
}
 
Example 10
Source File: InternalComponentManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
     *  Send a disco#info request to the new component. If the component provides information
     *  then it will be added to the list of discoverable server items.
     *
     * @param component the new component that was added to this manager.
     * @param componentJID the XMPP address of the new component.
     */
    private void checkDiscoSupport(Component component, JID componentJID) {
        // Build a disco#info request that will be sent to the component
        IQ iq = new IQ(IQ.Type.get);
        iq.setFrom(getAddress());
        iq.setTo(componentJID);
        iq.setChildElement("query", "http://jabber.org/protocol/disco#info");
        // Send the disco#info request to the component. The reply (if any) will be processed in
        // #process(Packet)
//        sendPacket(component, iq);
        component.processPacket(iq);
    }
 
Example 11
Source File: SoftwareServerVersionManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public void sessionCreated(Session session) {
    try {
        IQ versionRequest = new IQ(IQ.Type.get);
        versionRequest.setTo(session.getAddress());
        versionRequest.setFrom(session.getServerName());
        versionRequest.setChildElement("query", "jabber:iq:version");
        session.process(versionRequest);
    } catch (Exception e) {
        Log.error("Exception while trying to query a server for its software version.", e);;
    }
   
}
 
Example 12
Source File: IQPrivacyHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private IQ deleteList(IQ packet, JID from, String listName) {
    ClientSession currentSession;
    IQ result = IQ.createResultIQ(packet);
    Element childElement = packet.getChildElement().createCopy();
    result.setChildElement(childElement);
    // Get the list to delete
    PrivacyList list = manager.getPrivacyList(from.getNode(), listName);

    if (list == null) {
        // List to delete was not found
        result.setError(PacketError.Condition.item_not_found);
        return result;
    }
    else {
        currentSession = sessionManager.getSession(from);
        // Check if the list is being used by another session
        for (ClientSession session : sessionManager.getSessions(from.getNode())) {
            if (currentSession == session) {
                // Ignore the active session for this checking
                continue;
            }
            if (list.equals(session.getDefaultList()) || list.equals(session.getActiveList())) {
                // List to delete is being used by another session so return a conflict error
                result.setError(PacketError.Condition.conflict);
                return result;
            }
        }
    }
    // Remove the list from the active session (if it was being used)
    if (list.equals(currentSession.getDefaultList())) {
        currentSession.setDefaultList(null);
    }
    if (list.equals(currentSession.getActiveList())) {
        currentSession.setActiveList(null);
    }
    manager.deletePrivacyList(from.getNode(), listName);
    return result;
}
 
Example 13
Source File: IQBlockingHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.
 *
 * @param user      The for which updates are to be broadcasted (cannot be null).
 * @param newBlocks The JIDs for which an update needs to be sent (cannot be null, can be empty).
 */
protected void pushBlocklistUpdates( User user, List<JID> newBlocks )
{
    if ( newBlocks.isEmpty() )
    {
        return;
    }

    Log.debug( "Pushing blocklist updates to all resources of user '{}' that have previously requested the blocklist.", user.getUsername() );

    final Collection<ClientSession> sessions = sessionManager.getSessions( user.getUsername() );
    for ( final ClientSession session : sessions )
    {
        if ( session.hasRequestedBlocklist() )
        {
            final IQ iq = new IQ( IQ.Type.set );
            iq.setTo( session.getAddress() );
            final Element block = iq.setChildElement( "block", NAMESPACE );
            for ( final JID newBlock : newBlocks )
            {
                block.addElement( "item" ).addAttribute( "jid", newBlock.toString() );
            }

            XMPPServer.getInstance().getPacketRouter().route( iq );
        }
    }
}
 
Example 14
Source File: IQBlockingHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.
 *
 * @param user      The for which updates are to be broadcasted (cannot be null).
 * @param newBlocks The JIDs for which an update needs to be sent (cannot be null, can be empty).
 */
protected void pushBlocklistUpdates( User user, Collection<JID> newBlocks )
{
    if ( newBlocks.isEmpty() )
    {
        return;
    }

    Log.debug( "Pushing blocklist updates to all resources of user '{}' that have previously requested the blocklist.", user.getUsername() );

    final Collection<ClientSession> sessions = sessionManager.getSessions( user.getUsername() );
    for ( final ClientSession session : sessions )
    {
        if ( session.hasRequestedBlocklist() )
        {
            final IQ iq = new IQ( IQ.Type.set );
            iq.setTo( session.getAddress() );
            final Element block = iq.setChildElement( "unblock", NAMESPACE );
            for ( final JID newBlock : newBlocks )
            {
                block.addElement( "item" ).addAttribute( "jid", newBlock.toString() );
            }

            XMPPServer.getInstance().getPacketRouter().route( iq );
        }
    }
}
 
Example 15
Source File: IQPrivacyHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * User has specified a new default list that should be used for all session.
 *
 * @param packet IQ packet setting new default list for all sessions.
 * @param from sender of the IQ packet.
 * @param listName name of the new default list for all sessions.
 * @return acknowledge of success.
 */
private IQ setDefaultList(IQ packet, JID from, String listName) {
    IQ result = IQ.createResultIQ(packet);
    Element childElement = packet.getChildElement().createCopy();
    result.setChildElement(childElement);

    if (sessionManager.getSessionCount(from.getNode()) > 1) {
        // Current default list is being used by more than one session
        result.setError(PacketError.Condition.conflict);
    }
    else {
        // Get the list
        PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
        if (list != null) {
            // Get the user session
            ClientSession session = sessionManager.getSession(from);
            PrivacyList oldDefaultList = session.getDefaultList();
            manager.changeDefaultList(from.getNode(), list, oldDefaultList);
            // Set the new default list for this session (the only existing session)
            session.setDefaultList(list);
        }
        else {
            // List not found
            result.setError(PacketError.Condition.item_not_found);
        }
    }
    return result;
}
 
Example 16
Source File: LocalConnectionMultiplexerSession.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Send to the Connection Manager the connection options available for clients. The info
 * to send includes:
 * <ul>
 *  <li>if TLS is available, optional or required
 *  <li>SASL mechanisms available before TLS is negotiated
 *  <li>if compression is available
 *  <li>if Non-SASL authentication is available
 *  <li>if In-Band Registration is available
 * </ul
 */
private void sendClientOptions() {

    final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
    final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.SOCKET_C2S, false ).generateConnectionConfiguration();

    IQ options = new IQ(IQ.Type.set);
    Element child = options.setChildElement("configuration",
            "http://jabber.org/protocol/connectionmanager");
    // Add info about TLS
    if (configuration.getTlsPolicy() != Connection.TLSPolicy.disabled) {
        Element tls = child.addElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls");
        if (configuration.getTlsPolicy() == Connection.TLSPolicy.required) {
            tls.addElement("required");
        }

    }
    // Add info about SASL mechanisms
    Collection<String> mechanisms = SASLAuthentication.getSupportedMechanisms();
    if (!mechanisms.isEmpty()) {
        Element sasl = child.addElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl");
        for (String mechanism : mechanisms) {
            sasl.addElement("mechanism").setText(mechanism);
        }
    }
    // Add info about Stream Compression
    if (configuration.getCompressionPolicy() == Connection.CompressionPolicy.optional) {
        Element comp = child.addElement("compression", "http://jabber.org/features/compress");
        comp.addElement("method").setText("zlib");
    }
    // Add info about Non-SASL authentication
    if (XMPPServer.getInstance().getIQRouter().supports("jabber:iq:auth")) {
        child.addElement("auth", "http://jabber.org/features/iq-auth");
    }
    // Add info about In-Band Registration
    if (XMPPServer.getInstance().getIQRegisterHandler().isInbandRegEnabled()) {
        child.addElement("register", "http://jabber.org/features/iq-register");
    }
    // Send the options
    process(options);
}
 
Example 17
Source File: EntityCapabilitiesManagerTest.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Tests the CAPS verification string generation based on the
 * "Simple Generation Example" provided in section 5.2 of XEP-0115 (version
 * 1.4 and later).
 */
@Test
public void testSimpleGenerationExample() throws Exception {
    // formulate the result stanza
    final IQ iq = new IQ(IQ.Type.result);
    iq.setFrom("[email protected]/chamber");
    iq.setTo("[email protected]");
    iq.setID("simpleexample1");

    final Element query = iq.setChildElement("query",
            "http://jabber.org/protocol/disco#info");

    // Consider an entity whose category is "client", whose service
    // discovery type is "pc", service discovery name is "Exodus 0.9.1"
    // (...)
    final Element identity = query.addElement("identity");
    identity.addAttribute("category", "client");
    identity.addAttribute("type", "pc");
    identity.addAttribute("name", "Exodus 0.9.1");

    // (...) and whose supported features are
    // "http://jabber.org/protocol/disco#info",
    // "http://jabber.org/protocol/disco#items",
    // "http://jabber.org/protocol/muc" and
    // "http://jabber.org/protocol/caps"
    query.addElement("feature").addAttribute("var",
            "http://jabber.org/protocol/disco#info");
    query.addElement("feature").addAttribute("var",
            "http://jabber.org/protocol/disco#items");
    query.addElement("feature").addAttribute("var",
            "http://jabber.org/protocol/muc");
    query.addElement("feature").addAttribute("var",
            "http://jabber.org/protocol/caps");

    // Using the SHA-1 algorithm (...)
    final String verification = EntityCapabilitiesManager.generateVerHash(
            iq, "sha-1");

    // the verification string result must be QgayPKawpkPSDYmwT/WM94uAlu0=
    assertEquals("QgayPKawpkPSDYmwT/WM94uAlu0=", verification);
}
 
Example 18
Source File: EntityCapabilitiesManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public void process(Presence packet) {
    if (Presence.Type.unavailable == packet.getType()) {
        if (packet.getFrom() != null ) {
            this.capabilitiesBeingUpdated.remove( packet.getFrom() );
            final String oldVer = this.entityCapabilitiesUserMap.remove( packet.getFrom() );
            if ( oldVer != null ) {
                checkObsolete( oldVer );
            }
        }
        return;
    }

    // Examine the packet and check if it has caps info,
    // if not -- do nothing by returning.
    Element capsElement = packet.getChildElement("c", "http://jabber.org/protocol/caps");
    if (capsElement == null) {
        return;
    }

    // Examine the packet and check if it's in legacy format (pre version 1.4
    // of XEP-0115). If so, do nothing by returning.
    // TODO: if this packet is in legacy format, we SHOULD check the 'node',
    // 'ver', and 'ext' combinations as specified in the archived version
    // 1.3 of the specification, and cache the results. See JM-1447
    final String hashAttribute = capsElement.attributeValue("hash");
    if (hashAttribute == null || hashAttribute.trim().length() == 0) {
        return;
    }
    
    // Examine the packet and check if it has and a 'ver' hash
    // if not -- do nothing by returning.
    final String newVerAttribute = capsElement.attributeValue("ver");
    if (newVerAttribute == null || newVerAttribute.trim().length() == 0) {
        return;
    }

    // Check to see if the 'ver' hash is already in our cache.
    EntityCapabilities caps;
    if ((caps = entityCapabilitiesMap.get(newVerAttribute)) != null) {
        // The 'ver' hash is in the cache already, so let's update the
        // entityCapabilitiesUserMap for the user that sent the caps
        // packet.
        Log.trace( "Registering 'ver' (for recognized caps) for {}", packet.getFrom() );
        registerCapabilities( packet.getFrom(), caps );
    }
    else {
        // If this entity previously had another registration, that now no longer is valid.
        final String ver = entityCapabilitiesUserMap.remove(packet.getFrom());
        if ( ver != null ) {
            capabilitiesBeingUpdated.put( packet.getFrom(), ver );
        }

        // The 'ver' hash is not in the cache so send out a disco#info query
        // so that we may begin recognizing this 'ver' hash.
        IQ iq = new IQ(IQ.Type.get);
        iq.setTo(packet.getFrom());

        String serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
        iq.setFrom(serverName);

        iq.setChildElement("query", "http://jabber.org/protocol/disco#info");

        String packetId = iq.getID();
        
        caps = new EntityCapabilities();
        caps.setHashAttribute(hashAttribute);
        caps.setVerAttribute(newVerAttribute);
        Log.trace( "Querying 'ver' for unrecognized caps. Querying: {}", packet.getFrom() );
        verAttributes.put(packetId, caps);

        final IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();
        iqRouter.addIQResultListener(packetId, this);
        iqRouter.route(iq);
    }
}
 
Example 19
Source File: S2STestService.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Run a test against the domain.
 * @return K-V pairs of debug information.
 * @throws Exception On error.
 */
public Map<String, String> run() throws Exception {
    waitUntil = new Semaphore(0);
    Map<String, String> results = new HashMap<>();
    final DomainPair pair = new DomainPair(XMPPServer.getInstance().getServerInfo().getXMPPDomain(), domain);

    // Tear down existing routes.
    final SessionManager sessionManager = SessionManager.getInstance();
    for (final Session incomingServerSession : sessionManager.getIncomingServerSessions( domain ) )
    {
        incomingServerSession.close();
    }

    final Session outgoingServerSession = sessionManager.getOutgoingServerSession( pair );
    if ( outgoingServerSession != null )
    {
        outgoingServerSession.close();
    }

    final IQ pingRequest = new IQ( Type.get );
    pingRequest.setChildElement( "ping", IQPingHandler.NAMESPACE );
    pingRequest.setFrom( pair.getLocal() );
    pingRequest.setTo( domain );

    // Intercept logging.
    final Writer logs = new StringWriter();
    final String appenderName = addAppender( logs );

    // Intercept packets.
    final PacketInterceptor interceptor = new S2SInterceptor( pingRequest );
    InterceptorManager.getInstance().addInterceptor(interceptor);

    // Send ping.
    try
    {
        Log.info( "Sending server to server ping request to " + domain );
        XMPPServer.getInstance().getIQRouter().route( pingRequest );

        // Wait for success or exceed socket timeout.
        waitUntil.tryAcquire( RemoteServerManager.getSocketTimeout(), TimeUnit.MILLISECONDS );

        // Check on the connection status.
        logSessionStatus();

        // Prepare response.
        results.put( "certs", getCertificates() );
        results.put( "stanzas", interceptor.toString() );
        results.put( "logs", logs.toString() );

        return results;
    }
    finally
    {
        // Cleanup
        InterceptorManager.getInstance().removeInterceptor( interceptor );
        removeAppender( appenderName );
    }
}
 
Example 20
Source File: MultiplexerPacketHandler.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Sends an IQ result packet confirming that the operation was successful.
 *
 * @param packet the original IQ packet.
 */
private void sendResultPacket(IQ packet) {
    IQ reply = IQ.createResultIQ(packet);
    reply.setChildElement(packet.getChildElement().createCopy());
    deliver(reply);
}