Java Code Examples for org.xmpp.packet.JID#getNode()

The following examples show how to use org.xmpp.packet.JID#getNode() . 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: LocationHandler.java    From openfireLBS with Apache License 2.0 6 votes vote down vote up
private IQ updateLocation(IQ packet) {
	IQ reply = IQ.createResultIQ(packet);

	Element iq = packet.getChildElement();
	JID from = packet.getFrom();
	String username = from.getNode();

	Element item = iq.element("item");
	Double myLon = Double.parseDouble(item.attributeValue("lon"));
	Double myLat = Double.parseDouble(item.attributeValue("lat"));

	boolean f = insertLocation(myLon,myLat,username);
	if (f){
		// reply.setChildElement(iq);
	}else{
		reply.setType(IQ.Type.error);
		reply.setError(PacketError.Condition.internal_server_error);
	}
	
	return reply;
}
 
Example 2
Source File: SessionManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Broadcasts presence updates from the originating user's resource to any of the user's
 * existing available resources (including the resource from where the update originates).
 *
 * @param originatingResource the full JID of the session that sent the presence update.
 * @param presence the presence.
 */
public void broadcastPresenceToResources( JID originatingResource, Presence presence) {
    // RFC 6121 4.4.2 says we always send to the originating resource.
    // Also RFC 6121 4.2.2 for updates.
    presence.setTo(originatingResource);
    routingTable.routePacket(originatingResource, presence, false);
    if (!SessionManager.isOtherResourcePresenceEnabled()) {
        return;
    }
    // Get list of sessions of the same user
    JID searchJID = new JID(originatingResource.getNode(), originatingResource.getDomain(), null);
    List<JID> addresses = routingTable.getRoutes(searchJID, null);
    for (JID address : addresses) {
        if (!originatingResource.equals(address)) {
            // Send the presence of the session whose presence has changed to
            // this user's other session(s)
            presence.setTo(address);
            routingTable.routePacket(address, presence, false);
        }
    }
}
 
Example 3
Source File: SessionManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the session responsible for this JID data. The returned Session may have never sent
 * an available presence (thus not have a route) or could be a Session that hasn't
 * authenticated yet (i.e. preAuthenticatedSessions).
 *
 * @param from the sender of the packet.
 * @return the <code>Session</code> associated with the JID.
 */
public ClientSession getSession(JID from) {
    // Return null if the JID is null or belongs to a foreign server. If the server is
    // shutting down then serverName will be null so answer null too in this case.
    if (from == null || serverName == null || !serverName.equals(from.getDomain())) {
        return null;
    }

    // Initially Check preAuthenticated Sessions
    if (from.getResource() != null) {
        ClientSession session = localSessionManager.getPreAuthenticatedSessions().get(from.getResource());
        if (session != null) {
            return session;
        }
    }

    if (from.getResource() == null || from.getNode() == null) {
        return null;
    }

    return routingTable.getClientRoute(from);
}
 
Example 4
Source File: InternalComponentManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the <code>Component</code> which is mapped to the specified JID. The
 * look up will only be done on components that were registered with this JVM. That
 * means that components registered in other cluster nodes are not going to be
 * considered.
 *
 * @param componentJID the jid mapped to the component.
 * @return the list of components with the specified id.
 */
private List<Component> getComponents(JID componentJID) {
    synchronized (routables) {
        if (componentJID.getNode() != null) {
            return Collections.emptyList();
        }
        RoutableComponents routable = routables.get(componentJID.getDomain());
        if (routable != null) {
            return routable.getComponents();
        }
        else {
            // Search again for those JIDs whose domain include the server name but this
            // time remove the server name from the JID's domain
            String serverName = componentJID.getDomain();
            int index = serverName.lastIndexOf("." + serverDomain);
            if (index > -1) {
                routable = routables.get(serverName.substring(0, index));
                if (routable != null) {
                    return routable.getComponents();
                }
            }
        }
        return Collections.emptyList();
    }
}
 
Example 5
Source File: UserNameManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the name of the XMPP entity. If the entity is a local user then the User's name
 * will be returned. However, if the user is not a local user then check if there exists a
 * UserNameProvider that provides name for the specified domain. If none was found then
 * the vCard of the entity might be requested and if none was found then a string
 * representation of the entity's JID will be returned.
 *
 * @param entity      the JID of the entity to get its name.
 * @param defaultName default name to return when no name was found.
 * @return the name of the XMPP entity.
 * @throws UserNotFoundException if the jid belongs to the local server but no user was
 *                               found for that jid.
 */
public static String getUserName(JID entity, String defaultName) throws UserNotFoundException {
    if (server.isLocal(entity)) {
        // Contact is a local entity so search for his user name
        User localUser = UserManager.getInstance().getUser(entity.getNode());
        return !localUser.isNameVisible() || "".equals(localUser.getName()) ? entity.getNode() : localUser.getName();
    } else {
        UserNameProvider provider = providersByDomain.get(entity.getDomain());
        if (provider != null) {
            return provider.getUserName(entity);
        }
        // TODO Request vCard to the remote server/component and return the name as
        // TODO defined in the vCard. We might need to cache this information to avoid
        // TODO high traffic.

        // Return the jid itself as the username
        return defaultName;
    }
}
 
Example 6
Source File: JDBCAdminProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private void changeAdmins(final Connection con, final String sql, final List<JID> admins) throws SQLException {
    if (!admins.isEmpty()) {
        try (final PreparedStatement pstmt = con.prepareStatement(sql)) {
            for (final JID jid : admins) {
                // OF-1837: When the database does not hold escaped data, our query should use unescaped values in the 'where' clause.
                final String queryValue = assumePersistedDataIsEscaped() ? jid.getNode() : JID.unescapeNode( jid.getNode() );
                pstmt.setString(1, queryValue);
                pstmt.execute();
            }
        }
    }
}
 
Example 7
Source File: LocationHandler.java    From openfireLBS with Apache License 2.0 5 votes vote down vote up
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
	
	System.out.println(">>>>>>>>>>>>> RECV IQ: " + packet.toXML()); // XXX
	
	// get users near me(from JID)
	if (IQ.Type.get.equals(packet.getType())) {
		return getUsersNearme(packet);
	// set from JID's location to ...
	} else if (IQ.Type.set.equals(packet.getType())) {
		JID to = packet.getTo();
		
		// send from JID's location to to JID
		if (to.getNode() != null && !to.getNode().equals("")){  
			XMPPServer.getInstance().getIQRouter().route(packet); // route to another user 
			
			return IQ.createResultIQ(packet);
		// send from JID's location to server , and update ofLocation  
		}else{ 
			return updateLocation(packet);
		}
	} else {
		IQ reply = IQ.createResultIQ(packet);
		reply.setType(IQ.Type.error);
		reply.setError(PacketError.Condition.bad_request);
		return reply;
	}
}
 
Example 8
Source File: InternalComponentManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if a component is associated to the specified address. Components
 * registered with this JVM or other cluster nodes are going to be considered.
 *
 * @param componentJID the address of the component. This is the complete domain.
 * @return true if a component is associated to the specified address.
 */
public boolean hasComponent(JID componentJID) {
    synchronized (routables) {
        if (componentJID.getNode() != null || componentJID.getResource() != null) {
            return false;
        }
//        if (componentJID.getDomain().lastIndexOf("." + serverDomain) == -1) {
//            componentJID = new JID(componentJID.getDomain() + "." + serverDomain);
//        }
        return routingTable.hasComponentRoute(componentJID);
    }
}
 
Example 9
Source File: SocketPacketWriteHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
 public void process(Packet packet) throws UnauthorizedException, PacketException {
    try {
        JID recipient = packet.getTo();
        // Check if the target domain belongs to a remote server or a component
        if (server.matchesComponent(recipient) || server.isRemote(recipient)) {
            routingTable.routePacket(recipient, packet, false);
        }
        // The target domain belongs to the local server
        else if (recipient == null || (recipient.getNode() == null && recipient.getResource() == null)) {
            // no TO was found so send back the packet to the sender
            routingTable.routePacket(packet.getFrom(), packet, false);
        }
        else if (recipient.getResource() != null || !(packet instanceof Presence)) {
            // JID is of the form <user@domain/resource>
            routingTable.routePacket(recipient, packet, false);
        }
        else {
            // JID is of the form <user@domain>
            for (JID route : routingTable.getRoutes(recipient, null)) {
                routingTable.routePacket(route, packet, false);
            }
        }
    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error.deliver") + "\n" + packet.toString(), e);
    }
}
 
Example 10
Source File: PresenceSubscribeHandler.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Obtain the roster for the given address or null if the address doesn't have a roster.</p>
 *
 * @param address The address to check
 * @return The roster or null if the address is not managed on the server
 */
private Roster getRoster(JID address) {
    String username;
    Roster roster = null;
    if (localServer.isLocal(address) && userManager.isRegisteredUser(address.getNode())) {
        username = address.getNode();
        try {
            roster = rosterManager.getRoster(username);
        }
        catch (UserNotFoundException e) {
            // Do nothing
        }
    }
    return roster;
}
 
Example 11
Source File: GroupJID.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a JID from the given JID. If the JID represents a group,
 * returns an instance of this class. Otherwise returns the given JID.
 *
 * @param jid A JID, possibly representing a group
 * @return A new GroupJID if the given JID represents a group, or the given JID
 */
public static JID fromJID(JID jid) {
    if (jid instanceof GroupJID || jid.getResource() == null || jid.getNode() == null) {
        return jid;
    } else {
        return (isGroup(jid)) ? new GroupJID(jid) : jid;
    }
}
 
Example 12
Source File: GroupJID.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(JID jid) {
    // Comparison order is domain, node, resource.
    int compare = getDomain().compareTo(jid.getDomain());
    if (compare == 0) {
        String otherNode = jid.getNode();
        compare = otherNode == null ? 1 : getGroupName().compareTo(otherNode);
    }
    if (compare == 0) {
        compare = jid.getResource() == null ? 0 : -1;
    }
    return compare;
}
 
Example 13
Source File: JDBCGroupProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<String> getGroupNames(JID user) {
    List<String> groupNames = new ArrayList<>();
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        // OF-1837: When the database does not hold escaped data, our query should use unescaped values in the 'where' clause.
        final String queryValue;
        if ( server.isLocal(user) ) {
            queryValue = assumePersistedDataIsEscaped() ? user.getNode() : JID.unescapeNode( user.getNode() );
        } else {
            String value = user.toString();
            final int splitIndex = value.lastIndexOf( "@" );
            final String node = value.substring( 0, splitIndex );
            final String processedNode = assumePersistedDataIsEscaped() ? node : JID.unescapeNode( node );
            queryValue = processedNode + value.substring( splitIndex );
        }
        con = getConnection();
        pstmt = con.prepareStatement(userGroupsSQL);
        pstmt.setString(1, queryValue);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            groupNames.add(rs.getString(1));
        }
    }
    catch (SQLException e) {
        Log.error(e.getMessage(), e);
    }
    finally {
        DbConnectionManager.closeConnection(rs, pstmt, con);
    }
    return groupNames;
}
 
Example 14
Source File: SessionManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Sends a message with a given subject and body to one or more user sessions related to the
 * specified address. If address is null or the address's node is null then the message will be
 * sent to all the user sessions. But if the address includes a node but no resource then
 * the message will be sent to all the user sessions of the requeted user (defined by the node).
 * Finally, if the address is a full JID then the message will be sent to the session associated
 * to the full JID. If no session is found then the message is not sent.
 *
 * @param address the address that defines the sessions that will receive the message.
 * @param subject the subject to broadcast.
 * @param body    the body to broadcast.
 */
public void sendServerMessage(JID address, String subject, String body) {
    Message packet = createServerMessage(subject, body);
    if (address == null || address.getNode() == null || !userManager.isRegisteredUser(address)) {
        broadcast(packet);
    }
    else if (address.getResource() == null || address.getResource().length() < 1) {
        userBroadcast(address.getNode(), packet);
    }
    else {
        routingTable.routePacket(address, packet, true);
    }
}
 
Example 15
Source File: OfflineMessageStore.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Adds a message to this message store. Messages will be stored and made
 * available for later delivery.
 *
 * Note that certain messages are ignored by this implementation, for example, messages that are carbon copies,
 * have 'no-store' hints, or for which the intended recipient is not a local user. When a message is discarded for
 * reasons like these, this method will return 'false'.
 *
 * @param message the message to store.
 * @return true when data was stored, otherwise false.
 */
public boolean addMessage(Message message) {
    if (message == null) {
        Log.trace( "Not storing null message." );
        return false;
    }
    if(!shouldStoreMessage(message)) {
        Log.trace( "Not storing message, as 'should store' returned false." );
        return false;
    }
    JID recipient = message.getTo();
    String username = recipient.getNode();
    // If the username is null (such as when an anonymous user), don't store.
    if (username == null || !UserManager.getInstance().isRegisteredUser(recipient)) {
        Log.trace( "Not storing message for which the recipient ({}) is not a registered user.", recipient );
        return false;
    }
    else
    if (!XMPPServer.getInstance().getServerInfo().getXMPPDomain().equals(recipient.getDomain())) {
        Log.trace( "Not storing message for which the recipient ({}) is not a local user.", recipient );
        // Do not store messages sent to users of remote servers
        return false;
    }

    long messageID = SequenceManager.nextID(JiveConstants.OFFLINE);

    // Get the message in XML format.
    String msgXML = message.getElement().asXML();

    Connection con = null;
    PreparedStatement pstmt = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(INSERT_OFFLINE);
        pstmt.setString(1, username);
        pstmt.setLong(2, messageID);
        pstmt.setString(3, StringUtils.dateToMillis(new java.util.Date()));
        pstmt.setInt(4, msgXML.length());
        pstmt.setString(5, msgXML);
        pstmt.executeUpdate();
    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
        return false;
    }
    finally {
        DbConnectionManager.closeConnection(pstmt, con);
    }

    // Update the cached size if it exists.
    if (sizeCache.containsKey(username)) {
        int size = sizeCache.get(username);
        size += msgXML.length();
        sizeCache.put(username, size);
    }
    return true;
}
 
Example 16
Source File: IQRosterHandler.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * The packet is a typical 'set' or 'get' update targeted at the server.
 * Notice that the set could be a roster removal in which case we have to
 * generate a local roster removal update as well as a new roster removal
 * to send to the the roster item's owner.
 *
 * @param packet The packet that triggered this update
 * @return Either a response to the roster update or null if the packet is corrupt and the session was closed down
 */
private IQ manageRoster(org.xmpp.packet.Roster packet) throws UnauthorizedException,
        UserAlreadyExistsException, SharedGroupException {

    IQ returnPacket = null;
    JID sender = packet.getFrom();
    IQ.Type type = packet.getType();

    try {
        if ((sender.getNode() == null || !RosterManager.isRosterServiceEnabled() ||
                !userManager.isRegisteredUser(sender.getNode())) &&
                IQ.Type.get == type) {
            // If anonymous user asks for his roster or roster service is disabled then
            // return an empty roster
            IQ reply = IQ.createResultIQ(packet);
            reply.setChildElement("query", "jabber:iq:roster");
            return reply;
        }
        if (!localServer.isLocal(sender)) {
            // Sender belongs to a remote server so discard this IQ request
            Log.warn("Discarding IQ roster packet of remote user: " + packet);
            return null;
        }

        Roster cachedRoster = userManager.getUser(sender.getNode()).getRoster();
        if (IQ.Type.get == type) {

            if (RosterManager.isRosterVersioningEnabled()) {
                String clientVersion = packet.getChildElement().attributeValue("ver");
                String latestVersion = String.valueOf( cachedRoster.hashCode() );
                // Whether or not the roster has been modified since the version ID enumerated by the client, ...
                if (!latestVersion.equals(clientVersion)) {
                    // ... the server MUST either return the complete roster
                    // (including a 'ver' attribute that signals the latest version)
                    returnPacket = cachedRoster.getReset();
                    returnPacket.getChildElement().addAttribute("ver", latestVersion );
                } else {
                    // ... or return an empty IQ-result
                    returnPacket = new org.xmpp.packet.IQ();
                }
            } else {
                returnPacket = cachedRoster.getReset();
            }
            returnPacket.setType(IQ.Type.result);
            returnPacket.setTo(sender);
            returnPacket.setID(packet.getID());
            // Force delivery of the response because we need to trigger
            // a presence probe from all contacts
            deliverer.deliver(returnPacket);
            returnPacket = null;
        }
        else if (IQ.Type.set == type) {
            returnPacket = IQ.createResultIQ(packet);

            // RFC 6121 2.3.3.  Error Cases:
            // The server MUST return a <bad-request/> stanza error to the client if the roster set contains any of the following violations:
            // The <query/> element contains more than one <item/> child element.
            if (packet.getItems().size() > 1) {
                returnPacket.setError(new PacketError(PacketError.Condition.bad_request, PacketError.Type.modify, "Query contains more than one item"));
            } else {
                for (org.xmpp.packet.Roster.Item item : packet.getItems()) {
                    if (item.getSubscription() == org.xmpp.packet.Roster.Subscription.remove) {
                        if (removeItem(cachedRoster, packet.getFrom(), item) == null) {
                            // RFC 6121 2.5.3.  Error Cases: If the value of the 'jid' attribute specifies an item that is not in the roster, then the server MUST return an <item-not-found/> stanza error.
                            returnPacket.setError(PacketError.Condition.item_not_found);
                        }
                    } else {
                        PacketError error = checkGroups(item.getGroups());
                        if (error != null) {
                            returnPacket.setError(error);
                        } else {
                            if (cachedRoster.isRosterItem(item.getJID())) {
                                // existing item
                                RosterItem cachedItem = cachedRoster.getRosterItem(item.getJID());
                                cachedItem.setAsCopyOf(item);
                                cachedRoster.updateRosterItem(cachedItem);
                            } else {
                                // new item
                                cachedRoster.createRosterItem(item);
                            }
                        }
                    }
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        throw new UnauthorizedException(e);
    }

    return returnPacket;

}
 
Example 17
Source File: OfflineMessageStrategy.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public void storeOffline(Message message) {
    if (message != null) {
        // Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
        // Also ignore message carbons
        JID recipientJID = message.getTo();
        if (recipientJID == null || serverAddress.equals(recipientJID) ||
                recipientJID.getNode() == null ||
                message.getExtension("received", "urn:xmpp:carbons:2") != null ||
                !UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
            return;
        }

        // Do not store messages if communication is blocked
        PrivacyList list =
                PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
        if (list != null && list.shouldBlockPacket(message)) {
            Message result = message.createCopy();
            result.setTo(message.getFrom());
            result.setFrom(message.getTo());
            result.setError(PacketError.Condition.service_unavailable);
            XMPPServer.getInstance().getRoutingTable().routePacket(message.getFrom(), result, true);
            return;
        }

        // 8.5.2.  localpart@domainpart
        // 8.5.2.2.  No Available or Connected Resources
        if (recipientJID.getResource() == null) {
            if (message.getType() == Message.Type.headline || message.getType() == Message.Type.error) {
                // For a message stanza of type "headline" or "error", the server MUST silently ignore the message.
                return;
            }
            // // For a message stanza of type "groupchat", the server MUST return an error to the sender, which SHOULD be <service-unavailable/>.
            else if (message.getType() == Message.Type.groupchat) {
                bounce(message);
                return;
            }
        } else {
            // 8.5.3.  localpart@domainpart/resourcepart
            // 8.5.3.2.1.  Message

            // For a message stanza of type "normal", "groupchat", or "headline", the server MUST either (a) silently ignore the stanza
            // or (b) return an error stanza to the sender, which SHOULD be <service-unavailable/>.
            if (message.getType() == Message.Type.normal || message.getType() == Message.Type.groupchat || message.getType() == Message.Type.headline) {
                // Depending on the OfflineMessageStragey, we may silently ignore or bounce
                if (type == Type.bounce) {
                    bounce(message);
                }
                // Either bounce or silently ignore, never store such messages
                return;
            }
            // For a message stanza of type "error", the server MUST silently ignore the stanza.
            else if (message.getType() == Message.Type.error) {
                return;
            }
        }

        switch (type) {
        case bounce:
            bounce(message);
            break;
        case store:
            store(message);
            break;
        case store_and_bounce:
            if (underQuota(message)) {
                store(message);
            }
            else {
                Log.debug( "Unable to store, as user is over storage quota. Bouncing message instead: " + message.toXML() );
                bounce(message);
            }
            break;
        case store_and_drop:
            if (underQuota(message)) {
                store(message);
            } else {
                Log.debug( "Unable to store, as user is over storage quota. Silently dropping message: " + message.toXML() );
            }
            break;
        case drop:
            // Drop essentially means silently ignore/do nothing
            break;
        }
    }
}
 
Example 18
Source File: MultiUserChatServiceImpl.java    From Openfire with Apache License 2.0 4 votes vote down vote up
@Override
public void processPacket(final Packet packet) {

    Log.trace( "Routing stanza: {}", packet.toXML() );
    if (!isServiceEnabled()) {
        Log.trace( "Service is disabled. Ignoring stanza." );
        return;
    }
    // The MUC service will receive all the packets whose domain matches the domain of the MUC
    // service. This means that, for instance, a disco request should be responded by the
    // service itself instead of relying on the server to handle the request.
    try {
        // Check if the packet is a disco request or a packet with namespace iq:register
        if (packet instanceof IQ) {
            if (process((IQ)packet)) {
                Log.trace( "Done processing IQ stanza." );
                return;
            }
        } else if (packet instanceof Message) {
            final Message msg = (Message) packet;
            if (msg.getType() == Message.Type.error) {
                // Bounced message, drop user.
                removeUser(packet.getFrom());
                Log.trace( "Done processing Message stanza." );
                return;
            }
        } else if (packet instanceof Presence) {
            final Presence pres = (Presence) packet;
            if (pres.getType() == Presence.Type.error) {
                // Bounced presence, drop user.
                removeUser(packet.getFrom());
                Log.trace( "Done processing Presence stanza." );
                return;
            }
        }

        if ( packet.getTo().getNode() == null )
        {
            Log.trace( "Stanza was addressed at the service itself, which by now should have been handled." );
            if ( packet instanceof IQ && ((IQ) packet).isRequest() )
            {
                final IQ reply = IQ.createResultIQ( (IQ) packet );
                reply.setChildElement( ((IQ) packet).getChildElement().createCopy() );
                reply.setError( PacketError.Condition.feature_not_implemented );
                router.route( reply );
            }
            Log.debug( "Ignoring stanza addressed at conference service: {}", packet.toXML() );
        }
        else
        {
            Log.trace( "The stanza is a normal packet that should possibly be sent to the room." );
            final JID recipient = packet.getTo();
            final String roomName = recipient != null ? recipient.getNode() : null;
            final JID userJid = packet.getFrom();
            Log.trace( "Stanza recipient: {}, room name: {}, sender: {}", recipient, roomName, userJid );
            try (final AutoCloseableReentrantLock.AutoCloseableLock ignored = new AutoCloseableReentrantLock(MultiUserChatServiceImpl.class, userJid.toString()).lock()) {
                if ( !packet.getElement().elements(FMUCHandler.FMUC).isEmpty() ) {
                    Log.trace( "Stanza is a FMUC stanza." );
                    final MUCRoom chatRoom = getChatRoom(roomName);
                    if ( chatRoom != null ) {
                        chatRoom.getFmucHandler().process(packet);
                    } else {
                        Log.warn( "Unable to process FMUC stanza, as room it's addressed to does not exist: {}", roomName );
                        // FIXME need to send error back in case of IQ request, and FMUC join. Might want to send error back in other cases too.
                    }
                } else {
                    Log.trace( "Stanza is a regular MUC stanza." );
                    getChatUser(userJid, roomName).process(packet);
                }
            }
        }
    }
    catch (final Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
    }
}
 
Example 19
Source File: GroupJID.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a JID representing a Group from a regular JID. This constructor is
 * private because it is used only from within this class after the source JID
 * has been validated.
 * 
 * @param source A full JID representing a group
 * @see GroupJID#fromString
 */
private GroupJID(JID source) {
    // skip stringprep for the new group JID, since it has already been parsed
    super(source.getNode(), source.getDomain(), source.getResource(), true);
}